Skip to content

Commit 7dfd260

Browse files
committed
initial commit of 1.0.0 version
1 parent 50d91d1 commit 7dfd260

34 files changed

+6863
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2+
.idea
23
pom.xml.tag
34
pom.xml.releaseBackup
45
pom.xml.versionsBackup
@@ -7,3 +8,6 @@ release.properties
78
dependency-reduced-pom.xml
89
buildNumber.properties
910
.mvn/timing.properties
11+
*.classpath
12+
.project
13+
.settings

db-setup-core.iml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
4+
<output url="file://$MODULE_DIR$/db-setup-core/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/db-setup-core/target/test-classes" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$/db-setup-core">
8+
<sourceFolder url="file://$MODULE_DIR$/db-setup-core/src/main/java" isTestSource="false" />
9+
<sourceFolder url="file://$MODULE_DIR$/db-setup-core/src/main/resources" type="java-resource" />
10+
<sourceFolder url="file://$MODULE_DIR$/db-setup-core/target/generated-sources/sources" isTestSource="false" generated="true" />
11+
<sourceFolder url="file://$MODULE_DIR$/db-setup-core/src/test/java" isTestSource="true" />
12+
<sourceFolder url="file://$MODULE_DIR$/db-setup-core/target/generated-sources/license" isTestSource="false" generated="true" />
13+
<excludeFolder url="file://$MODULE_DIR$/db-setup-core/target/generated-resources" />
14+
<excludeFolder url="file://$MODULE_DIR$/db-setup-core/target/jaxb2" />
15+
<excludeFolder url="file://$MODULE_DIR$/db-setup-core/target/maven-archiver" />
16+
<excludeFolder url="file://$MODULE_DIR$/db-setup-core/target/surefire" />
17+
</content>
18+
<orderEntry type="inheritedJdk" />
19+
<orderEntry type="sourceFolder" forTests="false" />
20+
<orderEntry type="library" scope="PROVIDED" name="Maven: com.liferay.portal:portal-service:6.2.5" level="project" />
21+
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.portlet:portlet-api:2.0" level="project" />
22+
<orderEntry type="library" name="Maven: org.jboss:jboss-vfs:3.1.0.Final" level="project" />
23+
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.0.0.CR1" level="project" />
24+
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
25+
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
26+
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-all:1.10.19" level="project" />
27+
</component>
28+
</module>

db-setup-core/.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# 4 space indentation
12+
[*.java]
13+
indent_style = space
14+
indent_size = 4

