revised job notifications

This commit is contained in:
Massimiliano Assante 2022-04-27 18:29:47 +02:00
parent a0432fed4d
commit 593644b9ec
10 changed files with 147 additions and 101 deletions

View File

@ -1,8 +1,12 @@
# Changelog
## [v1.1.1-SNAPSHOT] - 2022-04-21
- Partially added support for workspace notifications
## [v1.0.0] - 2022-04-05
First release
- First release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

43
pom.xml
View File

@ -1,5 +1,7 @@
<?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>
<parent>
@ -10,7 +12,7 @@
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-model</artifactId>
<version>1.0.0</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>social-networking-service-model</name>
<description>Social networking service model classes</description>
@ -18,6 +20,7 @@
<properties>
<java-version>1.8</java-version>
<version.jersey>2.9</version.jersey>
<enunciate.version>2.14.0</enunciate.version>
<gCubeSubsystem>social-networking</gCubeSubsystem>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -51,12 +54,7 @@
</scm>
<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>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-model</artifactId>
@ -90,35 +88,26 @@
</dependency>
</dependencies>
<build>
<finalName>${name}</finalName>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<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>
<execution>
<id>generate-doc</id>
<phase>install</phase>
<goals>
<goal>test-jar</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
</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>
</build>
</project>

View File

@ -2,14 +2,8 @@ package org.gcube.social_networking.socialnetworking.model.beans;
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.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
/**
@ -36,9 +30,8 @@ public class JobNotificationBean {
private String serviceName;
@JsonProperty("status")
@JsonDeserialize(using=JobStatusTypeDeserializer.class)
@NotNull(message="status cannot be missing")
private JobStatusType status;
private JobStatusModelType status;
@JsonProperty("status_message")
private String statusMessage;
@ -56,7 +49,7 @@ public class JobNotificationBean {
* @param statusMessage
*/
public JobNotificationBean(String recipient, String jobId, String jobName,
String serviceName, JobStatusType status, String statusMessage) {
String serviceName, JobStatusModelType status, String statusMessage) {
super();
this.recipient = recipient;
this.jobId = jobId;
@ -106,21 +99,14 @@ public class JobNotificationBean {
this.jobName = jobName;
}
public JobStatusType getStatus() {
public JobStatusModelType getStatus() {
return status;
}
public void setStatus(JobStatusType status) {
public void setStatus(JobStatusModelType status) {
this.status = status;
}
@JsonIgnore
public RunningJob getRunningJob(){
return new RunningJob(jobId, jobName, status, statusMessage, serviceName);
}
@Override
public String toString() {
return "JobNotificationBean ["

View File

@ -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
}

View File

@ -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;
}
}

View File

@ -1,5 +1,5 @@
package org.gcube.social_networking.socialnetworking.model.beans;
interface WorkspaceNotificationBean {
public interface WorkspaceNotificationBean {
}

View File

@ -3,9 +3,9 @@ package org.gcube.social_networking.socialnetworking.model.beans;
public class WorkspaceNotificationMessage {
private WorkspaceNotificationType type;
private WorkspaceNotificationBean bean;
public WorkspaceNotificationMessage(WorkspaceNotificationType type, WorkspaceNotificationBean bean) {
super();
this.type = type;
@ -19,7 +19,7 @@ public class WorkspaceNotificationMessage {
public WorkspaceNotificationBean getBean() {
return bean;
}
}

View File

@ -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
*/
WP_ITEM_NEW(WSAddedItemNotificationBean.class),
ITEM_NEW(WSAddedItemNotificationBean.class),
/**
* 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;

View File

@ -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;
}
}

View File

@ -23,7 +23,6 @@ public class ResponseBean <T> implements Serializable {
* @param success
* @param message
* @param result
* @param help
*/
public ResponseBean(boolean success, String message, T result) {
super();