[gatein-commits] gatein SVN: r8546 - in epp/portal/branches/EPP_5_2_Branch: component and 13 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Mar 8 08:32:20 EST 2012
Author: mposolda
Date: 2012-03-08 08:32:18 -0500 (Thu, 08 Mar 2012)
New Revision: 8546
Added:
epp/portal/branches/EPP_5_2_Branch/component/initializer/
epp/portal/branches/EPP_5_2_Branch/component/initializer/pom.xml
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/JMXOrganizationInitializer.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewGroupListener.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewMembershipListener.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewProfileListener.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewUserListener.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerJob.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerUtils.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationListenersInitializerService.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/RestOrganizationInitializer.java
epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/TriggerInitializerFilter.java
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/organization/initializer-configuration.xml
Modified:
epp/portal/branches/EPP_5_2_Branch/component/pom.xml
epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/gatein.ear/pom.xml
epp/portal/branches/EPP_5_2_Branch/pom.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
Log:
Bug 793639 - (JBEPP-718) Create additional portal objects for external groups. Added new module exo.portal.component.initializer for listener related stuff
Property changes on: epp/portal/branches/EPP_5_2_Branch/component/initializer
___________________________________________________________________
Added: svn:ignore
+ *.iml
.idea
target
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/pom.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/pom.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>exo.portal.component</artifactId>
+ <groupId>org.exoplatform.portal</groupId>
+ <version>5.2.1.ER02-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.initializer</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Organization Initialization Service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.ext</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.api</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/JMXOrganizationInitializer.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/JMXOrganizationInitializer.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/JMXOrganizationInitializer.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupHandler;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserHandler;
+import org.picocontainer.Startable;
+
+/**
+ * JMX Endpoint for accessing OrganizationListenersInitializerService stuff.
+ *
+ * @author <a href="mailto:mposolda at redhat.com">Marek Posolda</a>
+ */
+ at Managed
+ at ManagedDescription("Organization Listeners Initializer Service Endpoint")
+ at NameTemplate({
+ @Property(key = "name", value = "OrganizationInitializerService"),
+ @Property(key = "service", value = "OrganizationInitializerService")
+})
+public class JMXOrganizationInitializer implements Startable
+{
+
+ private OrganizationListenersInitializerService initializerService;
+ private Log log = ExoLogger.getLogger(this.getClass());
+ private OrganizationService orgService_;
+
+ // TODO: We need this as workaround to handle bug https://issues.jboss.org/browse/EXOJCR-1791 as during client calls,
+ // we need to add this container to context. It should be removed when EXOJCR-1791 will be fixed.
+ private ExoContainer exoContainer;
+
+
+ public JMXOrganizationInitializer(ExoContainerContext exoContainerContext,
+ OrganizationListenersInitializerService organizationListenersInitializerService, OrganizationService orgService)
+ {
+ this.exoContainer = exoContainerContext.getContainer();
+ this.initializerService = organizationListenersInitializerService;
+ this.orgService_=orgService;
+ }
+
+ @Managed
+ @ManagedDescription("Launch all listeners for all users and groups")
+ @Impact(ImpactType.WRITE)
+ public String launchAllListeners(@ManagedDescription("Check JCR Folders") @ManagedName("checkFolders") Boolean checkFolders)
+ {
+ // TODO: We need to encapsulate call within correct portal container by ourselves because JMX kernel layer is not doing it (Workaround for EXOJCR-1791)
+ ExoContainer oldContainer = ExoContainerContext.getCurrentContainer();
+
+ try
+ {
+ ExoContainerContext.setCurrentContainer(this.exoContainer);
+ boolean ok = initializerService.launchAll(checkFolders);
+ String responseString = ok ? "All listeners executed successfuly." : "Error occured during execution of listeners.";
+ return responseString;
+ }
+ finally
+ {
+ ExoContainerContext.setCurrentContainer(oldContainer);
+ }
+ }
+
+ /**
+ *
+ * @param userName username
+ * @param checkFolders whether to check folders in OrganizationInitializerUtils or not. If folders are not checked, we simply trigger all listeners for user, userProfile and all his memberships.
+ * @return rest response
+ */
+ @Managed
+ @ManagedDescription("Launch user listeners for single user")
+ @Impact(ImpactType.WRITE)
+ public String launchUserListeners(@ManagedDescription("userName") @ManagedName("userName") String userName,
+ @ManagedDescription("Check JCR Folders") @ManagedName("checkFolders") Boolean checkFolders)
+ {
+ UserHandler userHandler = orgService_.getUserHandler();
+ User user;
+ ExoContainer oldContainer = ExoContainerContext.getCurrentContainer();
+
+ try
+ {
+ ExoContainerContext.setCurrentContainer(this.exoContainer);
+ user = userHandler.findUserByName(userName);
+ boolean ok = initializerService.treatUser(user, checkFolders);
+ String responseString = ok ? "User listeners executed successfuly." : "Error occured during execution of user listeners.";
+ return responseString;
+ }
+ catch (Exception e)
+ {
+ log.warn("Error with user "+userName, e);
+ return "Error occured during execution of user listeners: " + e.getMessage();
+ }
+ finally
+ {
+ ExoContainerContext.setCurrentContainer(oldContainer);
+ }
+ }
+
+ @Managed
+ @ManagedDescription("Launch group listeners for single group")
+ @Impact(ImpactType.WRITE)
+ public String launchGroupListeners(@ManagedDescription("Group Name") @ManagedName("groupName") String groupName,
+ @ManagedDescription("Check JCR Folders") @ManagedName("checkFolders") Boolean checkFolders)
+ {
+ GroupHandler groupHandler = orgService_.getGroupHandler();
+ Group group;
+ ExoContainer oldContainer = ExoContainerContext.getCurrentContainer();
+
+ try
+ {
+ ExoContainerContext.setCurrentContainer(this.exoContainer);
+ group = groupHandler.findGroupById(groupName);
+ boolean ok = initializerService.treatGroup(group, checkFolders);
+ String responseString = ok ? "Group listeners executed successfuly." : "Error occured during execution of group listeners.";
+ return responseString;
+ }
+ catch (Exception e)
+ {
+ log.warn("Error with group " + groupName, e);
+ return "Error occured during execution of group listeners: " + e.getMessage();
+ }
+ finally
+ {
+ ExoContainerContext.setCurrentContainer(oldContainer);
+ }
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+}
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewGroupListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewGroupListener.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewGroupListener.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupEventListener;
+
+public class NewGroupListener extends GroupEventListener {
+
+ private RepositoryService repositoryService;
+
+ public NewGroupListener(RepositoryService repositoryService) throws Exception {
+ this.repositoryService = repositoryService;
+ }
+
+ @Override
+ public void postSave(Group group, boolean isNew) throws Exception {
+ if (!OrganizationInitializerUtils.hasGroupFolder(repositoryService, group)) {
+ OrganizationInitializerUtils.createGroupFolder(repositoryService, group);
+ }
+ }
+
+ @Override
+ public void postDelete(Group group) throws Exception {
+ if (OrganizationInitializerUtils.hasGroupFolder(repositoryService, group)) {
+ OrganizationInitializerUtils.deleteGroupFolder(repositoryService, group);
+ }
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewMembershipListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewMembershipListener.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewMembershipListener.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.organization.Membership;
+import org.exoplatform.services.organization.MembershipEventListener;
+
+public class NewMembershipListener extends MembershipEventListener {
+
+ private RepositoryService repositoryService;
+
+ public NewMembershipListener(RepositoryService repositoryService) throws Exception {
+ this.repositoryService = repositoryService;
+ }
+
+ @Override
+ public void postSave(Membership m, boolean isNew) throws Exception {
+ if (!OrganizationInitializerUtils.hasMembershipFolder(repositoryService, m)) {
+ OrganizationInitializerUtils.createMembershipFolder(repositoryService, m);
+ }
+ }
+
+ @Override
+ public void postDelete(Membership m) throws Exception {
+ if (OrganizationInitializerUtils.hasMembershipFolder(repositoryService, m)) {
+ OrganizationInitializerUtils.deleteMembershipFolder(repositoryService, m);
+ }
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewProfileListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewProfileListener.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewProfileListener.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.organization.UserProfile;
+import org.exoplatform.services.organization.UserProfileEventListener;
+
+public class NewProfileListener extends UserProfileEventListener {
+
+ private RepositoryService repositoryService;
+
+ public NewProfileListener(RepositoryService repositoryService) throws Exception {
+ this.repositoryService = repositoryService;
+ }
+
+ @Override
+ public void postSave(UserProfile user, boolean isNew) throws Exception {
+ if (!OrganizationInitializerUtils.hasProfileFolder(repositoryService, user)) {
+ OrganizationInitializerUtils.createProfileFolder(repositoryService, user);
+ }
+ }
+
+ @Override
+ public void postDelete(UserProfile user) throws Exception {
+ if (OrganizationInitializerUtils.hasProfileFolder(repositoryService, user)) {
+ OrganizationInitializerUtils.deleteProfileFolder(repositoryService, user);
+ }
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewUserListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewUserListener.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/NewUserListener.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserEventListener;
+
+public class NewUserListener extends UserEventListener {
+
+ private RepositoryService repositoryService;
+
+ public NewUserListener(RepositoryService repositoryService) throws Exception {
+ this.repositoryService = repositoryService;
+ }
+
+ @Override
+ public void postSave(User user, boolean isNew) throws Exception {
+ if (!OrganizationInitializerUtils.hasUserFolder(repositoryService, user)) {
+ OrganizationInitializerUtils.createUserFolder(repositoryService, user);
+ }
+ }
+
+ @Override
+ public void postDelete(User user) throws Exception {
+ if (OrganizationInitializerUtils.hasUserFolder(repositoryService, user)) {
+ OrganizationInitializerUtils.deleteUserFolder(repositoryService, user);
+ }
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerJob.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerJob.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerJob.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.scheduler.BaseJob;
+import org.exoplatform.services.scheduler.JobContext;
+
+public class OrganizationInitializerJob extends BaseJob {
+
+ private static final Log LOG = ExoLogger.getLogger("job.OrganizationInitializerJob");
+
+ private OrganizationListenersInitializerService organizationListenersInitializerService_;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute(JobContext context) throws Exception {
+ LOG.info("File plan job started");
+ if (organizationListenersInitializerService_ == null) {
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ organizationListenersInitializerService_ = (OrganizationListenersInitializerService) container.getComponentInstanceOfType(OrganizationListenersInitializerService.class);
+ }
+
+ RequestLifeCycle.begin(PortalContainer.getInstance());
+
+ try
+ {
+ // TODO: Make checkFolders configurable through startup parameters? Or try existence of JCR workspace?
+ boolean checkFolders = true;
+
+ organizationListenersInitializerService_.launchAll(checkFolders);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+
+ LOG.info("Organization Listeners Initializer job done");
+ }
+}
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerUtils.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerUtils.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationInitializerUtils.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+
+package org.exoplatform.core.component.organization.initializer;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.Membership;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserProfile;
+
+public class OrganizationInitializerUtils {
+
+ final public static String ORGANIZATION_INITIALIZATIONS = "organizationInitializers".intern();
+ final public static String USERS_FOLDER = "users".intern();
+ final public static String GROUPS_FOLDER = "groups".intern();
+ final public static String MEMBERSHIPS_FOLDER = "memberships".intern();
+ final public static String PROFILES_FOLDER = "profiles".intern();
+
+ public static String REPOSITORY = "repository".intern();
+ public static String WORKSPACE = "collaboration".intern();
+ public static String HOME_PATH = "/".intern();
+
+ public static void init(Session session) throws Exception {
+ Node homePathNode = null;
+ try {
+ homePathNode = (Node) session.getItem(HOME_PATH);
+ } catch (Exception e) {}
+ if (homePathNode == null) {
+ homePathNode = createFolder(session.getRootNode(), HOME_PATH);
+ }
+ Node organizationInitializersHomePathNode = null;
+ if (!homePathNode.hasNode(ORGANIZATION_INITIALIZATIONS)) {
+ organizationInitializersHomePathNode = createFolder(homePathNode, ORGANIZATION_INITIALIZATIONS);
+ } else {
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ }
+ if (!organizationInitializersHomePathNode.hasNode(USERS_FOLDER)) {
+ createFolder(organizationInitializersHomePathNode, USERS_FOLDER);
+ }
+ if (!organizationInitializersHomePathNode.hasNode(GROUPS_FOLDER)) {
+ createFolder(organizationInitializersHomePathNode, GROUPS_FOLDER);
+ }
+ if (!organizationInitializersHomePathNode.hasNode(MEMBERSHIPS_FOLDER)) {
+ createFolder(organizationInitializersHomePathNode, MEMBERSHIPS_FOLDER);
+ }
+ if (!organizationInitializersHomePathNode.hasNode(PROFILES_FOLDER)) {
+ createFolder(organizationInitializersHomePathNode, PROFILES_FOLDER);
+ }
+ session.save();
+ }
+
+ private static Node getUsersFolder(Session session) throws Exception {
+ Node organizationInitializersHomePathNode = null;
+ try {
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ } catch (Exception e) {
+ init(session);
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ }
+ return organizationInitializersHomePathNode.getNode(USERS_FOLDER);
+ }
+
+ private static Node getGroupsFolder(Session session) throws Exception {
+ Node organizationInitializersHomePathNode = null;
+ try {
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ } catch (Exception e) {
+ init(session);
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ }
+ return organizationInitializersHomePathNode.getNode(GROUPS_FOLDER);
+ }
+
+ private static Node getMembershipsFolder(Session session) throws Exception {
+ Node organizationInitializersHomePathNode = null;
+ try {
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ } catch (Exception e) {
+ init(session);
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ }
+ return organizationInitializersHomePathNode.getNode(MEMBERSHIPS_FOLDER);
+ }
+
+ private static Node getProfilesFolder(Session session) throws Exception {
+ Node organizationInitializersHomePathNode = null;
+ try {
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ } catch (Exception e) {
+ init(session);
+ Node homePathNode = (Node) session.getItem(HOME_PATH);
+ organizationInitializersHomePathNode = homePathNode.getNode(ORGANIZATION_INITIALIZATIONS);
+ }
+ return organizationInitializersHomePathNode.getNode(PROFILES_FOLDER);
+ }
+
+ public static boolean hasUserFolder(RepositoryService repositoryService, User user) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ return getUsersFolder(session).hasNode(user.getUserName());
+ }
+
+ public static boolean hasProfileFolder(RepositoryService repositoryService, UserProfile userProfile) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ return getProfilesFolder(session).hasNode(userProfile.getUserName());
+ }
+
+ public static boolean hasMembershipFolder(RepositoryService repositoryService, Membership membership) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ return getMembershipsFolder(session).hasNode(membership.getGroupId().replace("/", "") + membership.getMembershipType().toString().replace("*", "_") + membership.getUserName());
+ }
+
+ public static boolean hasGroupFolder(RepositoryService repositoryService, Group group) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ return getGroupsFolder(session).hasNode(group.getId().replace("/", "").trim());
+ }
+
+ public static void createUserFolder(RepositoryService repositoryService, User user) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ createFolder(getUsersFolder(session), user.getUserName());
+ session.save();
+ }
+
+ public static void createProfileFolder(RepositoryService repositoryService, UserProfile userProfile) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ createFolder(getProfilesFolder(session), userProfile.getUserName());
+ session.save();
+ }
+
+ public static void createMembershipFolder(RepositoryService repositoryService, Membership membership) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ createFolder(getMembershipsFolder(session), membership.getGroupId().replace("/", "") + membership.getMembershipType().toString().replace("*", "_") + membership.getUserName());
+ session.save();
+ }
+
+ public static void createGroupFolder(RepositoryService repositoryService, Group group) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ createFolder(getGroupsFolder(session), group.getId().replace("/", "").trim());
+ session.save();
+ }
+
+ public static void deleteUserFolder(RepositoryService repositoryService, User user) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ getUsersFolder(session).getNode(user.getUserName()).remove();
+ session.save();
+ }
+
+ public static void deleteProfileFolder(RepositoryService repositoryService, UserProfile userProfile) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ getProfilesFolder(session).getNode(userProfile.getUserName()).remove();
+ session.save();
+ }
+
+ public static void deleteMembershipFolder(RepositoryService repositoryService, Membership membership) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ getMembershipsFolder(session).getNode(membership.getGroupId().replace("/", "") + membership.getMembershipType().toString().replace("*", "_") + membership.getUserName()).remove();
+ session.save();
+ }
+
+ public static void deleteGroupFolder(RepositoryService repositoryService, Group group) throws Exception {
+ Session session = repositoryService.getRepository(REPOSITORY).getSystemSession(WORKSPACE);
+ getGroupsFolder(session).getNode(group.getId().replace("/", "")).remove();
+ session.save();
+ }
+
+ private static Node createFolder(Node parentNode, String name) throws Exception {
+ parentNode.addNode(name, "nt:folder");
+ parentNode.getSession().save();
+ return parentNode.getNode(name);
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationListenersInitializerService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationListenersInitializerService.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/OrganizationListenersInitializerService.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,431 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+
+package org.exoplatform.core.component.organization.initializer;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Session;
+
+import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.component.ComponentPlugin;
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.Component;
+import org.exoplatform.container.xml.ExternalComponentPlugins;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupEventListener;
+import org.exoplatform.services.organization.Membership;
+import org.exoplatform.services.organization.MembershipEventListener;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.Query;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserEventListener;
+import org.exoplatform.services.organization.UserProfile;
+import org.exoplatform.services.organization.UserProfileEventListener;
+import org.picocontainer.Startable;
+
+public class OrganizationListenersInitializerService implements Startable {
+
+ private Map<String, UserEventListener> userDAOListeners_;
+ private Map<String, GroupEventListener> groupDAOListeners_;
+ private Map<String, MembershipEventListener> membershipDAOListeners_;
+ private Map<String, UserProfileEventListener> userProfileListeners_;
+ private OrganizationService organizationService;
+ private RepositoryService repositoryService;
+ private boolean executeAllListenersDuringBoot;
+ private Log log = ExoLogger.getLogger(this.getClass());
+
+ public OrganizationListenersInitializerService(OrganizationService organizationService, RepositoryService repositoryService, ConfigurationManager manager, InitParams initParams) {
+ this.organizationService = organizationService;
+ this.repositoryService = repositoryService;
+ userDAOListeners_ = new HashMap<String, UserEventListener>();
+ groupDAOListeners_ = new HashMap<String, GroupEventListener>();
+ membershipDAOListeners_ = new HashMap<String, MembershipEventListener>();
+ userProfileListeners_ = new HashMap<String, UserProfileEventListener>();
+ boolean hasExternalComponentPlugins = false;
+ int nbExternalComponentPlugins = 0;
+ try {
+ ExternalComponentPlugins organizationServiceExternalComponentPlugins = manager.getConfiguration().getExternalComponentPlugins(OrganizationListenersInitializerService.class.getName());
+
+ if (organizationServiceExternalComponentPlugins != null && organizationServiceExternalComponentPlugins.getComponentPlugins() != null) {
+ nbExternalComponentPlugins = organizationServiceExternalComponentPlugins.getComponentPlugins().size();
+ }
+
+ Component organizationServiceComponent = manager.getComponent(OrganizationListenersInitializerService.class);
+
+ if (organizationServiceComponent != null && organizationServiceComponent.getComponentPlugins() != null) {
+ nbExternalComponentPlugins += organizationServiceComponent.getComponentPlugins().size();
+ }
+ hasExternalComponentPlugins = (nbExternalComponentPlugins > 0);
+ } catch (Exception e) {
+ log.error("Test if this component has ExternalComponentPlugins generated an exception, cause:" + e.getMessage());
+ }
+
+ if (!hasExternalComponentPlugins) {
+ try {
+ ExternalComponentPlugins organizationServiceExternalComponentPlugins = manager.getConfiguration().getExternalComponentPlugins(OrganizationService.class.getName());
+ addComponentPlugin(this, organizationServiceExternalComponentPlugins.getComponentPlugins(), ExoContainerContext.getCurrentContainer());
+
+ Component organizationServiceComponent = manager.getComponent(OrganizationService.class);
+ List<org.exoplatform.container.xml.ComponentPlugin> organizationServicePlugins = organizationServiceComponent.getComponentPlugins();
+ if (organizationServicePlugins != null) {
+ addComponentPlugin(this, organizationServicePlugins, ExoContainerContext.getCurrentContainer());
+ }
+ } catch (Exception e) {
+ log.error("Failed to add OrganizationService plugins to the OrgSrvInitializer ");
+ }
+ } else {
+ log.info("This component has already " + nbExternalComponentPlugins + " ExternalComponentPlugins");
+ }
+ OrganizationInitializerUtils.REPOSITORY = initParams.getValueParam("repository").getValue();
+ OrganizationInitializerUtils.WORKSPACE = initParams.getValueParam("workspace").getValue();
+ OrganizationInitializerUtils.HOME_PATH = initParams.getValueParam("homePath").getValue();
+ this.executeAllListenersDuringBoot = Boolean.parseBoolean(initParams.getValueParam("executeAllListenersDuringBoot").getValue());
+ }
+
+ private static final Comparator<org.exoplatform.container.xml.ComponentPlugin> COMPARATOR = new Comparator<org.exoplatform.container.xml.ComponentPlugin>() {
+ public int compare(org.exoplatform.container.xml.ComponentPlugin o1, org.exoplatform.container.xml.ComponentPlugin o2) {
+ return o1.getPriority() - o2.getPriority();
+ }
+ };
+
+ @SuppressWarnings("unchecked")
+ private void addComponentPlugin(Object component, List<org.exoplatform.container.xml.ComponentPlugin> plugins, ExoContainer container) throws Exception {
+ if (plugins == null)
+ return;
+ Collections.sort(plugins, COMPARATOR);
+ for (org.exoplatform.container.xml.ComponentPlugin plugin : plugins) {
+
+ try {
+ Class clazz = Class.forName(plugin.getType());
+ ComponentPlugin cplugin = (ComponentPlugin) container.createComponent(clazz, plugin.getInitParams());
+ cplugin.setName(plugin.getName());
+ cplugin.setDescription(plugin.getDescription());
+ clazz = component.getClass();
+
+ Method m = getSetMethod(clazz, plugin.getSetMethod());
+ Object[] params = {cplugin};
+ m.invoke(component, params);
+
+ cplugin.setName(plugin.getName());
+ cplugin.setDescription(plugin.getDescription());
+ } catch (Exception ex) {
+ log.error("Failed to instanciate plugin " + plugin.getName() + "for component " + component + ": " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ private Method getSetMethod(Class clazz, String name) {
+ Method[] methods = clazz.getMethods();
+ for (Method m : methods) {
+ if (name.equals(m.getName())) {
+ Class[] types = m.getParameterTypes();
+ if (types != null && types.length == 1 && ComponentPlugin.class.isAssignableFrom(types[0])) {
+ return m;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void start()
+ {
+ if (executeAllListenersDuringBoot)
+ {
+ log.info("Going to execute listeners for all users and groups");
+ RequestLifeCycle.begin(PortalContainer.getInstance());
+
+ try
+ {
+ // TODO: Make checkFolders configurable through startup parameters? Or try existence of JCR workspace?
+ boolean checkFolders = true;
+
+ this.launchAll(checkFolders);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+ }
+ else
+ {
+ log.info("Skipped executing of listeners");
+ }
+ }
+
+
+ /**
+ * @param checkFolders whether to check folders in OrganizationInitializerUtils or not. If folders are not checked, we simply trigger all listeners for users and groups.
+ * @return true if no error occured and everything has been created correctly.
+ */
+ public boolean launchAll(boolean checkFolders) {
+
+ boolean ok = true;
+ try {
+ log.info("Launch OrganizationListenersInitializerService with checkFolders=" + checkFolders);
+
+ if (checkFolders)
+ {
+ Session session = repositoryService.getRepository(OrganizationInitializerUtils.REPOSITORY).getSystemSession(OrganizationInitializerUtils.WORKSPACE);
+ OrganizationInitializerUtils.init(session);
+ }
+
+ PageList pageList = organizationService.getUserHandler().findUsers(new Query());
+ int pagesNumber = pageList.getAvailablePage();
+ for (int i = 1; i <= pagesNumber; i++) {
+ List users = pageList.getPage(i);
+ if (log.isDebugEnabled()) {
+ log.debug("Number of users = " + users.size());
+ }
+
+ for (Object objectUser : users) {
+ User user = (User) objectUser;
+ boolean userOk = treatUser(user, checkFolders);
+
+ if (!userOk)
+ {
+ ok = false;
+ }
+ }
+ }
+
+ Collection groups = organizationService.getGroupHandler().getAllGroups();
+ if (log.isDebugEnabled()) {
+ log.debug("Groups = " + groups.size());
+ }
+ for (Object objectGroup : groups) {
+ Group group = (Group) objectGroup;
+ boolean groupOk = treatGroup(group, checkFolders);
+
+ if (!groupOk)
+ {
+ ok = false;
+ }
+ }
+ log.info("OrganizationListenersInitializerService launched successfully!");
+ } catch (Exception e) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.error(writer.toString());
+ ok = false;
+ }
+
+ return ok;
+ }
+
+
+ public void stop() {
+ }
+
+
+ /**
+ *
+ * @param group
+ * @param checkFolders whether to check folders in OrganizationInitializerUtils or not. If folders are not checked, we simply trigger all listeners for group.
+ * @return true if no error occured and everything has been created correctly.
+ */
+ public boolean treatGroup(Group group, boolean checkFolders) {
+
+ if (group == null)
+ {
+ log.error("Group is null. This group likely does not exist.");
+ return false;
+ }
+
+ boolean ok = true;
+ if (log.isDebugEnabled())
+ {
+ log.debug("Initialize Group listener : " + group.getId() + ", checkFolders=" + checkFolders);
+ }
+
+ try {
+ if (!checkFolders || !OrganizationInitializerUtils.hasGroupFolder(repositoryService, group)) {
+ log.info("Group = " + group.getId());
+ Collection<GroupEventListener> groupDAOListeners = groupDAOListeners_.values();
+ for (GroupEventListener groupEventListener : groupDAOListeners) {
+ try {
+ groupEventListener.preSave(group, true);
+ groupEventListener.postSave(group, true);
+ } catch (Exception e) {e.printStackTrace();
+ log.warn("Failed to initialize " + group.getId() + " Group, listener = " + groupEventListener.getClass());
+ log.debug(e);
+ ok = false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + group.getId() + " Group listeners ", e);
+ ok = false;
+ }
+
+ return ok;
+ }
+
+ /**
+ *
+ * @param user
+ * @param checkFolders whether to check folders in OrganizationInitializerUtils or not. If folders are not checked, we simply trigger all listeners for user, userProfile and all his memberships.
+ * @return true if no error occured and everything has been created correctly.
+ */
+ public boolean treatUser (User user, boolean checkFolders) {
+ if (user == null)
+ {
+ log.error("User is null. This user likely does not exist.");
+ return false;
+ }
+
+ boolean ok = true;
+
+ if (user.getCreatedDate() == null) {
+ user.setCreatedDate(new Date());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Initialize User listener : " + user.getUserName() + ", checkFolders=" + checkFolders);
+ }
+
+ try {
+ if (!checkFolders || !OrganizationInitializerUtils.hasUserFolder(repositoryService, user)) {
+ log.info("User loaded ======> " + user.getUserName());
+ Collection<UserEventListener> userDAOListeners = userDAOListeners_.values();
+ for (UserEventListener userEventListener : userDAOListeners) {
+ try {
+ userEventListener.preSave(user, true);
+ userEventListener.postSave(user, true);
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " User with listener : " + userEventListener.getClass());
+ log.debug("", e);
+ ok = false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " User", e);
+ ok = false;
+ }
+
+ UserProfile userProfile = null;
+ try
+ {
+ userProfile = organizationService.getUserProfileHandler().findUserProfileByName(user.getUserName());
+
+ // TODO: Is this really needed? NewUserEventListener called for this user in previous step, should take care of creating UserProfile if it does not exists.
+ if (userProfile == null) {
+ userProfile = organizationService.getUserProfileHandler().createUserProfileInstance(user.getUserName());
+ organizationService.getUserProfileHandler().saveUserProfile(userProfile, true);
+ userProfile = organizationService.getUserProfileHandler().findUserProfileByName(user.getUserName());
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to load user profile for " + user.getUserName() + " User", e);
+ ok = false;
+ }
+
+ try {
+ if (!checkFolders || !OrganizationInitializerUtils.hasProfileFolder(repositoryService, userProfile)) {
+ log.info("User profile loaded ======> " + user.getUserName());
+ Collection<UserProfileEventListener> userProfileListeners = userProfileListeners_.values();
+ for (UserProfileEventListener userProfileEventListener : userProfileListeners) {
+ try {
+ if(userProfile.getUserInfoMap() == null) {
+ userProfile.setUserInfoMap(new HashMap<String, String>());
+ }
+ userProfileEventListener.preSave(userProfile, true);
+ userProfileEventListener.postSave(userProfile, true);
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " User profile with listener : " + userProfileEventListener.getClass());
+ log.debug(e);
+ ok = false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " User profile", e);
+ ok = false;
+ }
+
+ try {
+ Collection memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName());
+ if (log.isDebugEnabled()) {
+ log.debug("Memberships = " + memberships.size());
+ }
+ for (Object objectMembership : memberships) {
+ Membership membership = (Membership) objectMembership;
+ try {
+ if (!checkFolders || !OrganizationInitializerUtils.hasMembershipFolder(repositoryService, membership)) {
+ log.info("Membership loaded = " + membership.getId());
+ Collection<MembershipEventListener> membershipDAOListeners = membershipDAOListeners_.values();
+ for (MembershipEventListener membershipEventListener : membershipDAOListeners) {
+ try {
+ membershipEventListener.preSave(membership, true);
+ membershipEventListener.postSave(membership, true);
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " Membership (" + membership.getId() + ") listener = " + membershipEventListener.getClass());
+ log.debug(e);
+ ok = false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " Membership (" + membership.getId() + ")");
+ log.debug(e);
+ ok = false;
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to initialize " + user.getUserName() + " Memberships listeners", e);
+ ok = false;
+ }
+
+ return ok;
+ }
+
+ public synchronized void addListenerPlugin(ComponentPlugin listener) throws Exception {
+ if (listener instanceof UserEventListener)
+ userDAOListeners_.put(listener.getName(), (UserEventListener) listener);
+ else if (listener instanceof GroupEventListener)
+ groupDAOListeners_.put(listener.getName(), (GroupEventListener) listener);
+ else if (listener instanceof MembershipEventListener)
+ membershipDAOListeners_.put(listener.getName(), (MembershipEventListener) listener);
+ else if (listener instanceof UserProfileEventListener)
+ userProfileListeners_.put(listener.getName(), (UserProfileEventListener) listener);
+ }
+}
\ No newline at end of file
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/RestOrganizationInitializer.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/RestOrganizationInitializer.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/RestOrganizationInitializer.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+
+package org.exoplatform.core.component.organization.initializer;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupHandler;
+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;
+
+/**
+ * REST Endpoint for accessing OrganizationListenersInitializerService stuff.
+ */
+ at Path("/initializer/")
+public class RestOrganizationInitializer implements ResourceContainer {
+
+ private OrganizationListenersInitializerService initializerService;
+ private Log log = ExoLogger.getLogger(this.getClass());
+ private OrganizationService orgService_;
+
+
+ public RestOrganizationInitializer(
+ OrganizationListenersInitializerService organizationListenersInitializerService, OrganizationService orgService) {
+ this.initializerService = organizationListenersInitializerService;
+ this.orgService_=orgService;
+ }
+
+
+ @GET
+ @Path("launchAllListeners/{checkFolders}")
+ public String launchAllListeners(@PathParam("checkFolders") Boolean checkFolders)
+ {
+ boolean ok = initializerService.launchAll(checkFolders);
+ String responseString = ok ? "All listeners executed successfuly." : "Error occured during execution of listeners.";
+ return responseString;
+ }
+
+
+ @GET
+ @Path("launchUserListeners/{userName}/{checkFolders}")
+ public String launchUserListeners(@PathParam("userName") String userName,
+ @PathParam("checkFolders") Boolean checkFolders) {
+ UserHandler userHandler = orgService_.getUserHandler();
+ User user;
+ try {
+ user = userHandler.findUserByName(userName);
+ boolean ok = initializerService.treatUser(user, checkFolders);
+ String responseString = ok ? "User listeners executed successfuly." : "Error occured during execution of user listeners.";
+ return responseString;
+ } catch (Exception e) {
+ log.warn("Error with user "+userName, e);
+ return "Error occured during execution of user listeners: " + e.getMessage();
+ }
+ }
+
+
+ @GET
+ @Path("launchGroupListeners/{groupName}/{checkFolders}")
+ public String launchGroupListeners(@PathParam("groupName") String groupName,
+ @PathParam("checkFolders") Boolean checkFolders)
+ {
+ // We simply can't use slash in rest url
+ groupName = groupName.replaceAll("@", "/");
+
+ GroupHandler groupHandler = orgService_.getGroupHandler();
+ Group group;
+ try
+ {
+ group = groupHandler.findGroupById(groupName);
+ boolean ok = initializerService.treatGroup(group, checkFolders);
+ String responseString = ok ? "Group listeners executed successfuly." : "Error occured during execution of group listeners.";
+ return responseString;
+ }
+ catch (Exception e)
+ {
+ log.warn("Error with group " + groupName, e);
+ return "Error occured during execution of group listeners: " + e.getMessage();
+ }
+ }
+
+}
Added: epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/TriggerInitializerFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/TriggerInitializerFilter.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/initializer/src/main/java/org/exoplatform/core/component/organization/initializer/TriggerInitializerFilter.java 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.
+ */
+
+package org.exoplatform.core.component.organization.initializer;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.web.filter.Filter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * Filter will trigger listeners of {@link OrganizationListenersInitializerService} after login of user.
+ * It can be configured to trigger listeners also for all groups of this user.
+ *
+ * @author <a href="mailto:mposolda at redhat.com">Marek Posolda</a>
+ */
+public class TriggerInitializerFilter implements Filter
+{
+ // Whether to check JCR folders when triggering listeners
+ private boolean checkFolders;
+
+ // If true, we will trigger listener not only for user, but also for all his groups.
+ private boolean triggerListenersForGroups;
+
+ private Log log = ExoLogger.getLogger(this.getClass());
+
+ // Flag to ensure that we will trigger listeners only once per logged user.
+ private static final String ATTR_FLAG_NAME = "TriggerInitializerFilter.flag";
+
+ public Boolean isCheckFolders()
+ {
+ return checkFolders;
+ }
+
+ public void setCheckFolders(Boolean checkFolders)
+ {
+ this.checkFolders = checkFolders;
+ }
+
+ public Boolean isTriggerListenersForGroups()
+ {
+ return triggerListenersForGroups;
+ }
+
+ public void setTriggerListenersForGroups(Boolean triggerListenersForGroups)
+ {
+ this.triggerListenersForGroups = triggerListenersForGroups;
+ }
+
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("filter in progress. checkFolders=" + checkFolders + ", TriggerListenersForGroups=" + triggerListenersForGroups);
+ }
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
+
+ //
+ if (httpServletRequest.getRemoteUser() != null && httpServletRequest.getSession().getAttribute(ATTR_FLAG_NAME) == null)
+ {
+ // Find services with ExoContainer
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ OrganizationListenersInitializerService initializer = (OrganizationListenersInitializerService)container.getComponentInstanceOfType(OrganizationListenersInitializerService.class);
+ OrganizationService orgService = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
+
+ // Encapsulate with RequestLifeCycle
+ RequestLifeCycle.begin(container);
+ try
+ {
+ // Find user and trigger listeners for him
+ String username = httpServletRequest.getRemoteUser();
+ User user = orgService.getUserHandler().findUserByName(username);
+ initializer.treatUser(user, checkFolders);
+
+ // This means that we will trigger listeners for all groups of particular user as well
+ if (triggerListenersForGroups)
+ {
+ Collection<Group> groups = orgService.getGroupHandler().findGroupsOfUser(username);
+ for (Group group : groups)
+ {
+ initializer.treatGroup(group, checkFolders);
+ }
+ }
+
+ // Put flag to indicate, that this session is "processed"
+ httpServletRequest.getSession().setAttribute(ATTR_FLAG_NAME, "true");
+ }
+ catch (Exception e)
+ {
+ log.error("Error occured in TriggerInitializerFilter", e);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+ }
+
+ // Continue with filter chain
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/component/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/pom.xml 2012-03-07 10:38:07 UTC (rev 8545)
+++ epp/portal/branches/EPP_5_2_Branch/component/pom.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -45,6 +45,7 @@
<module>scripting</module>
<module>management</module>
<module>identity</module>
+ <module>initializer</module>
</modules>
</project>
Modified: epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/gatein.ear/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/gatein.ear/pom.xml 2012-03-07 10:38:07 UTC (rev 8545)
+++ epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/gatein.ear/pom.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -179,6 +179,10 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.initializer</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.resources</artifactId>
</dependency>
Modified: epp/portal/branches/EPP_5_2_Branch/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/pom.xml 2012-03-07 10:38:07 UTC (rev 8545)
+++ epp/portal/branches/EPP_5_2_Branch/pom.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -525,6 +525,11 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.initializer</artifactId>
+ <version>5.2.1.ER02-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.resources</artifactId>
<version>5.2.1.ER02-SNAPSHOT</version>
</dependency>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2012-03-07 10:38:07 UTC (rev 8545)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -50,6 +50,10 @@
<!-- <import>war:/conf/security-configuration.xml</import> -->
<import>war:/conf/organization/organization-configuration.xml</import>
+
+ <!-- Uncomment for enable initializer (OrganizationListenersInitializerService and related stuff) -->
+ <!--<import>war:/conf/organization/initializer-configuration.xml</import>-->
+
<import>war:/conf/jcr/component-plugins-configuration.xml</import>
<import>war:/conf/mail/portal-mail-configuration.xml</import>
Added: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/organization/initializer-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/organization/initializer-configuration.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/organization/initializer-configuration.xml 2012-03-08 13:32:18 UTC (rev 8546)
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ JBoss, a division of Red Hat
+ ~ Copyright 2012, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ 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.
+ -->
+<configuration>
+
+ <!-- Main configuration of service -->
+ <component>
+ <type>org.exoplatform.core.component.organization.initializer.OrganizationListenersInitializerService</type>
+ <init-params>
+ <value-param>
+ <name>repository</name>
+ <value>repository</value>
+ </value-param>
+ <value-param>
+ <name>workspace</name>
+ <value>portal-system</value>
+ </value-param>
+ <value-param>
+ <name>homePath</name>
+ <value>/</value>
+ </value-param>
+ <value-param>
+ <name>executeAllListenersDuringBoot</name>
+ <value>true</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <!-- Possibility to trigger operations through REST -->
+ <component>
+ <type>org.exoplatform.core.component.organization.initializer.RestOrganizationInitializer</type>
+ </component>
+
+ <!-- Possibility to trigger operations through JMX -->
+ <component>
+ <type>org.exoplatform.core.component.organization.initializer.JMXOrganizationInitializer</type>
+ </component>
+
+ <!-- Listeners for creating marker JCR folders -->
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.organization.OrganizationService</target-component>
+ <component-plugin>
+ <name>organization.initializer.group.event.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.core.component.organization.initializer.NewGroupListener</type>
+ <description>description</description>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.initializer.user.event.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.core.component.organization.initializer.NewUserListener</type>
+ <description>description</description>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.initializer.membership.event.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.core.component.organization.initializer.NewMembershipListener</type>
+ <description>description</description>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.initializer.profile.event.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.core.component.organization.initializer.NewProfileListener</type>
+ <description>description</description>
+ </component-plugin>
+ </external-component-plugins>
+
+ <!-- Trigger listeners for particular user after his login -->
+ <external-component-plugins>
+ <target-component>org.exoplatform.web.filter.ExtensibleFilter</target-component>
+ <component-plugin>
+ <name>TriggerInitializerFilter</name>
+ <set-method>addFilterDefinitions</set-method>
+ <type>org.exoplatform.web.filter.FilterDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>Trigger Initializer filter definition</name>
+ <object type="org.exoplatform.web.filter.FilterDefinition">
+ <field name="filter">
+ <object type="org.exoplatform.core.component.organization.initializer.TriggerInitializerFilter">
+ <field name="checkFolders"><boolean>true</boolean></field>
+ <field name="triggerListenersForGroups"><boolean>true</boolean></field>
+ </object>
+ </field>
+ <field name="patterns">
+ <collection type="java.util.ArrayList" item-type="java.lang.String">
+ <value>
+ <string>/.*</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ <!-- Trigger all listeners periodically -->
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.scheduler.JobSchedulerService</target-component>
+ <component-plugin>
+ <name>OrgInitializerCronJob</name>
+ <set-method>addCronJob</set-method>
+ <type>org.exoplatform.services.scheduler.CronJob</type>
+ <description>Initialize added Organization Model objects added by an UIother tha eXo UI</description>
+ <init-params>
+ <properties-param>
+ <name>cronjob.info</name>
+ <description>Invoke initializer periodically</description>
+ <property name="jobName" value="OrgInitializerCronJob"/>
+ <property name="groupName" value="group"/>
+ <property name="job" value="org.exoplatform.core.component.organization.initializer.OrganizationInitializerJob"/>
+ <property name="expression" value="0 45 23 * * ? *"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
More information about the gatein-commits
mailing list