db-setup-core/pom.xml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.mimacom.liferay</groupId>
7+
<version>1.0.0</version>
8+
<artifactId>db-setup-core</artifactId>
9+
<name>Liferay Portal DB Setup core</name>
10+
<description>Library that allows to declare a set of Liferay data to be created and create them using the API.
11+
</description>
12+
<inceptionYear>2016</inceptionYear>
13+
14+
<packaging>jar</packaging>
15+
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.codehaus.mojo</groupId>
20+
<artifactId>jaxb2-maven-plugin</artifactId>
21+
<version>1.5</version>
22+
<executions>
23+
<execution>
24+
<id>xjc</id>
25+
<goals>
26+
<goal>xjc</goal>
27+
</goals>
28+
</execution>
29+
</executions>
30+
<configuration>
31+
<outputDirectory>${project.build.directory}/generated-sources/sources</outputDirectory>
32+
<schemaDirectory>${basedir}/src/main/resources</schemaDirectory>
33+
<packageName>com.mimacom.liferay.portal.setup.domain</packageName>
34+
<clearOutputDir>false</clearOutputDir>
35+
</configuration>
36+
</plugin>
37+
38+
<plugin>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>2.5</version>
41+
<configuration>
42+
<encoding>UTF-8</encoding>
43+
<source>1.7</source>
44+
<target>1.7</target>
45+
</configuration>
46+
</plugin>
47+
48+
<plugin>
49+
<groupId>org.codehaus.mojo</groupId>
50+
<artifactId>license-maven-plugin</artifactId>
51+
<version>1.8</version>
52+
<configuration>
53+
<outputDirectory>${project.build.directory}/generated-sources/license</outputDirectory>
54+
<thirdPartyFilename>THIRD-PARTY.txt</thirdPartyFilename>
55+
<licenseName>mit</licenseName>
56+
<excludes>
57+
<exclude>**/package-info.java</exclude>
58+
</excludes>
59+
<canUpdateCopyright>true</canUpdateCopyright>
60+
<canUpdateDescription>true</canUpdateDescription>
61+
<canUpdateLicense>true</canUpdateLicense>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>first</id>
66+
<goals>
67+
<goal>update-file-header</goal>
68+
</goals>
69+
<phase>process-sources</phase>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-resources-plugin</artifactId>
77+
<version>2.6</version>
78+
<configuration>
79+
<encoding>UTF-8</encoding>
80+
</configuration>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-javadoc-plugin</artifactId>
85+
<version>2.9.1</version>
86+
<configuration>
87+
<charset>UTF-8</charset>
88+
<encoding>UTF-8</encoding>
89+
</configuration>
90+
</plugin>
91+
</plugins>
92+
</build>
93+
94+
<dependencies>
95+
<dependency>
96+
<groupId>com.liferay.portal</groupId>
97+
<artifactId>portal-service</artifactId>
98+
<version>6.2.5</version>
99+
<scope>provided</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>javax.portlet</groupId>
103+
<artifactId>portlet-api</artifactId>
104+
<version>2.0</version>
105+
<scope>provided</scope>
106+
</dependency>
107+
<dependency>
108+
<groupId>org.jboss</groupId>
109+
<artifactId>jboss-vfs</artifactId>
110+
<version>3.1.0.Final</version>
111+
</dependency>
112+
<!-- Test -->
113+
<dependency>
114+
<groupId>junit</groupId>
115+
<artifactId>junit</artifactId>
116+
<version>4.12</version>
117+
<scope>test</scope>
118+
</dependency>
119+
<dependency>
120+
<groupId>org.mockito</groupId>
121+
<artifactId>mockito-all</artifactId>
122+
<version>1.10.19</version>
123+
<scope>test</scope>
124+
</dependency>
125+
</dependencies>
126+
<scm>
127+
<url>https://github.com/mimacom/liferay-db-setup-core</url>
128+
</scm>
129+
<organization>
130+
<name>mimacom ag</name>
131+
<url>http://www.mimacom.com</url>
132+
</organization>
133+
134+
<licenses>
135+
<license>
136+
<name>The MIT License (MIT)</name>
137+
<url>https://opensource.org/licenses/MIT</url>
138+
<distribution>repo</distribution>
139+
<comments>A business-friendly OSS license</comments>
140+
</license>
141+
</licenses>
142+
</project>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.mimacom.liferay.portal.setup;
2+
3+
/*
4+
* #%L
5+
* Liferay Portal DB Setup core
6+
* %%
7+
* Copyright (C) 2016 mimacom ag
8+
* %%
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
* #L%
27+
*/
28+
29+
30+
import java.io.File;
31+
import java.io.IOException;
32+
import java.net.URI;
33+
import java.net.URISyntaxException;
34+
import java.net.URL;
35+
36+
import org.jboss.vfs.VirtualFile;
37+
38+
import com.liferay.portal.kernel.log.Log;
39+
import com.liferay.portal.kernel.log.LogFactoryUtil;
40+
import com.liferay.portal.kernel.upgrade.UpgradeException;
41+
import com.liferay.portal.kernel.upgrade.UpgradeProcess;
42+
43+
/**
44+
* Created by mapa on 13.3.2015.
45+
*/
46+
public abstract class BasicSetupUpgradeProcess extends UpgradeProcess {
47+
/**
48+
* Logger.
49+
*/
50+
private static final Log LOG = LogFactoryUtil.getLog(BasicSetupUpgradeProcess.class);
51+
52+
/**
53+
* Does upgrade.
54+
*
55+
* @throws com.liferay.portal.kernel.upgrade.UpgradeException
56+
* wrapped exception
57+
*/
58+
@Override
59+
public final void upgrade() throws UpgradeException {
60+
61+
String[] fileNames = getSetupFileNames();
62+
for (String fileName : fileNames) {
63+
LOG.info("Starting upgrade process. Filename: " + fileName);
64+
65+
File file = getSetupFile(fileName);
66+
if (file == null) {
67+
throw new UpgradeException("XML configuration not found");
68+
}
69+
LiferaySetup.setup(file);
70+
LOG.info("Finished upgrade process. Filename: " + fileName);
71+
}
72+
}
73+
74+
/**
75+
* checks and returns file used for setup.
76+
*
77+
* @param fileName
78+
* name of resource
79+
* @return setup xml file
80+
*/
81+
public final File getSetupFile(final String fileName) {
82+
83+
ClassLoader cl = this.getClass().getClassLoader();
84+
URL url = cl.getResource(fileName);
85+
if (url == null) {
86+
LOG.error("XML configuration not found");
87+
88+
return null;
89+
}
90+
91+
URI uri;
92+
try {
93+
uri = url.toURI();
94+
} catch (URISyntaxException e) {
95+
LOG.error("Problem with reading configuration xml", e);
96+
return null;
97+
}
98+
99+
File file = null;
100+
if (uri.getScheme().equals("vfs")) {
101+
try {
102+
VirtualFile virtualFile = (VirtualFile) url.openConnection().getContent();
103+
file = virtualFile.getPhysicalFile();
104+
105+
} catch (IOException e) {
106+
LOG.error("Couldn't open xml configuration", e);
107+
return null;
108+
}
109+
} else if (uri.getScheme().equals("file")) {
110+
file = new File(uri);
111+
}
112+
113+
return file;
114+
}
115+
116+
/**
117+
* @return paths to setup xml files.
118+
*/
119+
protected abstract String[] getSetupFileNames();
120+
121+
}

0 commit comments

Comments
 (0)