Extracted hook specific project from event-publisher-portal
commit
bf0a4d6353
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.liferay.ide.eclipse.server.tomcat.runtimeClasspathProvider/Liferay v6.2 (Tomcat 7)">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="jst.web"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -0,0 +1 @@
|
||||
target
|
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>event-publisher-hook</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/webapp"/>
|
||||
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="target/m2e-wtp/web-resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
|
||||
<attributes>
|
||||
<attribute name="hide" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
@ -0,0 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=gcube-developer
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="event-publisher-hook-hook">
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<property name="java-output-path" value="/event-publisher-portal/target/classes"/>
|
||||
<property name="context-root" value="event-publisher-portal"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<runtime name="Liferay v6.2 (Tomcat 7)"/>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="jst.web" version="2.4"/>
|
||||
<installed facet="liferay.hook" version="6.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
@ -0,0 +1 @@
|
||||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
@ -0,0 +1 @@
|
||||
Window
|
@ -0,0 +1,2 @@
|
||||
disabled=06target
|
||||
eclipse.preferences.version=1
|
@ -0,0 +1,7 @@
|
||||
# Changelog for "event-publisher-portal"
|
||||
|
||||
## [v1.0.0-SNAPSHOT]
|
||||
- First release (#19461)
|
||||
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
@ -0,0 +1,47 @@
|
||||
# Event Publisher Portal
|
||||
|
||||
**Event Publisher Hook** is a [Liferay](https://liferay.com) 6.2 hook that provides some portal's events and model listeners that push events to a broker endpoint.
|
||||
|
||||
## Structure of the project
|
||||
|
||||
The source code is present in `src` folder.
|
||||
|
||||
## Built With
|
||||
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
To build the hook WAR file it is sufficient to type
|
||||
|
||||
mvn clean package
|
||||
|
||||
## Change log
|
||||
|
||||
See [Releases](https://code-repo.d4science.org/gCubeSystem/authorization-client/releases).
|
||||
|
||||
## Authors
|
||||
|
||||
* **Mauro Mugnaini** ([Nubisware S.r.l.](http://www.nubisware.com))
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- DILIGENT (grant no. 004260);
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
|
||||
- the H2020 research and innovation programme
|
||||
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
|
||||
|
@ -0,0 +1,112 @@
|
||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>event-publisher-portal</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<liferay.version>6.2.5</liferay.version>
|
||||
<liferay.maven.plugin.version>6.2.10.12</liferay.maven.plugin.version>
|
||||
<liferay.auto.deploy.dir>/Users/themaxx/Development/Server/liferay-portal-6.2-ce-ga6/deploy
|
||||
</liferay.auto.deploy.dir>
|
||||
<liferay.app.server.deploy.dir>/Users/themaxx/Development/Server/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/webapps
|
||||
</liferay.app.server.deploy.dir>
|
||||
<liferay.app.server.lib.global.dir>/Users/themaxx/Development/Server/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/lib/ext
|
||||
</liferay.app.server.lib.global.dir>
|
||||
<liferay.app.server.portal.dir>/Users/themaxx/Development/Server/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/webapps/ROOT
|
||||
</liferay.app.server.portal.dir>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.liferay.maven.plugins</groupId>
|
||||
<artifactId>liferay-maven-plugin</artifactId>
|
||||
<version>${liferay.maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
|
||||
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
|
||||
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
|
||||
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
|
||||
<liferayVersion>${liferay.version}</liferayVersion>
|
||||
<pluginType>hook</pluginType>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>event-publisher-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>event-publisher-portal</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-java</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID></ID>
|
||||
<Type>Portlet</Type>
|
||||
<Profile>
|
||||
<Description>${project.description}</Description>
|
||||
<Class>PortletUser</Class>
|
||||
<Name>${project.artifactId}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>${project.artifactId}</Name>
|
||||
<Description>${project.description}</Description>
|
||||
<MavenCoordinates>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>${project.build.finalName}.${project.packaging}</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
@ -0,0 +1,18 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>servicearchive</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
@ -0,0 +1,50 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
|
||||
import com.liferay.portal.model.User;
|
||||
|
||||
public class ActionEvent extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = -256209939036712171L;
|
||||
|
||||
public static final String LOGIN_NAME = "login";
|
||||
public static final String LOGOUT_NAME = "logout";
|
||||
|
||||
private ActionEvent(String name, User user) throws UserManagementSystemException, UserRetrievalFault {
|
||||
super(name);
|
||||
setUser(user);
|
||||
}
|
||||
|
||||
public static ActionEvent newLoginEvent(HttpServletRequest request, HttpServletResponse response) {
|
||||
User user = (User) request.getSession(false).getAttribute("USER");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sending login event for user: " + user.getScreenName());
|
||||
}
|
||||
try {
|
||||
return new ActionEvent(LOGIN_NAME, user);
|
||||
} catch (UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create action event for user: " + user, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ActionEvent newLogoutEvent(HttpServletRequest request, HttpServletResponse response) {
|
||||
User user = (User) request.getSession(false).getAttribute("USER");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sending logut event for user: " + user.getScreenName());
|
||||
}
|
||||
try {
|
||||
return new ActionEvent(LOGOUT_NAME, user);
|
||||
} catch (UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create action event for user: " + user, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.AbstractLR62EventPublisher;
|
||||
|
||||
public class ActionEventPublisher extends AbstractLR62EventPublisher {
|
||||
|
||||
public ActionEventPublisher() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.gcube.event.publisher.EventPublisher;
|
||||
|
||||
import com.liferay.portal.kernel.events.Action;
|
||||
import com.liferay.portal.kernel.events.ActionException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
public class PostLoginAction extends Action {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(PostLoginAction.class);
|
||||
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
public PostLoginAction() {
|
||||
eventPublisher = new ActionEventPublisher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
|
||||
ActionEvent actionEvent = ActionEvent.newLoginEvent(request, response);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("ActionEvent is: " + actionEvent);
|
||||
}
|
||||
eventPublisher.publish(actionEvent);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.gcube.event.publisher.EventPublisher;
|
||||
|
||||
import com.liferay.portal.kernel.events.Action;
|
||||
import com.liferay.portal.kernel.events.ActionException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
public class PreLogoutAction extends Action {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(PreLogoutAction.class);
|
||||
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
public PreLogoutAction() {
|
||||
eventPublisher = new ActionEventPublisher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
|
||||
ActionEvent actionEvent = ActionEvent.newLogoutEvent(request, response);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("ActionEvent is: " + actionEvent);
|
||||
}
|
||||
eventPublisher.publish(actionEvent);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import org.gcube.event.publisher.EventPublisher;
|
||||
|
||||
import com.liferay.portal.kernel.events.ActionException;
|
||||
import com.liferay.portal.kernel.events.SimpleAction;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
public class ShutdownAction extends SimpleAction implements Runnable {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(ShutdownAction.class);
|
||||
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
public ShutdownAction() {
|
||||
eventPublisher = new ActionEventPublisher();
|
||||
// Runtime.getRuntime().addShutdownHook(new Thread(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String[] ids) throws ActionException {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("Sending shutdown event");
|
||||
}
|
||||
eventPublisher.publish(SimpleActionEvent.newShutdownEvent(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.run(null);
|
||||
} catch (ActionException e) {
|
||||
// Left intentionally as it is
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
|
||||
public class SimpleActionEvent extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = -256209939036712171L;
|
||||
|
||||
public static final String STARTUP_NAME = "startup";
|
||||
public static final String SHUTDOWN_NAME = "shutdown";
|
||||
|
||||
public static final String IDS_ENTRY = "ids";
|
||||
|
||||
private SimpleActionEvent(String name, String[] ids) {
|
||||
super(name);
|
||||
setData(ids);
|
||||
}
|
||||
|
||||
public static SimpleActionEvent newStartupEvent(String[] ids) {
|
||||
return new SimpleActionEvent(STARTUP_NAME, ids);
|
||||
}
|
||||
|
||||
public static SimpleActionEvent newShutdownEvent(String[] ids) {
|
||||
return new SimpleActionEvent(SHUTDOWN_NAME, ids);
|
||||
}
|
||||
|
||||
public void setData(String[] ids) {
|
||||
set(IDS_ENTRY, String.join(", ", ids));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.gcube.portal.event.publisher.lr62.action;
|
||||
|
||||
import org.gcube.event.publisher.EventPublisher;
|
||||
|
||||
import com.liferay.portal.kernel.events.ActionException;
|
||||
import com.liferay.portal.kernel.events.SimpleAction;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
public class StartupAction extends SimpleAction {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(StartupAction.class);
|
||||
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
public StartupAction() {
|
||||
eventPublisher = new ActionEventPublisher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String[] ids) throws ActionException {
|
||||
SimpleActionEvent event = SimpleActionEvent.newStartupEvent(ids);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("Sending startup event: " + event);
|
||||
}
|
||||
eventPublisher.publish(event);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.AbstractLR62EventPublisher;
|
||||
|
||||
import com.liferay.portal.model.BaseModel;
|
||||
import com.liferay.portal.model.ModelListener;
|
||||
|
||||
public abstract class AbstractEventPublisherBaseModelListener<T extends BaseModel<T>>
|
||||
extends AbstractLR62EventPublisher
|
||||
implements ModelListener<T> {
|
||||
|
||||
public AbstractEventPublisherBaseModelListener() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.Group;
|
||||
|
||||
public class GroupEvent extends PortalModelListenerEvent<Group> {
|
||||
|
||||
private static final long serialVersionUID = 3939268094440017646L;
|
||||
|
||||
public static final String CREATED_NAME = "group_created";
|
||||
public static final String DELETED_NAME = "group_deleted";
|
||||
|
||||
private GroupEvent(String name, Group group) throws PortalException, SystemException {
|
||||
super(name, group);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public static GroupEvent newCreatedEvent(Group group) {
|
||||
try {
|
||||
return new GroupEvent(CREATED_NAME, group);
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot create event from Group model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static GroupEvent newDeletedEvent(Group group) {
|
||||
try {
|
||||
return new GroupEvent(DELETED_NAME, group);
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot create event from Group model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
|
||||
public class GroupEventPublisher extends AbstractEventPublisherBaseModelListener<Group> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(GroupEventPublisher.class);
|
||||
|
||||
public GroupEventPublisher() {
|
||||
super();
|
||||
log.info("New GroupEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(Group group) throws ModelListenerException {
|
||||
if (group.isSite()) {
|
||||
log.info("Created a site Group");
|
||||
GroupEvent groupEvent = GroupEvent.newCreatedEvent(group);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Group event is: " + groupEvent);
|
||||
}
|
||||
publish(groupEvent);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Created a non-site Group");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(Group group) throws ModelListenerException {
|
||||
if (group.isSite()) {
|
||||
log.info("Deleted a site Group");
|
||||
GroupEvent groupEvent = GroupEvent.newDeletedEvent(group);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Group event is: " + groupEvent);
|
||||
}
|
||||
publish(groupEvent);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Deleted a non-site Group");
|
||||
}
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(Group group) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(Group group) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(Group group) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(Group group) throws ModelListenerException {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portal.event.publisher.lr62.PortalEvent;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
|
||||
import com.liferay.portal.model.BaseModel;
|
||||
import com.liferay.portal.model.User;
|
||||
|
||||
public class PortalModelListenerEvent<T extends BaseModel<T>> extends PortalEvent {
|
||||
|
||||
private static final long serialVersionUID = -9062395669075373612L;
|
||||
|
||||
public static final String MODELCLASSNAME_ENTRY = "model-class-name";
|
||||
|
||||
public PortalModelListenerEvent(String name, T baseModel) {
|
||||
super(name);
|
||||
setModelClassName(baseModel.getModelClassName());
|
||||
}
|
||||
|
||||
public PortalModelListenerEvent(String name, User user, T baseModel)
|
||||
throws UserManagementSystemException, UserRetrievalFault {
|
||||
|
||||
super(name);
|
||||
setUser(user);
|
||||
setModelClassName(baseModel.getModelClassName());
|
||||
}
|
||||
|
||||
public PortalModelListenerEvent(String name, Map<String, String> data, User user, T baseModel)
|
||||
throws UserManagementSystemException, UserRetrievalFault {
|
||||
|
||||
super(name, data);
|
||||
setUser(user);
|
||||
setModelClassName(baseModel.getModelClassName());
|
||||
}
|
||||
|
||||
public void setModelClassName(String group) {
|
||||
set(MODELCLASSNAME_ENTRY, group);
|
||||
}
|
||||
|
||||
public String getModelClassName() {
|
||||
return (String) get(MODELCLASSNAME_ENTRY);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.User;
|
||||
|
||||
public class UserEvent extends PortalModelListenerEvent<User> {
|
||||
|
||||
private static final long serialVersionUID = 3939268094440017646L;
|
||||
|
||||
public static final String CREATED_NAME = "user_created";
|
||||
public static final String DELETED_NAME = "user_deleted";
|
||||
|
||||
public static final String UG_CREATED_NAME = "user-group_created";
|
||||
public static final String UG_DELETED_NAME = "user-group_deleted";
|
||||
|
||||
private UserEvent(String name, User user) throws UserManagementSystemException, UserRetrievalFault {
|
||||
super(name, user, user);
|
||||
}
|
||||
|
||||
private UserEvent(String name, User user, Group group)
|
||||
throws PortalException, SystemException, UserManagementSystemException, UserRetrievalFault {
|
||||
|
||||
this(name, user);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public static UserEvent newCreatedEvent(User user) {
|
||||
try {
|
||||
return new UserEvent(CREATED_NAME, user);
|
||||
} catch (UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from User model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static UserEvent newDeletedEvent(User user) {
|
||||
try {
|
||||
return new UserEvent(DELETED_NAME, user);
|
||||
} catch (UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from User model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static UserEvent newCreatedEvent(User user, Group group) {
|
||||
try {
|
||||
return new UserEvent(UG_CREATED_NAME, user, group);
|
||||
} catch (PortalException | SystemException | UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from one model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static UserEvent newDeletedEvent(User user, Group group) {
|
||||
try {
|
||||
return new UserEvent(UG_DELETED_NAME, user, group);
|
||||
} catch (PortalException | SystemException | UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from one model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<User> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(UserEventPublisher.class);
|
||||
|
||||
public UserEventPublisher() {
|
||||
super();
|
||||
log.info("New UserEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(User user) throws ModelListenerException {
|
||||
log.info("New user created");
|
||||
UserEvent userEvent = UserEvent.newCreatedEvent(user);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("User event is: " + userEvent);
|
||||
}
|
||||
publish(userEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(User user) throws ModelListenerException {
|
||||
log.info("User removed");
|
||||
UserEvent userEvent = UserEvent.newDeletedEvent(user);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("User event is: " + userEvent);
|
||||
}
|
||||
publish(userEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
if (Group.class.getName().equals(associationClassName)) {
|
||||
log.info("User has been associated to a group");
|
||||
User user = getUser((Long) classPK);
|
||||
Group group = getGroup((Long) associationClassPK);
|
||||
if (user != null && group != null) {
|
||||
if (group.isSite()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Target group is a site: " + group.getName());
|
||||
}
|
||||
UserEvent userEvent = UserEvent.newCreatedEvent(user, group);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("User event is: " + userEvent);
|
||||
}
|
||||
publish(userEvent);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Target group is not a site");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Uninteresting association with: " + associationClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
if (Group.class.getName().equals(associationClassName)) {
|
||||
log.info("User has been associated to a group");
|
||||
User user = getUser((Long) classPK);
|
||||
Group group = getGroup((Long) associationClassPK);
|
||||
if (user != null && group != null) {
|
||||
if (group.isSite()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Target group is a site: " + group.getName());
|
||||
}
|
||||
UserEvent userEvent = UserEvent.newDeletedEvent(user, group);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("User event is: " + userEvent);
|
||||
}
|
||||
publish(userEvent);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Target group is not a site");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Uninteresting association removal with: " + associationClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected User getUser(Long userPK) {
|
||||
User user = null;
|
||||
try {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Getting user object idetified by pk: " + userPK);
|
||||
}
|
||||
user = UserLocalServiceUtil.getUser(userPK);
|
||||
} catch (PortalException | SystemException e) {
|
||||
logger.error("Cannot get user with pk: " + userPK, e);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
protected Group getGroup(Long groupPK) {
|
||||
Group group = null;
|
||||
try {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Getting group object idetified by pk: " + groupPK);
|
||||
}
|
||||
group = GroupLocalServiceUtil.getGroup((Long) groupPK);
|
||||
} catch (PortalException | SystemException e) {
|
||||
logger.error("Cannot get group with pk: " + groupPK, e);
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(User user) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(User user) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(User user) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(User user) throws ModelListenerException {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.UserGroup;
|
||||
|
||||
public class UserGroupEventPublisher extends AbstractEventPublisherBaseModelListener<UserGroup> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(UserGroupEventPublisher.class);
|
||||
|
||||
public UserGroupEventPublisher() {
|
||||
super();
|
||||
log.info("New UserGroupEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(UserGroup userGroup) throws ModelListenerException {
|
||||
log.info("onAfterCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(UserGroup userGroup) throws ModelListenerException {
|
||||
log.info("onBeforeRemove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onAfterAddAssociation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(UserGroup userGroupRole) throws ModelListenerException {
|
||||
log.info("onAfterRemove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onAfterRemoveAssociation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(UserGroup userGroupRole) throws ModelListenerException {
|
||||
log.info("onAfterUpdate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onBeforeAddAssociation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(UserGroup userGroupRole) throws ModelListenerException {
|
||||
log.info("onBeforeCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onBeforeRemoveAssociation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(UserGroup userGroupRole) throws ModelListenerException {
|
||||
log.info("onBeforeUpdate");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.UserGroupGroupRole;
|
||||
|
||||
public class UserGroupGroupRoleEventPublisher extends AbstractEventPublisherBaseModelListener<UserGroupGroupRole> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(UserGroupGroupRoleEventPublisher.class);
|
||||
|
||||
public UserGroupGroupRoleEventPublisher() {
|
||||
super();
|
||||
log.info("New UserGroupGroupRoleEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onAfterCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onBeforeRemove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onAfterAddAssociation: "+ associationClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onAfterRemove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onAfterRemoveAssociation: " + associationClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onAfterUpdate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onBeforeAddAssociation: " + associationClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onBeforeCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
|
||||
log.info("onBeforeRemoveAssociation: "+ associationClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(UserGroupGroupRole userGroupGroupRole) throws ModelListenerException {
|
||||
log.info("onBeforeUpdate");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.Role;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.model.UserGroupRole;
|
||||
|
||||
public class UserGroupRoleEvent extends PortalModelListenerEvent<UserGroupRole> {
|
||||
|
||||
private static final long serialVersionUID = 3939268094440017646L;
|
||||
|
||||
public static final String CREATED_NAME = "user-group-role_created";
|
||||
public static final String DELETED_NAME = "user-group-role_deleted";
|
||||
|
||||
private UserGroupRoleEvent(String name, UserGroupRole userGroupRole, User user, Group group, Role role)
|
||||
throws PortalException, SystemException, UserManagementSystemException, UserRetrievalFault {
|
||||
|
||||
super(name, user, userGroupRole);
|
||||
setGroup(group);
|
||||
setRole(role);
|
||||
}
|
||||
|
||||
public static UserGroupRoleEvent newCreatedEvent(UserGroupRole userGroupRole, User user, Group group, Role role) {
|
||||
try {
|
||||
return new UserGroupRoleEvent(CREATED_NAME, userGroupRole, user, group, role);
|
||||
} catch (PortalException | SystemException | UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static UserGroupRoleEvent newDeletedEvent(UserGroupRole userGroupRole, User user, Group group, Role role) {
|
||||
try {
|
||||
return new UserGroupRoleEvent(DELETED_NAME, userGroupRole, user, group, role);
|
||||
} catch (PortalException | SystemException | UserManagementSystemException | UserRetrievalFault e) {
|
||||
log.error("Cannot create event from model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.UserGroupRole;
|
||||
|
||||
public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModelListener<UserGroupRole> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(UserGroupRoleEventPublisher.class);
|
||||
|
||||
public UserGroupRoleEventPublisher() {
|
||||
super();
|
||||
log.info("New UserGroupRoleEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
try {
|
||||
Group group = userGroupRole.getGroup();
|
||||
if (group.isSite()) {
|
||||
log.info("Created a site user's group role");
|
||||
UserGroupRoleEvent event = UserGroupRoleEvent.newCreatedEvent(userGroupRole, userGroupRole.getUser(),
|
||||
group, userGroupRole.getRole());
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Created a non-site user's group role");
|
||||
}
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot get related model objects", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
try {
|
||||
Group group = userGroupRole.getGroup();
|
||||
if (group.isSite()) {
|
||||
log.info("Deleted a site user's group role");
|
||||
UserGroupRoleEvent event = UserGroupRoleEvent.newDeletedEvent(userGroupRole, userGroupRole.getUser(),
|
||||
group, userGroupRole.getRole());
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Deleted a non-site user's group role");
|
||||
}
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot get related model objects", e);
|
||||
}
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
value.object.listener.com.liferay.portal.model.User=org.gcube.portal.event.publisher.lr62.model.UserEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.Group=org.gcube.portal.event.publisher.lr62.model.GroupEventPublisher
|
||||
#value.object.listener.com.liferay.portal.model.UserGroup=org.gcube.portal.event.publisher.lr62.model.UserGroupEventPublisher
|
||||
#value.object.listener.com.liferay.portal.model.UserGroupGroupRole=org.gcube.portal.event.publisher.lr62.model.UserGroupGroupRoleEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.UserGroupRole=org.gcube.portal.event.publisher.lr62.model.UserGroupRoleEventPublisher
|
||||
login.events.post=org.gcube.portal.event.publisher.lr62.action.PostLoginAction
|
||||
logout.events.pre=org.gcube.portal.event.publisher.lr62.action.PreLogoutAction
|
||||
#servlet.session.destroy.events=
|
||||
#global.startup.events is not hook-able but they should be configured in main portal*.properties
|
||||
#global.shutdown.events is not hook-able but they should be configured in main portal*.properties
|
||||
application.startup.events=org.gcube.portal.event.publisher.lr62.action.StartupAction
|
||||
application.shutdown.events=org.gcube.portal.event.publisher.lr62.action.ShutdownAction
|
||||
# shutdown event is never called. See issue at https://issues.liferay.com/browse/LPS-11613
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
|
||||
|
||||
<hook>
|
||||
<portal-properties>portal.properties</portal-properties>
|
||||
</hook>
|
@ -0,0 +1,9 @@
|
||||
name=event-publisher-hook
|
||||
module-group-id=liferay
|
||||
module-incremental-version=1
|
||||
tags=
|
||||
short-description=
|
||||
change-log=
|
||||
page-url=http://www.liferay.com
|
||||
author=Liferay, Inc.
|
||||
licenses=LGPL
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||
</web-app>
|
@ -0,0 +1 @@
|
||||
d4science.event-broker-endpoint=http://localhost:8984/event/
|
Loading…
Reference in New Issue