revised job notifications
This commit is contained in:
parent
a0432fed4d
commit
593644b9ec
|
@ -1,8 +1,12 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [v1.1.1-SNAPSHOT] - 2022-04-21
|
||||||
|
|
||||||
|
- Partially added support for workspace notifications
|
||||||
|
|
||||||
## [v1.0.0] - 2022-04-05
|
## [v1.0.0] - 2022-04-05
|
||||||
|
|
||||||
First release
|
- First release
|
||||||
|
|
||||||
|
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
43
pom.xml
43
pom.xml
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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">
|
<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">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -10,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.social-networking</groupId>
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
<artifactId>social-service-model</artifactId>
|
<artifactId>social-service-model</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>social-networking-service-model</name>
|
<name>social-networking-service-model</name>
|
||||||
<description>Social networking service model classes</description>
|
<description>Social networking service model classes</description>
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<java-version>1.8</java-version>
|
<java-version>1.8</java-version>
|
||||||
<version.jersey>2.9</version.jersey>
|
<version.jersey>2.9</version.jersey>
|
||||||
|
<enunciate.version>2.14.0</enunciate.version>
|
||||||
<gCubeSubsystem>social-networking</gCubeSubsystem>
|
<gCubeSubsystem>social-networking</gCubeSubsystem>
|
||||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||||
|
@ -51,12 +54,7 @@
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>social-networking-library</artifactId>
|
|
||||||
<version>[1.16.0, 2.0.0)</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-model</artifactId>
|
<artifactId>storagehub-model</artifactId>
|
||||||
|
@ -90,35 +88,26 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
|
<additionalJOption>-Xdoclint:none</additionalJOption>
|
||||||
|
</configuration>
|
||||||
|
<version>3.1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>generate-doc</id>
|
||||||
|
<phase>install</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test-jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skipTests>true</skipTests>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>${java_version}</source>
|
|
||||||
<target>${java_version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -2,14 +2,8 @@ package org.gcube.social_networking.socialnetworking.model.beans;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.JobStatusType;
|
|
||||||
import org.gcube.portal.databook.shared.RunningJob;
|
|
||||||
import org.gcube.social_networking.socialnetworking.model.custom.serializers_deserializers.JobStatusTypeDeserializer;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,9 +30,8 @@ public class JobNotificationBean {
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
|
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
@JsonDeserialize(using=JobStatusTypeDeserializer.class)
|
|
||||||
@NotNull(message="status cannot be missing")
|
@NotNull(message="status cannot be missing")
|
||||||
private JobStatusType status;
|
private JobStatusModelType status;
|
||||||
|
|
||||||
@JsonProperty("status_message")
|
@JsonProperty("status_message")
|
||||||
private String statusMessage;
|
private String statusMessage;
|
||||||
|
@ -56,7 +49,7 @@ public class JobNotificationBean {
|
||||||
* @param statusMessage
|
* @param statusMessage
|
||||||
*/
|
*/
|
||||||
public JobNotificationBean(String recipient, String jobId, String jobName,
|
public JobNotificationBean(String recipient, String jobId, String jobName,
|
||||||
String serviceName, JobStatusType status, String statusMessage) {
|
String serviceName, JobStatusModelType status, String statusMessage) {
|
||||||
super();
|
super();
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
this.jobId = jobId;
|
this.jobId = jobId;
|
||||||
|
@ -106,21 +99,14 @@ public class JobNotificationBean {
|
||||||
this.jobName = jobName;
|
this.jobName = jobName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobStatusType getStatus() {
|
public JobStatusModelType getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(JobStatusType status) {
|
public void setStatus(JobStatusModelType status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public RunningJob getRunningJob(){
|
|
||||||
|
|
||||||
return new RunningJob(jobId, jobName, status, statusMessage, serviceName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "JobNotificationBean ["
|
return "JobNotificationBean ["
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.gcube.social_networking.socialnetworking.model.beans;
|
||||||
|
|
||||||
|
public enum JobStatusModelType {
|
||||||
|
/**
|
||||||
|
* The job has been cancelled.
|
||||||
|
*/
|
||||||
|
CANCELLED,
|
||||||
|
/**
|
||||||
|
* The job is in the process of being cancelled.
|
||||||
|
*/
|
||||||
|
CANCELLING,
|
||||||
|
/**
|
||||||
|
* The job has been deleted.
|
||||||
|
*/
|
||||||
|
DELETED,
|
||||||
|
/**
|
||||||
|
* The job is in the process of being deleted.
|
||||||
|
*/
|
||||||
|
DELETING,//
|
||||||
|
/**
|
||||||
|
* The job is being executed by job processor.
|
||||||
|
*/
|
||||||
|
EXECUTING,//
|
||||||
|
/**
|
||||||
|
* he job execution has failed.
|
||||||
|
*/
|
||||||
|
FAILED,
|
||||||
|
/**
|
||||||
|
* The job is new.
|
||||||
|
*/
|
||||||
|
NEW,//
|
||||||
|
/**
|
||||||
|
* The job is submitted for execution.
|
||||||
|
*/
|
||||||
|
SUBMITTED,
|
||||||
|
/**
|
||||||
|
* The job has completed successfully
|
||||||
|
*/
|
||||||
|
SUCCEEDED,
|
||||||
|
/**
|
||||||
|
* The job execution has timed out.
|
||||||
|
*/
|
||||||
|
TIMED_OUT,
|
||||||
|
/**
|
||||||
|
* The job is waiting for available job processor.
|
||||||
|
*/
|
||||||
|
WAITING
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package org.gcube.social_networking.socialnetworking.model.beans;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class WSUnsharedFolderNotificationBean implements WorkspaceNotificationBean {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the username of the user you wish to notify
|
||||||
|
*/
|
||||||
|
@JsonProperty("userIdToNotify")
|
||||||
|
@NotNull(message="recipient cannot be missing")
|
||||||
|
private String userIdToNotify;
|
||||||
|
|
||||||
|
@JsonProperty("unsharedFolderId")
|
||||||
|
@NotNull(message="folderid cannot be missing")
|
||||||
|
private String unsharedFolderId;
|
||||||
|
|
||||||
|
@JsonProperty("unsharedFolderName")
|
||||||
|
@NotNull(message="unsharedFolderName cannot be missing")
|
||||||
|
private String unsharedFolderName;
|
||||||
|
|
||||||
|
public WSUnsharedFolderNotificationBean(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) {
|
||||||
|
super();
|
||||||
|
this.userIdToNotify = userIdToNotify;
|
||||||
|
this.unsharedFolderId = unsharedFolderId;
|
||||||
|
this.unsharedFolderName = unsharedFolderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WSUnsharedFolderNotificationBean [userIdToNotify=" + userIdToNotify + ", unsharedFolderId="
|
||||||
|
+ unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserIdToNotify() {
|
||||||
|
return userIdToNotify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIdToNotify(String userIdToNotify) {
|
||||||
|
this.userIdToNotify = userIdToNotify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnsharedFolderId() {
|
||||||
|
return unsharedFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnsharedFolderId(String unsharedFolderId) {
|
||||||
|
this.unsharedFolderId = unsharedFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnsharedFolderName() {
|
||||||
|
return unsharedFolderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnsharedFolderName(String unsharedFolderName) {
|
||||||
|
this.unsharedFolderName = unsharedFolderName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package org.gcube.social_networking.socialnetworking.model.beans;
|
package org.gcube.social_networking.socialnetworking.model.beans;
|
||||||
|
|
||||||
interface WorkspaceNotificationBean {
|
public interface WorkspaceNotificationBean {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package org.gcube.social_networking.socialnetworking.model.beans;
|
||||||
public class WorkspaceNotificationMessage {
|
public class WorkspaceNotificationMessage {
|
||||||
|
|
||||||
private WorkspaceNotificationType type;
|
private WorkspaceNotificationType type;
|
||||||
|
|
||||||
private WorkspaceNotificationBean bean;
|
private WorkspaceNotificationBean bean;
|
||||||
|
|
||||||
public WorkspaceNotificationMessage(WorkspaceNotificationType type, WorkspaceNotificationBean bean) {
|
public WorkspaceNotificationMessage(WorkspaceNotificationType type, WorkspaceNotificationBean bean) {
|
||||||
super();
|
super();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -19,7 +19,7 @@ public class WorkspaceNotificationMessage {
|
||||||
public WorkspaceNotificationBean getBean() {
|
public WorkspaceNotificationBean getBean() {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,16 @@ public enum WorkspaceNotificationType {
|
||||||
/**
|
/**
|
||||||
* use to notify a user she got a workspace item new in some of her workspace shared folder
|
* use to notify a user she got a workspace item new in some of her workspace shared folder
|
||||||
*/
|
*/
|
||||||
WP_ITEM_NEW(WSAddedItemNotificationBean.class),
|
ITEM_NEW(WSAddedItemNotificationBean.class),
|
||||||
/**
|
/**
|
||||||
* use to notify a user he got a workspace folder shared
|
* use to notify a user he got a workspace folder shared
|
||||||
*/
|
*/
|
||||||
WP_FOLDER_SHARE(WSSharedFolderNotificationBean.class);
|
FOLDER_SHARE(WSSharedFolderNotificationBean.class),
|
||||||
|
/**
|
||||||
|
* use to notify a user he got a workspace folder Unshared
|
||||||
|
*/
|
||||||
|
FOLDER_UNSHARE(WSUnsharedFolderNotificationBean.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class<? extends WorkspaceNotificationBean> beanClass;
|
Class<? extends WorkspaceNotificationBean> beanClass;
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package org.gcube.social_networking.socialnetworking.model.custom.serializers_deserializers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.JobStatusType;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializer used to map a string representing the status in this JobNotificationBean to the JobStatusType enum.
|
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
||||||
*/
|
|
||||||
public class JobStatusTypeDeserializer extends JsonDeserializer<JobStatusType>{
|
|
||||||
|
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(JobStatusTypeDeserializer.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JobStatusType deserialize(JsonParser p,
|
|
||||||
DeserializationContext ctxt) throws IOException,
|
|
||||||
JsonProcessingException {
|
|
||||||
|
|
||||||
logger.debug("Status deserializer called");
|
|
||||||
|
|
||||||
String status = p.getText();
|
|
||||||
JobStatusType toReturn = null;
|
|
||||||
|
|
||||||
logger.debug("Status coming from json object is " + status);
|
|
||||||
|
|
||||||
JobStatusType[] values = JobStatusType.values();
|
|
||||||
|
|
||||||
for (JobStatusType jobStatusType : values) {
|
|
||||||
if(jobStatusType.toString().toLowerCase().contains(status.toLowerCase())){
|
|
||||||
toReturn = jobStatusType;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("JOB STATUS deserialized as " + toReturn);
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,7 +23,6 @@ public class ResponseBean <T> implements Serializable {
|
||||||
* @param success
|
* @param success
|
||||||
* @param message
|
* @param message
|
||||||
* @param result
|
* @param result
|
||||||
* @param help
|
|
||||||
*/
|
*/
|
||||||
public ResponseBean(boolean success, String message, T result) {
|
public ResponseBean(boolean success, String message, T result) {
|
||||||
super();
|
super();
|
||||||
|
|
Loading…
Reference in New Issue