diff --git a/output.log b/output.log new file mode 100644 index 0000000..ae8e9c7 --- /dev/null +++ b/output.log @@ -0,0 +1,189 @@ +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] Training addon - Parent [pom] +[INFO] Training Exercise - Services [jar] +[INFO] Training Exercises - Webapp [war] +[INFO] Training Exercises - Packaging [pom] +[INFO] +[INFO] -----< org.exoplatform.addons.training:training-exercices-parent >------ +[INFO] Building Training addon - Parent 1.0.x-SNAPSHOT [1/4] +[INFO] --------------------------------[ pom ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ training-exercices-parent --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ training-exercices-parent --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ training-exercices-parent --- +[INFO] +[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ training-exercices-parent --- +[INFO] Executing: /bin/sh -c cd /home/exo/addon-project-template && git rev-parse --verify HEAD +[INFO] Working directory: /home/exo/addon-project-template +[INFO] Storing buildNumber: c133e089877717f2f142aa13addf20d1c17a3d60 at timestamp: 20201217 +[INFO] Storing buildScmBranch: template/add-services +[INFO] +[INFO] --- build-helper-maven-plugin:1.9.1:parse-version (parse-version) @ training-exercices-parent --- +[INFO] +[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ training-exercices-parent --- +[INFO] +[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ training-exercices-parent --- +[INFO] Installing /home/exo/addon-project-template/pom.xml to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercices-parent/1.0.x-SNAPSHOT/training-exercices-parent-1.0.x-SNAPSHOT.pom +[INFO] +[INFO] ----< org.exoplatform.addons.training:training-exercises-services >----- +[INFO] Building Training Exercise - Services 1.0.x-SNAPSHOT [2/4] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ training-exercises-services --- +[INFO] Deleting /home/exo/addon-project-template/services/target +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ training-exercises-services --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ training-exercises-services --- +[INFO] +[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ training-exercises-services --- +[INFO] +[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ training-exercises-services --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] Copying 3 resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ training-exercises-services --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 6 source files to /home/exo/addon-project-template/services/target/classes +[WARNING] bootstrap class path not set in conjunction with -source 7 +[WARNING] source value 7 is obsolete and will be removed in a future release +[WARNING] target value 7 is obsolete and will be removed in a future release +[WARNING] To suppress warnings about obsolete options, use -Xlint:-options. +[WARNING] Exo JPA entity detected: org.exoplatform.addons.entity.FavouriteActivity +[WARNING] Supported source version 'RELEASE_5' from annotation processor 'org.chromattic.apt.ChromatticProcessor' less than -source '7' +[INFO] +[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ training-exercises-services --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /home/exo/addon-project-template/services/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ training-exercises-services --- +[INFO] No sources to compile +[INFO] +[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ training-exercises-services --- +[INFO] No tests to run. +[INFO] +[INFO] --- build-helper-maven-plugin:1.9.1:parse-version (parse-version) @ training-exercises-services --- +[INFO] +[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ training-exercises-services --- +[INFO] Building jar: /home/exo/addon-project-template/services/target/training-exercises-services.jar +[INFO] +[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ training-exercises-services --- +[INFO] Building jar: /home/exo/addon-project-template/services/target/training-exercises-services-sources.jar +[INFO] +[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ training-exercises-services --- +[INFO] Installing /home/exo/addon-project-template/services/target/training-exercises-services.jar to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT.jar +[INFO] Installing /home/exo/addon-project-template/services/pom.xml to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT.pom +[INFO] Installing /home/exo/addon-project-template/services/target/training-exercises-services-sources.jar to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT-sources.jar +[INFO] +[INFO] -----< org.exoplatform.addons.training:training-exercises-webapp >------ +[INFO] Building Training Exercises - Webapp 1.0.x-SNAPSHOT [3/4] +[INFO] --------------------------------[ war ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ training-exercises-webapp --- +[INFO] Deleting /home/exo/addon-project-template/war/target +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ training-exercises-webapp --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ training-exercises-webapp --- +[INFO] +[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ training-exercises-webapp --- +[INFO] +[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ training-exercises-webapp --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /home/exo/addon-project-template/war/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ training-exercises-webapp --- +[INFO] No sources to compile +[INFO] +[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ training-exercises-webapp --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /home/exo/addon-project-template/war/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ training-exercises-webapp --- +[INFO] No sources to compile +[INFO] +[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ training-exercises-webapp --- +[INFO] No tests to run. +[INFO] +[INFO] --- build-helper-maven-plugin:1.9.1:parse-version (parse-version) @ training-exercises-webapp --- +[INFO] +[INFO] --- maven-war-plugin:2.5:war (default-war) @ training-exercises-webapp --- +[INFO] Packaging webapp +[INFO] Assembling webapp [training-exercises-webapp] in [/home/exo/addon-project-template/war/target/training-exercises-extension] +[INFO] Processing war project +[INFO] Copying webapp resources [/home/exo/addon-project-template/war/src/main/webapp] +[INFO] Webapp assembled in [35 msecs] +[INFO] Building war: /home/exo/addon-project-template/war/target/training-exercises-extension.war +[INFO] +[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ training-exercises-webapp --- +[INFO] No sources in project. Archive not created. +[INFO] +[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ training-exercises-webapp --- +[INFO] Installing /home/exo/addon-project-template/war/target/training-exercises-extension.war to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-webapp/1.0.x-SNAPSHOT/training-exercises-webapp-1.0.x-SNAPSHOT.war +[INFO] Installing /home/exo/addon-project-template/war/pom.xml to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-webapp/1.0.x-SNAPSHOT/training-exercises-webapp-1.0.x-SNAPSHOT.pom +[INFO] +[INFO] ----< org.exoplatform.addons.training:training-exercices-packaging >---- +[INFO] Building Training Exercises - Packaging 1.0.x-SNAPSHOT [4/4] +[INFO] --------------------------------[ pom ]--------------------------------- +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/exoplatform/social/social-component-core/5.0.1/social-component-core-5.0.1.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/exoplatform/social/social-component-core/5.0.1/social-component-core-5.0.1.pom (18 kB at 28 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/exoplatform/social/social-component-core/5.0.1/social-component-core-5.0.1.jar +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar (450 kB at 1.4 MB/s) +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/exoplatform/social/social-component-core/5.0.1/social-component-core-5.0.1.jar (965 kB at 1.8 MB/s) +[INFO] +[INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ training-exercices-packaging --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ training-exercices-packaging --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ training-exercices-packaging --- +[INFO] +[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ training-exercices-packaging --- +[INFO] +[INFO] --- build-helper-maven-plugin:1.9.1:parse-version (parse-version) @ training-exercices-packaging --- +[INFO] +[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ training-exercices-packaging --- +[INFO] +[INFO] --- maven-assembly-plugin:2.5:single (package-addon) @ training-exercices-packaging --- +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-archiver/2.8.2/plexus-archiver-2.8.2.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-archiver/2.8.2/plexus-archiver-2.8.2.pom (4.1 kB at 50 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-io/2.3.3/plexus-io-2.3.3.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-io/2.3.3/plexus-io-2.3.3.pom (2.8 kB at 35 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-repository-builder/1.0-alpha-2/maven-repository-builder-1.0-alpha-2.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-repository-builder/1.0-alpha-2/maven-repository-builder-1.0-alpha-2.pom (3.2 kB at 40 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-shared-components/7/maven-shared-components-7.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-shared-components/7/maven-shared-components-7.pom (2.6 kB at 19 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-common-artifact-filters/1.0-alpha-1/maven-common-artifact-filters-1.0-alpha-1.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-common-artifact-filters/1.0-alpha-1/maven-common-artifact-filters-1.0-alpha-1.pom (1.8 kB at 24 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-shared-components/6/maven-shared-components-6.pom +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-shared-components/6/maven-shared-components-6.pom (3.1 kB at 40 kB/s) +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-archiver/2.8.2/plexus-archiver-2.8.2.jar +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-io/2.3.3/plexus-io-2.3.3.jar +[INFO] Downloading from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-repository-builder/1.0-alpha-2/maven-repository-builder-1.0-alpha-2.jar +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/apache/maven/shared/maven-repository-builder/1.0-alpha-2/maven-repository-builder-1.0-alpha-2.jar (23 kB at 279 kB/s) +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-archiver/2.8.2/plexus-archiver-2.8.2.jar (143 kB at 1.5 MB/s) +[INFO] Downloaded from exo-mirror: https://repository.exoplatform.org/public/org/codehaus/plexus/plexus-io/2.3.3/plexus-io-2.3.3.jar (79 kB at 279 kB/s) +[INFO] Reading assembly descriptor: src/main/assemblies/packaging.xml +[INFO] Building zip: /home/exo/addon-project-template/packaging/target/training-exercises-packaging.zip +[INFO] +[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ training-exercices-packaging --- +[INFO] Installing /home/exo/addon-project-template/packaging/pom.xml to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercices-packaging/1.0.x-SNAPSHOT/training-exercices-packaging-1.0.x-SNAPSHOT.pom +[INFO] Installing /home/exo/addon-project-template/packaging/target/training-exercises-packaging.zip to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercices-packaging/1.0.x-SNAPSHOT/training-exercices-packaging-1.0.x-SNAPSHOT.zip +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Summary for Training addon - Parent 1.0.x-SNAPSHOT: +[INFO] +[INFO] Training addon - Parent ............................ SUCCESS [ 0.649 s] +[INFO] Training Exercise - Services ....................... SUCCESS [ 2.124 s] +[INFO] Training Exercises - Webapp ........................ SUCCESS [ 0.319 s] +[INFO] Training Exercises - Packaging ..................... SUCCESS [ 5.555 s] +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 9.101 s +[INFO] Finished at: 2020-12-17T11:12:47+01:00 +[INFO] ------------------------------------------------------------------------ diff --git a/services/output.log b/services/output.log new file mode 100644 index 0000000..03f321f --- /dev/null +++ b/services/output.log @@ -0,0 +1,61 @@ +[INFO] Scanning for projects... +[INFO] +[INFO] ----< org.exoplatform.addons.training:training-exercises-services >----- +[INFO] Building Training Exercise - Services 1.0.x-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ training-exercises-services --- +[INFO] Deleting /home/exo/addon-project-template/services/target +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ training-exercises-services --- +[INFO] +[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ training-exercises-services --- +[INFO] +[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ training-exercises-services --- +[INFO] Executing: /bin/sh -c cd /home/exo/addon-project-template/services && git rev-parse --verify HEAD +[INFO] Working directory: /home/exo/addon-project-template/services +[INFO] Storing buildNumber: c133e089877717f2f142aa13addf20d1c17a3d60 at timestamp: 20201217 +[INFO] Storing buildScmBranch: template/add-services +[INFO] +[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ training-exercises-services --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] Copying 3 resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ training-exercises-services --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 6 source files to /home/exo/addon-project-template/services/target/classes +[WARNING] bootstrap class path not set in conjunction with -source 7 +[WARNING] source value 7 is obsolete and will be removed in a future release +[WARNING] target value 7 is obsolete and will be removed in a future release +[WARNING] To suppress warnings about obsolete options, use -Xlint:-options. +[WARNING] Exo JPA entity detected: org.exoplatform.addons.entity.FavouriteActivity +[WARNING] Supported source version 'RELEASE_5' from annotation processor 'org.chromattic.apt.ChromatticProcessor' less than -source '7' +[INFO] +[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ training-exercises-services --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /home/exo/addon-project-template/services/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ training-exercises-services --- +[INFO] No sources to compile +[INFO] +[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ training-exercises-services --- +[INFO] No tests to run. +[INFO] +[INFO] --- build-helper-maven-plugin:1.9.1:parse-version (parse-version) @ training-exercises-services --- +[INFO] +[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ training-exercises-services --- +[INFO] Building jar: /home/exo/addon-project-template/services/target/training-exercises-services.jar +[INFO] +[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ training-exercises-services --- +[INFO] Building jar: /home/exo/addon-project-template/services/target/training-exercises-services-sources.jar +[INFO] +[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ training-exercises-services --- +[INFO] Installing /home/exo/addon-project-template/services/target/training-exercises-services.jar to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT.jar +[INFO] Installing /home/exo/addon-project-template/services/pom.xml to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT.pom +[INFO] Installing /home/exo/addon-project-template/services/target/training-exercises-services-sources.jar to /home/exo/.m2/repository/org/exoplatform/addons/training/training-exercises-services/1.0.x-SNAPSHOT/training-exercises-services-1.0.x-SNAPSHOT-sources.jar +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 3.215 s +[INFO] Finished at: 2020-12-17T11:12:24+01:00 +[INFO] ------------------------------------------------------------------------ diff --git a/services/pom.xml b/services/pom.xml index ac4546e..d85a47c 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -1,49 +1,162 @@ - - - - org.exoplatform.addons.training - training-exercices-parent + + + org.exoplatform.addons.training + training-exercices-parent + 1.0.x-SNAPSHOT + + 4.0.0 + training-exercises-services 1.0.x-SNAPSHOT - - 4.0.0 - training-exercises-services - 1.0.x-SNAPSHOT - - - picocontainer - picocontainer - 1.1 - - - org.exoplatform.kernel - exo.kernel.commons - ${platform.version} - - - org.exoplatform.kernel - exo.kernel.container - ${platform.version} - - - org.exoplatform.commons - commons-api - ${platform.version} - - - org.exoplatform.social - social-component-core-jpa - 5.0.0-RC13 - - - org.exoplatform.social - social-component-core-jpa - 5.0.0-RC13 - - - Training Exercise - Services - - training-exercises-services - + + + + + org.exoplatform.core + exo.core.component.organization.api + 2.6.0-GA + + + javax.jcr + jcr + 2.0 + + + javax.annotation + jsr250-api + 1.0 + + + + + + picocontainer + picocontainer + 1.1 + + + org.exoplatform.kernel + exo.kernel.commons + ${platform.version} + + + org.exoplatform.kernel + exo.kernel.container + ${platform.version} + + + org.exoplatform.commons + commons-api + ${platform.version} + + + org.exoplatform.social + social-component-core + 6.0.0 + + + org.junit.jupiter + junit-jupiter-api + 5.4.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.4.2 + test + + + org.apache.logging.log4j + log4j-api + 2.11.1 + + + org.slf4j + slf4j-jdk14 + 1.7.28 + + + org.exoplatform.ws + exo.ws.rest.core + 2.3.7-GA + provided + + + org.exoplatform.core + exo.core.component.organization.api + 2.6.0-GA + provided + + + javax.annotation + jsr250-api + 1.0 + provided + + + com.metaparadigm + json-rpc + 1.0 + provided + + + org.hibernate + hibernate-entitymanager + 4.3.6.Final + + + org.exoplatform.gatein.portal + exo.portal.component.portal + 6.0.0 + + + org.exoplatform.gatein.portal + exo.portal.component.common + 6.0.0 + + + org.exoplatform.core + exo.core.component.organization.api + 2.6.0-GA + + + javax.jcr + jcr + 2.0 + + + javax.annotation + jsr250-api + 1.0 + + + + + org.quartz-scheduler + quartz + 2.1.7 + provided + + + + org.exoplatform.kernel + exo.kernel.commons + 2.4.13-GA + + + org.quartz-scheduler + quartz + + + + Training Exercise - Services + + training-exercises-services + + + org.apache.maven.plugins + maven-surefire-plugin + + + \ No newline at end of file diff --git a/services/src/main/java/exo/rest/service/RestUserService.java b/services/src/main/java/exo/rest/service/RestUserService.java new file mode 100644 index 0000000..5e0826e --- /dev/null +++ b/services/src/main/java/exo/rest/service/RestUserService.java @@ -0,0 +1,170 @@ +package exo.rest.service; + +import io.swagger.annotations.ApiParam; +import org.exoplatform.addons.DAO.FavoriteActivityDAO; +import org.exoplatform.addons.entity.FavoriteActivityEntity; +import org.exoplatform.commons.utils.ListAccess; +import org.exoplatform.container.ExoContainer; +import org.exoplatform.container.ExoContainerContext; +import org.exoplatform.services.organization.OrganizationService; +import org.exoplatform.services.organization.User; +import org.exoplatform.services.organization.UserHandler; +import org.exoplatform.services.rest.resource.ResourceContainer; +import org.exoplatform.services.security.Identity; +import org.exoplatform.services.security.IdentityRegistry; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import javax.ws.rs.*; +import javax.ws.rs.core.*; +import java.util.Calendar; +import java.util.List; + + +/** + * Rest User Service! + */ +@Path("/demo") +@Produces("application/json") +public class RestUserService implements ResourceContainer { + + private FavoriteActivityDAO dao = new FavoriteActivityDAO(); + + public RestUserService() { + } + + public RestUserService(FavoriteActivityDAO dao) { + this.dao = dao; + } + + + @GET + @Path("/hello/{name}") + //@RolesAllowed({"administrators"}) + public String hello(@PathParam("name") String name) { + return "Hello " + name; + } + + @GET + @Path("/listusers/{offset}") + public Response getListUserName(@Context SecurityContext sc, @PathParam("offset") Integer offset) throws JSONException { + JSONArray list = new JSONArray(); + JSONObject jsonObject = new JSONObject(); + String groupToCheck = "/platform/administrators"; + CacheControl cacheControl = new CacheControl(); + cacheControl.setNoCache(true); + cacheControl.setNoStore(true); + + if (sc.getUserPrincipal() == null || !this.isMemberOf(sc.getUserPrincipal().getName(), groupToCheck)) { + + jsonObject.put("rights", "NOT-ALLOWED"); + list.put(jsonObject); + + } else { + + OrganizationService organizationService = ExoContainerContext.getCurrentContainer() + .getComponentInstanceOfType(OrganizationService.class); + UserHandler userHandler = organizationService.getUserHandler(); + try { + ListAccess allUsers = userHandler.findAllUsers(); + + if (offset == null || offset < 0) + offset = 0; + int limit = 1000; + int total = limit + offset; + int totalUsers = allUsers.getSize(); + + if (offset < totalUsers && total > totalUsers) { + total = totalUsers; + } + User[] users = null; + + for (int i = offset; i < total; i++) { + users = allUsers.load(i, 1); + jsonObject = new JSONObject(); + jsonObject.put("username", users[0].getUserName()); + list.put(jsonObject); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + return Response.ok(list.toString(), MediaType.APPLICATION_JSON).cacheControl(cacheControl).build(); + + } + + @POST + @Path("/create") + @Consumes("application/json") + public Response create(@ApiParam(value = "entity", required = true) FavoriteActivityEntity entity) { + CacheControl cacheControl = new CacheControl(); + cacheControl.setNoCache(true); + cacheControl.setNoStore(true); + try { + entity.setFavouriteDate(Calendar.getInstance()); + dao.addActivity(entity); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return Response.ok("OK", MediaType.APPLICATION_JSON).cacheControl(cacheControl).build(); + + } + + @GET + @Path("/show") + public JSONArray show() throws JSONException { + JSONArray list = new JSONArray(); + JSONObject jsonObject = new JSONObject(); + + String groupToCheck = "/platform/administrators"; + CacheControl cacheControl = new CacheControl(); + cacheControl.setNoCache(true); + cacheControl.setNoStore(true); + + + + List allFavoriteActivities = dao.findAllActivity(); + + + for (int i = 0; i < allFavoriteActivities.size(); i++) { + jsonObject = new JSONObject(); + jsonObject.put("id", allFavoriteActivities.get(i).getId()); + jsonObject.put("activityTitle", allFavoriteActivities.get(i).getActivityTitle()); + jsonObject.put("targetActivity", allFavoriteActivities.get(i).getTargetActivity()); + jsonObject.put("favoriteDate", allFavoriteActivities.get(i).getFavouriteDate()); + list.put(jsonObject); + } + + + + + return list; + } + + @DELETE + @Path("/delete/{id}") + public Response deleteById(@PathParam("id") Long id ){ + dao.deleteActivity(id); + return Response.ok().build(); + } + + @DELETE + @Path("/deleteAll") + public Response deleteAll(){ + dao.deleteAll(); + return Response.ok().build(); + } + + private boolean isMemberOf(String username, String role) { + ExoContainer container = ExoContainerContext.getCurrentContainer(); + IdentityRegistry identityRegistry = container.getComponentInstanceOfType(IdentityRegistry.class); + Identity identity = identityRegistry.getIdentity(username); + return identity.isMemberOf(role); + } + +} \ No newline at end of file diff --git a/services/src/main/java/org/exoplatform/addons/DAO/FavoriteActivityDAO.java b/services/src/main/java/org/exoplatform/addons/DAO/FavoriteActivityDAO.java new file mode 100644 index 0000000..a734aa6 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/DAO/FavoriteActivityDAO.java @@ -0,0 +1,87 @@ +package org.exoplatform.addons.DAO; + +import org.exoplatform.addons.entity.FavoriteActivityEntity; +import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl; + +import javax.persistence.Entity; +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.List; + +public class FavoriteActivityDAO extends GenericDAOJPAImpl { + + public FavoriteActivityDAO() { + } + + public FavoriteActivityEntity findActivity(Long id) + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + Query q = em.createQuery("select f from FavoriteActivityEntity f where f.ID= :idd"); + q.setParameter("idd", id); + FavoriteActivityEntity res = (FavoriteActivityEntity) q.getSingleResult(); + em.getTransaction().commit(); + return res; + } + + public List findAllActivity() + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + Query q = em.createQuery("select f from FavoriteActivityEntity f "); + List list = q.getResultList(); + em.getTransaction().commit(); + return list; + } + + public void addActivity(FavoriteActivityEntity entity) { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + em.persist(entity); + em.getTransaction().commit(); + } + + public void addAllActivity(List entities) + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + em.persist(entities); + em.getTransaction().commit(); + } + + public void updateActivity(FavoriteActivityEntity entity) + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + getEntityManager().merge(entity); + em.getTransaction().commit(); + } + + public void updateAllActivity(List entities) + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + for (FavoriteActivityEntity entity : entities) { + getEntityManager().merge(entity); + } + em.getTransaction().commit(); + + } + + public void deleteActivity(Long id) + { + FavoriteActivityEntity entity = findActivity(id); + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + em.remove(entity); + em.getTransaction().commit(); + } + + public void deleteAllActivity() + { + EntityManager em= getEntityManager() ; + em.getTransaction().begin(); + em.createQuery("delete from FavoriteActivityEntity ").executeUpdate(); + em.getTransaction().commit(); + } +} diff --git a/services/src/main/java/org/exoplatform/addons/entity/FavoriteActivityEntity.java b/services/src/main/java/org/exoplatform/addons/entity/FavoriteActivityEntity.java new file mode 100644 index 0000000..56082a3 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/entity/FavoriteActivityEntity.java @@ -0,0 +1,76 @@ +package org.exoplatform.addons.entity; + + +import javax.persistence.*; + +import org.exoplatform.commons.api.persistence.ExoEntity; +import org.exoplatform.social.core.jpa.storage.entity.ActivityEntity; + +import java.util.Calendar; + +@Entity +@ExoEntity +@Table(name = "ADDON_FAVOURITE_ACTIVITY") +public class FavoriteActivityEntity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "ID") + private Long id; + + @Column(name="ACTIVITY_ID") + private String activityTitle; + + + + @ManyToOne + @JoinColumn(name="FAVOURITE_BY_ID") + private ActivityEntity targetActivity; + + @Temporal(value = TemporalType.TIMESTAMP) + @Column(name = "FAVOURITE_DATE") + private Calendar favouriteDate; + + + public FavoriteActivityEntity() { + } + + public FavoriteActivityEntity(Long id, String activityTitle, ActivityEntity targetActivity, Calendar favouriteDate) { + this.id = id; + this.activityTitle = activityTitle; + this.targetActivity = targetActivity; + this.favouriteDate = favouriteDate; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getActivityTitle() { + return activityTitle; + } + + public void setActivityTitle(String activityTitle) { + this.activityTitle = activityTitle; + } + + public ActivityEntity getTargetActivity() { + return targetActivity; + } + + public void setTargetActivity(ActivityEntity targetActivity) { + this.targetActivity = targetActivity; + } + + public Calendar getFavouriteDate() { + return favouriteDate; + } + + public void setFavouriteDate(Calendar favouriteDate) { + this.favouriteDate = favouriteDate; + } +} diff --git a/services/src/main/java/org/exoplatform/addons/jobs/LoggedInNumberJob.java b/services/src/main/java/org/exoplatform/addons/jobs/LoggedInNumberJob.java new file mode 100644 index 0000000..8e4901a --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/jobs/LoggedInNumberJob.java @@ -0,0 +1,29 @@ +package org.exoplatform.addons.jobs; + +import org.exoplatform.addons.listener.LoggedInUserListener; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +public class LoggedInNumberJob implements Job { + + private static final Log LOG = ExoLogger.getLogger(LoggedInNumberJob.class); + + LoggedInUserListener loggedInNumberJob; + public LoggedInNumberJob() { + + this.loggedInNumberJob = new LoggedInUserListener(); + } + + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + + + LOG.info("The number of logged in users in the last 10 minutes is:"+loggedInNumberJob.countLoggedInUser()); + + + } +} diff --git a/services/src/main/java/org/exoplatform/addons/listener/LoggedInUserListener.java b/services/src/main/java/org/exoplatform/addons/listener/LoggedInUserListener.java new file mode 100644 index 0000000..8fbfda9 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/listener/LoggedInUserListener.java @@ -0,0 +1,91 @@ +package org.exoplatform.addons.listener; + +import org.exoplatform.container.PortalContainer; +import org.exoplatform.container.component.ComponentRequestLifecycle; +import org.exoplatform.container.component.RequestLifeCycle; +import org.exoplatform.services.listener.Event; +import org.exoplatform.services.listener.Listener; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; +import org.exoplatform.services.organization.OrganizationService; +import org.exoplatform.services.organization.User; +import org.exoplatform.services.organization.UserHandler; +import org.exoplatform.services.security.ConversationRegistry; +import org.exoplatform.services.security.ConversationState; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +public class LoggedInUserListener extends Listener{ + + private static final Log LOG = ExoLogger.getLogger(LoggedInUserListener.class); + + public static final String USER_PROFILE = "UserProfile"; + + private PortalContainer container; + + private OrganizationService organizationService; + + public LoggedInUserListener(PortalContainer container) { + this.container = container; + } + public LoggedInUserListener() + { + + } + private static List list = new ArrayList(); + + + public List getList() { + return list; + } + + @Override + public void onEvent(Event event) { + LOG.info("********************************************************User Connected"); + + if (organizationService == null) { + organizationService = this.container.getComponentInstanceOfType(OrganizationService.class); + } + UserHandler userHandler = organizationService.getUserHandler(); + + ConversationState state = event.getData(); + String userId = state.getIdentity().getUserId(); + boolean transactionOpened = false; + if(organizationService instanceof ComponentRequestLifecycle) { + RequestLifeCycle.begin((ComponentRequestLifecycle)organizationService); + transactionOpened = true; + } + try { + User user = (User) state.getAttribute(USER_PROFILE); + + if (user == null) { + user = userHandler.findUserByName(userId); + state.setAttribute(USER_PROFILE, user); + } + + user.setLastLoginTime(Calendar.getInstance().getTime()); + userHandler.saveUser(user, false); + list.add(user); + } catch (Exception e) { + LOG.error("Error while updating the last login time for user {}", userId, e); + } finally { + if(transactionOpened) { + RequestLifeCycle.end(); + } + } + //LOG.info("User Connected/*///////////////////////////////////////////////////////"); + } + + public int countLoggedInUser() + { + LOG.info("*****",list.size()); + return list.size(); + } + + + + +} + diff --git a/services/src/main/java/org/exoplatform/addons/listener/MailSendListener.java b/services/src/main/java/org/exoplatform/addons/listener/MailSendListener.java new file mode 100644 index 0000000..6e22bac --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/listener/MailSendListener.java @@ -0,0 +1,95 @@ +package org.exoplatform.addons.listener; + +import org.exoplatform.commons.utils.MailUtils; +import org.exoplatform.container.ExoContainer; +import org.exoplatform.container.ExoContainerContext; +import org.exoplatform.portal.branding.BrandingService; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; +import org.exoplatform.services.mail.MailService; +import org.exoplatform.services.mail.Message; +import org.exoplatform.services.organization.OrganizationService; +import org.exoplatform.services.organization.User; +import org.exoplatform.services.organization.UserEventListener; +import org.exoplatform.services.organization.UserProfile; +import org.exoplatform.services.organization.impl.NewUserConfig; +import org.exoplatform.services.resources.ResourceBundleService; +import org.exoplatform.web.WebAppController; + +import java.io.InputStream; +import java.util.Locale; +import java.util.ResourceBundle; + +public class MailSendListener extends UserEventListener { + + private static final Log LOG = ExoLogger.getLogger(MailSendListener.class); + + + private final MailService mailService; + private final ResourceBundleService bundleService; + private final BrandingService brandingService; + private NewUserConfig config_; + + public MailSendListener(MailService mailService, ResourceBundleService bundleService, BrandingService brandingService, WebAppController webController) { + super(); + this.mailService = mailService; + this.bundleService = bundleService; + this.brandingService = brandingService; + } + + public boolean SendMail(User user, Locale locale) { + if (user == null) { + throw new IllegalArgumentException("User or Locale must not be null"); + } + + ResourceBundle bundle = bundleService.getResourceBundle(bundleService.getSharedResourceBundleNames(), locale); + String emailBody = ""; + InputStream input = this.getClass().getClassLoader().getResourceAsStream("conf/onBoarding_email_template.html"); + emailBody = emailBody.replaceAll("\\$\\{USER_DISPLAY_NAME\\}", user.getDisplayName()); + emailBody = emailBody.replaceAll("\\$\\{COMPANY_NAME\\}", brandingService.getCompanyName()); + emailBody = emailBody.replaceAll("\\$\\{CHANGING_PASSWORD_LINK\\}", "http://127.0.0.1:8080/portal/forgot-password"); + String emailSubject = bundle.getString("onboarding.email.header") + " " + brandingService.getCompanyName(); + String senderName = MailUtils.getSenderName(); + String from = MailUtils.getSenderEmail(); + if (senderName != null && !senderName.trim().isEmpty()) { + from = senderName + " <" + from + ">"; + } + + Message message = new Message(); + message.setFrom(from); + message.setTo(user.getEmail()); + message.setSubject(emailSubject); + message.setBody(emailBody); + message.setMimeType("text/html"); + + try { + mailService.sendMessage(message); + } catch (Exception ex) { + LOG.error("Failure to send onboarding email", ex); + return false; + } + return true; + + } + + + public void preSave(User user, boolean isNew) throws Exception { + LOG.info("Before user is added into database"); + } + + + public void postSave(User user, boolean isNew) throws Exception { + ExoContainer pcontainer = ExoContainerContext.getCurrentContainer(); + OrganizationService service = (OrganizationService) pcontainer.getComponentInstanceOfType(OrganizationService.class); + UserProfile up = service.getUserProfileHandler().createUserProfileInstance(); + up.setUserName(user.getUserName()); + service.getUserProfileHandler().saveUserProfile(up, false); + + Locale locale = new Locale("en", "US"); + + LOG.info("After user is added into database"); + SendMail(user, locale); + + } + +} \ No newline at end of file diff --git a/services/src/main/java/org/exoplatform/addons/services/MyNewService.java b/services/src/main/java/org/exoplatform/addons/services/MyNewService.java new file mode 100644 index 0000000..a4eba3f --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/services/MyNewService.java @@ -0,0 +1,100 @@ +package org.exoplatform.addons.services; + +import org.exoplatform.services.jcr.RepositoryService; +import org.exoplatform.services.jcr.core.ManageableRepository; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; +import org.exoplatform.container.ExoContainerContext; +import org.exoplatform.container.ExoContainer; + +import javax.jcr.*; +import javax.jcr.query.Query; +import javax.jcr.query.QueryManager; +import java.util.Date; + +/** + * + */ + +/** + * @author exo + * + */ +public class MyNewService { + /** + * The logger. + */ + private static final Log LOG = ExoLogger.getExoLogger(MyService.class); + + + public MyNewService() { + LOG.info("******************************** New Simple service started successfully !!"); + } + + public void call() { + LOG.info("************************* New call function invoked !!"); + } + + public void addFavouriteActivity(String title, String link, Date date, String nodeName) throws RepositoryException { + ExoContainer myContainer = ExoContainerContext.getCurrentContainer(); + RepositoryService repositoryService = (RepositoryService) myContainer.getComponentInstanceOfType(RepositoryService.class); + Repository repository = repositoryService.getCurrentRepository(); + Session jcrSession = ((ManageableRepository) repository).getSystemSession("collaboration"); + Node root = jcrSession.getRootNode(); + + Node newNode = root.addNode(nodeName, "plf:FavoriteActivity"); + Value titleValue = jcrSession.getValueFactory().createValue(title); + Value linkValue = jcrSession.getValueFactory().createValue(link); + Value dateValue = jcrSession.getValueFactory().createValue(date.toString()); + newNode.setProperty("plf:title", titleValue); + newNode.setProperty("plf:link", linkValue); + newNode.setProperty("plf;date", dateValue); + jcrSession.save(); + + } + + public void listFavoriteActivity() throws RepositoryException { + ExoContainer myContainer = ExoContainerContext.getCurrentContainer(); + RepositoryService repositoryService = (RepositoryService) myContainer.getComponentInstanceOfType(RepositoryService.class); + Repository repository = repositoryService.getCurrentRepository(); + Session jcrSession = ((ManageableRepository) repository).getSystemSession("collaboration"); + Node root = jcrSession.getRootNode(); + + QueryManager qm = jcrSession.getWorkspace().getQueryManager(); + Query q = qm.createQuery("select * from plf:FavoriteActivity", Query.SQL); + NodeIterator ni = q.execute().getNodes(); + while (ni.hasNext()) { + Node iterNode = ni.nextNode(); + System.out.println(iterNode.getName() + " title:" + + root.getProperty("plf:title").getValue().getString() + " link:" + + root.getProperty("plf:link").getValue().getString() + " date" + + root.getProperty("plf:date").getValue().getString()); + } + jcrSession.save(); + } + + + public void removeFavoriteActivity(String title) throws RepositoryException { + ExoContainer myContainer = ExoContainerContext.getCurrentContainer(); + RepositoryService repositoryService = (RepositoryService) myContainer.getComponentInstanceOfType(RepositoryService.class); + Repository repository = repositoryService.getCurrentRepository(); + Session jcrSession = ((ManageableRepository) repository).getSystemSession("collaboration"); + Node root = jcrSession.getRootNode(); + + QueryManager qm = jcrSession.getWorkspace().getQueryManager(); + Query q = qm.createQuery("select * from plf:FavoriteActivity", Query.SQL); + NodeIterator ni = q.execute().getNodes(); + while (ni.hasNext()) { + Node iterNode = ni.nextNode(); + if (iterNode.getProperty("plf:title").getValue().getString() == title) { + QueryManager qm1 = jcrSession.getWorkspace().getQueryManager(); + Query q1 = qm1.createQuery("delete from plf:FavoriteActivity where title='${title}'", Query.SQL); + } + + } + jcrSession.save(); + + + } + +} \ No newline at end of file diff --git a/services/src/main/java/org/exoplatform/addons/services/MyNewStartableService.java b/services/src/main/java/org/exoplatform/addons/services/MyNewStartableService.java new file mode 100644 index 0000000..76282d6 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/services/MyNewStartableService.java @@ -0,0 +1,43 @@ +package org.exoplatform.addons.services; + +import org.exoplatform.container.ExoContainerContext; +import org.exoplatform.container.PortalContainer; +import org.picocontainer.Startable; +import org.exoplatform.services.log.*; + + + +/** + * + */ + +/** + * @author exo + * + */ +public class MyNewStartableService implements Startable { + /** + * The logger. + */ + private static final Log LOG = ExoLogger.getExoLogger(MyStartableService.class); + + @Override + public void start() { + LOG.info("*********************** My new Startable service started !"); + PortalContainer portalContainer = (PortalContainer) ExoContainerContext.getCurrentContainer(); + LOG.info("&&&&&&&&&&&& Getting an instance of MyService !"); + MyNewService myNewService = (MyNewService) portalContainer.getComponentInstance(MyNewService.class); + LOG.info("&&&&&&&&&&&& Calling function call of MyService !"); + myNewService.call(); + } + + @Override + public void stop() { + LOG.info("********************* My new Startable service stopped !"); + } + + + +} + + diff --git a/services/src/main/java/org/exoplatform/addons/services/MyService.java b/services/src/main/java/org/exoplatform/addons/services/MyService.java index 16b9d6f..f88bdf0 100644 --- a/services/src/main/java/org/exoplatform/addons/services/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyService.java @@ -21,7 +21,10 @@ public MyService() { LOG.info("##################### Simple service started successfully !!"); } - public void call() { - LOG.info("###################### call function invoked !!"); + + public String call() { + //LOG.info("###################### call function invoked !!"); + return ("ca fonctionne!"); + } } diff --git a/services/src/main/resources/conf/portal/configuration.xml b/services/src/main/resources/conf/portal/configuration.xml index 33ff018..2ffe761 100644 --- a/services/src/main/resources/conf/portal/configuration.xml +++ b/services/src/main/resources/conf/portal/configuration.xml @@ -25,4 +25,72 @@ org.exoplatform.commons.persistence.impl.EntityManagerService - \ No newline at end of file + + + exo.rest.service.RestUserService + + + org.exoplatform.addons.DAO.FavoriteActivityDAO + + + + + org.exoplatform.services.scheduler.impl.QuartzSheduler + + + org.exoplatform.services.scheduler.QueueTasks + + + org.exoplatform.services.scheduler.JobSchedulerService + org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl + + + + + + org.exoplatform.services.organization.OrganizationService + + osend.mail.added.user + addListenerPlugin + org.exoplatform.addons.listener.MailSendListener + send mail after adding user + + + + + org.exoplatform.services.listener.ListenerService + + exo.core.security.ConversationRegistry.register + addListener + org.exoplatform.addons.listener.LoggedInUserListener + count the number of logged in user + + + + + + + org.exoplatform.services.scheduler.JobSchedulerService + + LoggedInNumberJob + addPeriodJob + org.exoplatform.services.scheduler.PeriodJob + Create a Job that Gives the number of logged-in users every 10 minutes + + + job.info + save the Forums Weekly Statistic data periodically + + + + + + + + + + + + + + diff --git a/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml b/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml index 5407070..77df67b 100644 --- a/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml +++ b/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml @@ -34,6 +34,7 @@ + 7:f620ffd34591e64cf5eabffed96fab56 @@ -42,9 +43,9 @@ - + - + diff --git a/services/src/test/java/org/exoplatform/addons/DAO/FavoriteActivityDAOTest.java b/services/src/test/java/org/exoplatform/addons/DAO/FavoriteActivityDAOTest.java new file mode 100644 index 0000000..a7d4917 --- /dev/null +++ b/services/src/test/java/org/exoplatform/addons/DAO/FavoriteActivityDAOTest.java @@ -0,0 +1,66 @@ +package org.exoplatform.addons.DAO; + +import org.exoplatform.addons.entity.FavoriteActivityEntity; +import org.exoplatform.social.core.jpa.storage.entity.ActivityEntity; +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import java.util.Calendar; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +class FavoriteActivityDAOTest { + + + private FavoriteActivityDAO activityDAO; + + @Test + void testFindActivity() { + /* FavoriteActivityEntity favAct = new FavoriteActivityEntity(9L,"title", new ActivityEntity(), Calendar.getInstance()); + activityDAO.addActivity(favAct); + List favActs = activityDAO.findAllActivity(); + Assert.assertEquals(favAct.getId(), activityDAO.findActivity(favActs.get(0).getId()));*/ + } + + @Test + void testFindAllActivity() { + + } + + @Test + void testAddActivity() { + + /* FavoriteActivityEntity favAct = new FavoriteActivityEntity(9L,"title", new ActivityEntity(), Calendar.getInstance()); + activityDAO.addActivity(favAct); + List favActs = activityDAO.findAllActivity(); + Assert.assertEquals(favAct.getId(), favActs.get(0).getId());*/ + + } + + @Test + void testAddAllActivity() { + } + + @Test + void testUpdateActivity() { + /* FavoriteActivityEntity favAct = new FavoriteActivityEntity(9L,"title", new ActivityEntity(), Calendar.getInstance()); + FavoriteActivityEntity newFavAct = new FavoriteActivityEntity(5L,"title", new ActivityEntity(), Calendar.getInstance()); + activityDAO.addActivity(favAct); + + Assert.assertEquals(favAct,activityDAO.updateActivity(newFavAct));*/ + + } + + @Test + void testUpdateAllActivity() { + } + + @Test + void testDeleteActivity() { + } + + @Test + void testDeleteAllActivity() { + } +} \ No newline at end of file diff --git a/services/src/test/java/org/exoplatform/addons/services/MyServiceTest.java b/services/src/test/java/org/exoplatform/addons/services/MyServiceTest.java new file mode 100644 index 0000000..51e62da --- /dev/null +++ b/services/src/test/java/org/exoplatform/addons/services/MyServiceTest.java @@ -0,0 +1,58 @@ +/** + * + */ +package org.exoplatform.addons.services; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * @author exo + * + */ +class MyServiceTest { + + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @AfterAll + static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @AfterEach + void tearDown() throws Exception { + } + + /** + * Test method for {@link org.exoplatform.addons.services.MyService#call()}. + */ + @Test + void testCall() { + MyService myService = new MyService(); + + assertEquals("ca fonctionne!", myService.call()); + } + +} diff --git a/war/src/main/webapp/WEB-INF/conf/common/locales-config.xml b/war/src/main/webapp/WEB-INF/conf/common/locales-config.xml new file mode 100644 index 0000000..44a8776 --- /dev/null +++ b/war/src/main/webapp/WEB-INF/conf/common/locales-config.xml @@ -0,0 +1,177 @@ + + + + + en + UTF-8 + UTF-8 + Default configuration for english locale + + + fr + UTF-8 + UTF-8 + Default configuration for the french locale + + + es_ES + UTF-8 + UTF-8 + Default configuration for the spanish locale + + + cs + UTF-8 + UTF-8 + Default configuration for the Czech locale + + + ja + UTF-8 + UTF-8 + Default configuration for the japanese locale + + + ar + UTF-8 + UTF-8 + Default configuration for the arabic locale + + + + ar_TN + UTF-8 + UTF-8 + Default configuration for the arabic Tunisia locale + + + + ar_OM + UTF-8 + UTF-8 + Default configuration for the arabic Oman locale + + + de + UTF-8 + UTF-8 + Default configuration for the german locale + + + pt_BR + UTF-8 + UTF-8 + Default configuration for the brazilian locale + + + pt_PT + UTF-8 + UTF-8 + Default configuration for the portuguese locale + + + it + UTF-8 + UTF-8 + Default configuration for the italian locale + + + ru + UTF-8 + UTF-8 + Default configuration for the russian locale + + + tr + UTF-8 + UTF-8 + Default configuration for the turkish locale + + + zh_CN + UTF-8 + UTF-8 + Default configuration for the chinese simplified locale + + + uk + UTF-8 + UTF-8 + Default configuration for the Ukrainian locale + + + pl + UTF-8 + UTF-8 + Default configuration for the Polish locale + + + fa + UTF-8 + UTF-8 + Default configuration for the Persian locale + + + ca + UTF-8 + UTF-8 + Default configuration for the Catalan locale + + + nl + UTF-8 + UTF-8 + Default configuration for the Dutch locale + + + sl + UTF-8 + UTF-8 + Default configuration for the Slovenian locale + + + in + UTF-8 + UTF-8 + Default configuration for the Indonesian locale + + + fil + UTF-8 + UTF-8 + Default configuration for the Filipino locale + + + + + vi + UTF-8 + UTF-8 + Default configuration for the Vietnamian locale + + \ No newline at end of file diff --git a/war/src/main/webapp/WEB-INF/conf/configuration.xml b/war/src/main/webapp/WEB-INF/conf/configuration.xml deleted file mode 100644 index 00b465e..0000000 --- a/war/src/main/webapp/WEB-INF/conf/configuration.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - org.exoplatform.addons.services.MyStartableService - org.exoplatform.addons.services.MyStartableService - - - org.exoplatform.addons.services.MyService - org.exoplatform.addons.services.MyService - - diff --git a/war/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml b/war/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml new file mode 100644 index 0000000..3ab972b --- /dev/null +++ b/war/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml @@ -0,0 +1,421 @@ + + + + + + + org.exoplatform.services.organization.cache.OrganizationCacheHandler + + + + org.exoplatform.services.organization.idm.PicketLinkIDMCacheService + org.exoplatform.services.organization.idm.PicketLinkIDMCacheService + + + org.gatein.common.transaction.JTAUserTransactionLifecycleService + org.gatein.common.transaction.JTAUserTransactionLifecycleServiceImpl + + + org.exoplatform.services.database.HibernateService + database:type=HibernateService + org.exoplatform.services.organization.idm.CustomHibernateServiceImpl + + + hibernate.properties + Default Hibernate Service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.exoplatform.services.organization.idm.PicketLinkIDMService + org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl + + + config + war:/conf/organization/picketlink-idm/picketlink-idm-config.xml + + + + + + + + + + + + + + + + + + + + + + + portalRealm + idm_realm${container.name.suffix} + + + + skipExpirationOfStructureCacheEntries + true + + + + useSecureRandomService + true + + + + + + + org.exoplatform.services.organization.OrganizationService + org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl + + + configuration + + + + true + + + + true + + + + . + + + + GTN_ROOT_GROUP + + + + + + + / + + + root_type + + + + + + + + + + + + + + + + + member + + + + + + + + + + false + + + + + @_@_@ + + + + + true + + + + + true + + + + + true + + + + + ${exo.disable.user.activated:true} + + + + + ${exo.idm.user.updateLastLoginTime:true} + + + + + + + + + + org.exoplatform.services.database.HibernateService + + add.hibernate.mapping + addPlugin + org.exoplatform.services.database.impl.AddHibernateMappingPlugin + + + hibernate.mapping + picketlink-idm/mappings/HibernateRealm.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml + picketlink-idm/mappings/HibernateIdentityObject.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectCredential.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectCredentialType.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectAttribute.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectType.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectRelationship.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectRelationshipType.hbm.xml + picketlink-idm/mappings/HibernateIdentityObjectRelationshipName.hbm.xml + + + hibernate.mapping + picketlink-idm/sybase-mappings/HibernateRealm.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObject.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectCredential.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectCredentialType.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectAttribute.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectType.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectRelationship.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectRelationshipType.hbm.xml + picketlink-idm/sybase-mappings/HibernateIdentityObjectRelationshipName.hbm.xml + + + + + + + org.exoplatform.services.listener.ListenerService + + exo.core.security.ConversationRegistry.register + addListener + org.exoplatform.services.organization.idm.UpdateLoginTimeListener + update last login time for user + + + + + + + + + + + + + org.exoplatform.services.cache.CacheService + + addExoCacheConfig + addExoCacheConfig + org.exoplatform.services.cache.ExoCacheConfigPlugin + add Exo Cache Config + + + portal.User + Exo Cache cluster configuration for IDM User entity + + portal.User + ${exo.cache.portal.user.strategy:LIRS} + ${exo.cache.portal.user.MaxNodes:5000} + ${exo.cache.portal.user.TimeToLive:3600} + ${exo.cache.portal.user.cacheMode:replication} + + + + + portal.Profile + Exo Cache cluster configuration for IDM User Profile entity + + portal.Profile + ${exo.cache.portal.profile.strategy:LIRS} + ${exo.cache.portal.profile.MaxNodes:5000} + ${exo.cache.portal.profile.TimeToLive:3600} + ${exo.cache.portal.profile.cacheMode:replication} + + + + + portal.Membership + Exo Cache cluster configuration for IDM Membership entity + + portal.Membership + ${exo.cache.portal.membership:LIRS} + ${exo.cache.portal.membership.MaxNodes:5000} + ${exo.cache.portal.membership.TimeToLive:86400} + ${exo.cache.portal.membership.cacheMode:replication} + + + + + portal.Role + Exo Cache cluster configuration for IDM Membership Type entity + + portal.Role + ${exo.cache.portal.role.strategy:LIRS} + ${exo.cache.portal.role.MaxNodes:5000} + ${exo.cache.portal.role.TimeToLive:3600} + ${exo.cache.portal.role.cacheMode:replication} + + + + + portal.Group + Exo Cache cluster configuration for IDM Group entity + + portal.Group + ${exo.cache.portal.group.strategy:LIRS} + ${exo.cache.portal.group.MaxNodes:100} + ${exo.cache.portal.group.TimeToLive:-1} + ${exo.cache.portal.group.cacheMode:replication} + + + + + + + diff --git a/war/src/main/webapp/groovy/social/webui/activity/commons/UIActivityActionBar.gtmpl b/war/src/main/webapp/groovy/social/webui/activity/commons/UIActivityActionBar.gtmpl new file mode 100644 index 0000000..8769fc9 --- /dev/null +++ b/war/src/main/webapp/groovy/social/webui/activity/commons/UIActivityActionBar.gtmpl @@ -0,0 +1,38 @@ +<% + def activity = uicomponent.getActivity(); + def likeActivityAction = uicomponent.event("LikeActivity", "true"); + def unlikeActivityAction = uicomponent.event("LikeActivity", "false"); + def labelLike = _ctx.appRes("UIActivity.label.Like"); + def labelComment = _ctx.appRes("UIActivity.label.Comment"); + def totalLikesNum = uicomponent.getIdentityLikes().length; + int allCommentSize = uicomponent.getAllCommentSize(); +%> +
+ <% def toggleDisplayCommentAction = uicomponent.event('ToggleDisplayCommentForm', null, false); + def commentLink = ""; + %> + +
\ No newline at end of file diff --git a/war/src/main/webapp/login/jsp/login.jsp b/war/src/main/webapp/login/jsp/login.jsp new file mode 100644 index 0000000..3f4a4db --- /dev/null +++ b/war/src/main/webapp/login/jsp/login.jsp @@ -0,0 +1,187 @@ +<%-- + + Copyright (C) 2009 eXo Platform SAS. + + This is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This software is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this software; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA, or see the FSF site: http://www.fsf.org. + +--%> + +<%@ page import="java.net.URLEncoder"%> +<%@ page import="javax.servlet.http.Cookie"%> +<%@ page import="org.exoplatform.web.login.LoginError"%> +<%@ page import="org.exoplatform.container.PortalContainer"%> +<%@ page import="org.exoplatform.services.resources.ResourceBundleService"%> +<%@ page import="org.gatein.security.oauth.spi.OAuthProviderType"%> +<%@ page import="org.gatein.security.oauth.spi.OAuthProviderTypeRegistry"%> +<%@ page import="java.util.ResourceBundle"%> +<%@ page import="org.gatein.common.text.EntityEncoder"%> +<%@ page language="java"%> +<% + String contextPath = request.getContextPath() ; + + String username = request.getParameter("username"); + if(username == null) { + username = ""; + } else { + EntityEncoder encoder = EntityEncoder.FULL; + username = encoder.encode(username); + } + + PortalContainer portalContainer = PortalContainer.getCurrentInstance(session.getServletContext()); + ResourceBundleService service = (ResourceBundleService) portalContainer.getComponentInstanceOfType(ResourceBundleService.class); + ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(), request.getLocale()) ; + + OAuthProviderTypeRegistry registry = (OAuthProviderTypeRegistry) portalContainer.getComponentInstanceOfType(OAuthProviderTypeRegistry.class); + + Cookie cookie = new Cookie(org.exoplatform.web.login.LoginServlet.COOKIE_NAME, ""); + cookie.setPath(request.getContextPath()); + cookie.setMaxAge(0); + response.addCookie(cookie); + + String uri = (String)request.getAttribute("org.gatein.portal.login.initial_uri"); + boolean error = request.getAttribute("org.gatein.portal.login.error") != null; + String errorParam = (String)request.getParameter(org.exoplatform.web.login.LoginError.ERROR_PARAM); + LoginError errorData = null; + if (errorParam != null) { + errorData = LoginError.parse(errorParam); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html; charset=UTF-8"); +%> + + + + + <%=res.getString("UILoginForm.label.Signin")%> + + + + + + + + + + + +
+

LOGIN PAGE MODIFIED !

+
+ + +
+ <% + if (errorData != null) { + if (org.exoplatform.web.login.LoginError.DISABLED_USER_ERROR == errorData.getCode()) { + %> + <%=errorData.getData()%> <%=res.getString("UILoginForm.label.DisabledUserSignin")%> + <% + } + } else if (error) {%> + <%=res.getString("UILoginForm.label.SigninFail")%> + <% } %> +
+
+
+
+
Sign In
+
+
+
+
+
+
+
+ +
" method="post"> + + +
+ + + + + + + + + + + + + +
+
+
+
+
+ "/> + <% if (uri != null) { + uri = EntityEncoder.FULL.encode(uri); + %> + + <% } %> +
+
+
+
+ <% + if (registry.isOAuthEnabled()) { + %> + +
+ <%= res.getString("UILoginForm.label.Delimiter")%> +
+
+ <% for (OAuthProviderType oauthProvType : registry.getEnabledOAuthProviders()) { %> + + <% } %> +
+ <% } %> +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file