Merge branch 'docker' of https://gitbox.apache.org/repos/asf/turbine-archetypes into docker
diff --git a/pom.xml b/pom.xml
index 24cc232..0034074 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,12 +26,12 @@
<version>20</version><!-- like turbine parent -->
</parent>
<groupId>org.apache.turbine</groupId>
- <artifactId>turbine-webapp-5.0</artifactId>
- <version>1.0.3-SNAPSHOT</version>
+ <artifactId>turbine-webapp-5.1-docker</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>maven-archetype</packaging>
<name>Archetype - Turbine 5.0 WebApp</name>
- <description>This archetype sets up a web application project based on Apache Turbine 5.0</description>
+ <description>This archetype sets up a web application project based on Apache Turbine 5.1 and torque 4.1 with docker compose</description>
<url>https://turbine.apache.org</url>
<inceptionYear>2011</inceptionYear>
@@ -41,7 +41,6 @@
<developerConnection>scm:git:https://github.com/apache/turbine-archetypes</developerConnection>
<url>scm:git:https://github.com/apache/turbine-archetypes</url>
</scm>
-
<properties>
<turbine_database_url>jdbc:mysql://localhost:3306/</turbine_database_url>
<docker>false</docker>
diff --git a/src/main/resources/archetype-resources/docker-resources/db/Dockerfile b/src/main/resources/archetype-resources/docker-resources/db/Dockerfile
index 555e234..8e715aa 100644
--- a/src/main/resources/archetype-resources/docker-resources/db/Dockerfile
+++ b/src/main/resources/archetype-resources/docker-resources/db/Dockerfile
@@ -1,7 +1,7 @@
#using multi-stage
# mariadb use docker-entrypoint
-FROM mysql:latest as builder
+FROM mysql:8.0.19 as builder
# That file does the DB initialization but also runs mysql daemon, by removing the last line it will only init
RUN ["/bin/sed", "-i", "s/exec \"$@\"/echo \"not running $@\"/", "/usr/local/bin/docker-entrypoint.sh"]
@@ -56,9 +56,9 @@
# it has been declared, those changes will be discarded.
RUN ["/usr/local/bin/docker-entrypoint.sh", "mysqld", "--datadir", "/initialized-db"]
-#RUN /docker-entrypoint.sh mysqld --datadir=/initialized-db && sleep 10
-FROM mysql:latest
+
+FROM mysql:8.0.19
# my.cnf setting data-dir
COPY --from=builder /initialized-db /var/lib/mysql
diff --git a/src/main/resources/archetype-resources/docker-resources/docker-compose.yml b/src/main/resources/archetype-resources/docker-resources/docker-compose.yml
index bbe4ca2..bdf0f0c 100644
--- a/src/main/resources/archetype-resources/docker-resources/docker-compose.yml
+++ b/src/main/resources/archetype-resources/docker-resources/docker-compose.yml
@@ -29,9 +29,7 @@
volumes:
- ../:/myapp
- - "${app_volume_local_repo}:/m2repo"
- #networks:
- # - db
+ - '${app_volume_local_repo}:/m2repo'
db:
# set the build context
@@ -71,14 +69,9 @@
# host: port
- "13306:3306"
- #networks:
- # - db
- #command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci]
command: --default-authentication-plugin=mysql_native_password
volumes:
#db_data:
mysql_log:
-
-#networks:
-# db:
+
diff --git a/src/main/resources/archetype-resources/docker-resources/readme.md b/src/main/resources/archetype-resources/docker-resources/readme.md
index 2f4c711..f9c17b5 100644
--- a/src/main/resources/archetype-resources/docker-resources/readme.md
+++ b/src/main/resources/archetype-resources/docker-resources/readme.md
@@ -36,7 +36,16 @@
## Check Docker Compose file (optional)
-- Check services in docker-compose.yml (volumes)
+- Check services in docker-compose.yml (volumes). You might map your local maven repostory like this:
+
+```sh
+ volumes:
+ - ../:/myapp
+ - '<localpath>:/m2repo'
+ ```yml
+
+- Check format:
+
```
docker-compose config
```
@@ -50,37 +59,24 @@
- Optionally Check system or cleanup, e.g. with docker-compose down, docker-compose down -v or docker sytem prune (removes any container on system).
+## Start
+
- If services are already installed, activate/start by
+
+```sh
docker-compose up
+```
- Starting the app service will build the app and start jetty with Maven on port 8081.
This command is set as a **command** in the app service in docker compose.
-If not yet done, build on the host with mvn clean install -f ../pom.xml -Pdocker.
+If not yet done, build on the host with
-### Build Services
-
-The app service uses later a volume, which maps to the local maven repository, which you may need/not need.
-The db service uses mysql-latest (currently 8.x), you may replace it with a fixed release tag, e.g. 5.6.
-
- - Build it
-
```sh
- docker-compose build --no-cache
+mvn clean install -f ../pom.xml -Pdocker
```
- .. optionally build it separately
- docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db db
-
- .. building app service first/only requires removing the dependency in docker-compose.yml(comment depends_on: db)
- docker-compose build --no-cache app
-
-DB_CONTEXT is set to allow starting the db container standalone (in folder db, e.g. with docker build --tag my-db .)
-to test it. CAVEAT: The db service is build and populated until now with hard coded data.
-It is a dependency for the service app (see app/Dockerfile).
-
-
-### Starting Services
+### Start and Stopp the service
Start both services in one step
```
@@ -93,8 +89,29 @@
```
This will start first the db service, then the app service. Jetty is run exposing the webapp to **http://localhost:8081/app**.
+
+Login should work with user admin/password or user/password.
+
+
By default remote debugging is activated (port 9000), which could be removed/commented in docker-compose.yml.
-You could follow the logs with docker-compose logs -f app or docker-compose logs -f db.
+
+You could follow the logs (in folder docker-resources) with
+
+``` sh
+docker-compose logs -f app
+```
+
+ or
+
+``` sh
+ docker-compose logs -f db.
+ ```
+
+Stop by Ctrl-C or
+```
+docker-compose down
+```
+
#### Lifecycle (developers only)
@@ -127,6 +144,31 @@
ls -la /myapp // should list pom.xml ...
```
+### Build Services
+
+The app service uses later a volume, which maps to the local maven repository, which you may need/not need.
+The db service uses mysql (currently 8.0.x), you may replace it with a fixed release tag, e.g. 5.6.
+
+In any case, you need then to rebuild the image.
+
+
+ - Build the image
+
+```sh
+ docker-compose build --no-cache
+```
+
+ .. optionally build it separately
+ docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db db
+
+ .. building app service first/only requires removing the dependency in docker-compose.yml(comment depends_on: db)
+ docker-compose build --no-cache app
+
+DB_CONTEXT is set to allow starting the db container standalone (in folder db, e.g. with docker build --tag my-db .)
+to test it. CAVEAT: The db service is build and populated until now with hard coded data.
+It is a dependency for the service app (see app/Dockerfile).
+
+
# System Specific Informations
## Windows
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index b3b5931..1468cd3 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -200,7 +200,7 @@
<dependency>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
- <version>8.0.17</version>
+ <version>#var("mysql.version")</version>
</dependency>
</dependencies>
<!-- this is mysql specific -->
@@ -269,7 +269,7 @@
<dependency>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
- <version>8.0.17</version>
+ <version>#var("mysql.version")</version>
</dependency>
<!-- Allow lookup of #var("web:rootDir") in log4j2 file -->
<dependency>
@@ -278,7 +278,6 @@
<version>#var("log4j2.version")</version>
</dependency>
<!-- Required for Java 9 and higher -->
- <!--
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
@@ -294,8 +293,6 @@
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
- -->
-
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
@@ -325,11 +322,10 @@
</exclusion>
</exclusions>
</dependency>
- <!-- slf4j already non optional/required slf4j in T5.0-->
<dependency>
<groupId>org.apache.fulcrum</groupId>
<artifactId>fulcrum-yaafi</artifactId>
- <version>1.0.8</version>
+ <version>#var("fulcrum.yaafi")</version>
</dependency>
<!-- if using intake -->
<dependency>
@@ -400,7 +396,7 @@
<dependency>
<groupId>org.apache.fulcrum</groupId>
<artifactId>fulcrum-testcontainer</artifactId>
- <version>1.0.8</version>
+ <version>#var("fulcrum.testcontainer")</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -410,11 +406,14 @@
<maven.compile.target>1.8</maven.compile.target>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<log4j2.version>2.12.0</log4j2.version>
- <torque.version>4.0</torque.version>
- <fulcrum.json>2.0.0</fulcrum.json>
- <fulcrum.intake>2.0.0</fulcrum.intake>
- <fulcrum.security>1.1.3</fulcrum.security>
- <turbine.core>5.0</turbine.core>
+ <mysql.version>8.0.17</mysql.version>
+ <fulcrum.yaafi>1.0.8</fulcrum.yaafi>
+ <fulcrum.testcontainer>1.0.9-SNAPSHOT</fulcrum.testcontainer>
+ <torque.version>4.1-SNAPSHOT</torque.version>
+ <fulcrum.json>2.0.1-SNAPSHOT</fulcrum.json>
+ <fulcrum.intake>2.0.1-SNAPSHOT</fulcrum.intake>
+ <fulcrum.security>2.0.0-SNAPSHOT</fulcrum.security>
+ <turbine.core>5.1-SNAPSHOT</turbine.core>
<skipTests>true</skipTests>
</properties>
@@ -441,7 +440,7 @@
<id>tomcat</id>
<build>
<defaultGoal>tomcat:run</defaultGoal>
- <finalName>#var("project.artifactId")</finalName>
+ <finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -458,6 +457,28 @@
<activation>
<activeByDefault>${docker}</activeByDefault>
</activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-db</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>create-data</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
<properties>
<turbine_database_url>jdbc:mysql://db:3306/</turbine_database_url>
<!-- to provide e.g. local snapshot builds -->
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
index 074e2e2..0a8afb7 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
@@ -34,10 +34,11 @@
import ${package}.flux.modules.actions.FluxAction;
/**
- * Change Password action.
- *
+ * Change user action
*/
-public class FluxUserAction extends FluxAction {
+public class FluxUserAction extends FluxAction
+{
+ /** Logging **/
private static Log log = LogFactory.getLog(FluxUserAction.class);
/** Injected service instance */
@@ -48,7 +49,8 @@
* ActionEvent responsible for inserting a new user into the Turbine security
* system.
*/
- public void doInsert(PipelineData pipelineData, Context context) throws Exception {
+ public void doInsert(PipelineData pipelineData, Context context) throws Exception
+ {
RunData data = (RunData) pipelineData;
/*
@@ -57,12 +59,14 @@
String username = data.getParameters().getString("username");
String password = data.getParameters().getString("password");
- if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
+ if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password))
+ {
/*
* Make sure this account doesn't already exist. If the account already exists
* then alert the user and make them change the username.
*/
- if (security.accountExists(username)) {
+ if (security.accountExists(username))
+ {
context.put("username", username);
context.put("errorTemplate", "user,FluxUserAlreadyExists.vm");
@@ -70,9 +74,12 @@
data.getParameters().add("mode", "insert");
data.setScreen("user,FluxUserForm.vm");
return;
- } else {
+ }
+ else
+ {
- try {
+ try
+ {
/*
* Create a new user modeled directly from the SecurityServiceTest method
*/
@@ -83,7 +90,9 @@
// Use security to force the password
security.forcePassword(user, password);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("Error adding new user: " + e);
context.put("username", username);
@@ -106,35 +115,32 @@
}
/**
- * ActionEvent responsible updating a user. Must check the input for integrity
- * before allowing the user info to be update in the database.
+ * ActionEvent responsible updating a user
*/
- public void doUpdate(PipelineData pipelineData, Context context) throws Exception {
+ public void doUpdate(PipelineData pipelineData, Context context) throws Exception
+ {
RunData data = (RunData) pipelineData;
String username = data.getParameters().getString("username");
- if (!StringUtils.isEmpty(username)) {
- if (security.accountExists(username)) {
-
- // This wrapped user does work for change password though... see below
+ if (!StringUtils.isEmpty(username))
+ {
+ if (security.accountExists(username))
+ {
+ // Load the wrapped user object
User user = security.getUser(username);
+ User tmp_user = security.getUser(username);
if (user != null) {
- // update all properties from form
+ // Update user details except for the password
data.getParameters().setProperties(user);
-
- // save the changes to the user account
+ user.setPassword(tmp_user.getPassword());
security.saveUser(user);
- // get the new password from form submit
+ // Test if Admin provided new password
String password = data.getParameters().getString("password");
-
- // Only update if we received a new (non-empty) password
- if (!StringUtils.isEmpty(password)) {
-
+ if (!StringUtils.isEmpty(password))
+ {
// Change user password
security.changePassword(user, user.getPassword(), password);
-
- // this still works
security.forcePassword(user, password);
} else {
data.setMessage("Cannot provide an empty password");
@@ -150,16 +156,19 @@
}
/**
- * ActionEvent responsible for removing a user from the Tambora system.
+ * ActionEvent responsible for removing a user
*/
- public void doDelete(PipelineData pipelineData, Context context) throws Exception {
+ public void doDelete(PipelineData pipelineData, Context context) throws Exception
+ {
- try {
+ try
+ {
RunData data = (RunData) pipelineData;
String username = data.getParameters().getString("username");
- if (!StringUtils.isEmpty(username)) {
- if (security.accountExists(username)) {
-
+ if (!StringUtils.isEmpty(username))
+ {
+ if (security.accountExists(username))
+ {
// find the user object and remove using security mgr
User user = security.getUser(username);
@@ -174,7 +183,9 @@
data.setMessage("User not found!");
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("Could not remove user: " + e);
}
}
@@ -182,17 +193,21 @@
/**
* Update the roles that are to assigned to a user for a project.
*/
- public void doRoles(PipelineData pipelineData, Context context) throws Exception {
+ public void doRoles(PipelineData pipelineData, Context context) throws Exception
+ {
RunData data = (RunData) pipelineData;
- try {
+ try
+ {
/*
* Get the user we are trying to update. The username has been hidden in the
* form so we will grab the hidden username and use that to retrieve the user.
*/
String username = data.getParameters().getString("username");
- if (!StringUtils.isEmpty(username)) {
- if (security.accountExists(username)) {
+ if (!StringUtils.isEmpty(username))
+ {
+ if (security.accountExists(username))
+ {
User user = security.getUser(username);
// Get the Turbine ACL implementation
@@ -204,9 +219,11 @@
GroupSet groups = security.getAllGroups();
RoleSet roles = security.getAllRoles();
- for (Group group : groups) {
+ for (Group group : groups)
+ {
String groupName = group.getName();
- for (Role role : roles) {
+ for (Role role : roles)
+ {
String roleName = role.getName();
/*
@@ -258,7 +275,8 @@
/**
* Implement this to add information to the context.
*/
- public void doPerform(PipelineData pipelineData, Context context) throws Exception {
+ public void doPerform(PipelineData pipelineData, Context context) throws Exception
+ {
log.info("Running do perform!");
( (RunData) pipelineData).setMessage("Can't find the requested action!");
}
diff --git a/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml b/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
index 76c31da..5813629 100644
--- a/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
+++ b/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
@@ -69,7 +69,7 @@
</table>
- <table name="TURBINE_ROLE_PERMISSION">
+ <table name="TURBINE_ROLE_PERMISSION" interface="org.apache.fulcrum.security.torque.peer.TurbineRolePermissionPeerMapper">
<column name="ROLE_ID" required="true" primaryKey="true" type="INTEGER"/>
<column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER"/>
@@ -83,9 +83,8 @@
</foreign-key>
</table>
- <!-- org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity -->
<table name="TURBINE_USER" idMethod="native" baseClass="org.apache.fulcrum.security.torque.turbine.DefaultAbstractTurbineUser"
- interface="org.apache.fulcrum.security.model.turbine.entity.TurbineUser">
+ interface="org.apache.fulcrum.security.model.turbine.entity.TurbineUser" peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer">
<column name="USER_ID" required="true" primaryKey="true" type="INTEGER" javaType="object" javaName="EntityId" autoIncrement="true"/>
<column name="LOGIN_NAME" required="true" size="64" type="VARCHAR" javaName="EntityName"/>
<column name="PASSWORD_VALUE" required="true" size="16" type="VARCHAR" javaName="Password"/>
@@ -104,7 +103,7 @@
</table>
- <table name="TURBINE_USER_GROUP_ROLE" interface="org.apache.fulcrum.security.torque.peer.TurbineUserGroupRoleModelPeerMapper">
+ <table name="TURBINE_USER_GROUP_ROLE" interface="org.apache.fulcrum.security.torque.peer.TurbineUserGroupRoleModelPeerMapper" peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbineUserGroupRolePeer">
<column name="USER_ID" required="true" primaryKey="true" type="INTEGER"/>
<column name="GROUP_ID" required="true" primaryKey="true" type="INTEGER"/>
<column name="ROLE_ID" required="true" primaryKey="true" type="INTEGER"/>
diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/TurbineResources.properties b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/TurbineResources.properties
index d266cbd..be72891 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/TurbineResources.properties
+++ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/TurbineResources.properties
@@ -236,10 +236,12 @@
#
# action.sessionvalidator=sessionvalidator.TemplateSecureSessionValidator
-# This is the timeout in seconds for sessions. If left commented out, the
-# servlet container's default timeout will be left as is.
-
-# session.timeout=1800
+#
+# session.timeout is no longer a property that is honored
+# by the Turbine configuration. If you need to adjust your
+# session timeout, please update the web.xml configuration file
+# for setting application wide timeout values
+#
# This is the default action that builds up the AccessControlList for
# the individual users session.