From 1dbc072f16db5e1aaa955643552e0d52a0c694c8 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 16 Feb 2018 17:41:59 +0000 Subject: [PATCH] minor fixes git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/social-networking/social-networking-service-model@163345 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 2 +- .project | 4 +- .settings/org.eclipse.jdt.core.prefs | 6 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- .settings/org.eclipse.wst.validation.prefs | 2 + pom.xml | 19 ++++-- .../model/input/ApplicationId.java | 4 ++ .../model/input/JobNotificationBean.java | 24 ++++--- .../model/input/MessageInputBean.java | 12 ++-- .../model/input/PostInputBean.java | 4 ++ .../model/input/Recipient.java | 4 ++ .../model/output/MessageOutputBeanMixIn.java | 62 +++++++++++++++++++ .../model/output/ResponseBean.java | 14 ++--- 13 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 .settings/org.eclipse.wst.validation.prefs create mode 100644 src/main/java/org/gcube/portal/socialnetworking/model/output/MessageOutputBeanMixIn.java diff --git a/.classpath b/.classpath index 5cca4e3..7f8784a 100644 --- a/.classpath +++ b/.classpath @@ -18,7 +18,7 @@ - + diff --git a/.project b/.project index ad63406..a3ff8da 100644 --- a/.project +++ b/.project @@ -16,12 +16,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 443e085..6e80039 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +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.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 1b22d70..f4bf050 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml index 42fdfd7..15cd36d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 1.7 - 2.25.1 + 2.9 social-networking ${project.basedir}/distro ${project.build.directory}/${project.build.finalName} @@ -37,6 +37,13 @@ pom import + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + @@ -50,7 +57,11 @@ org.gcube.portal social-networking-library - [1.0.0-SNAPSHOT,) + provided + + + org.gcube.common + home-library provided @@ -96,10 +107,6 @@ maven-compiler-plugin - - 1.7 - 1.7 - diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/input/ApplicationId.java b/src/main/java/org/gcube/portal/socialnetworking/model/input/ApplicationId.java index 49648b0..90fc22d 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/input/ApplicationId.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/ApplicationId.java @@ -16,6 +16,10 @@ public class ApplicationId { @NotNull(message="app_id cannot be null") @Size(message="app_id cannot be empty", min=1) private String appId; + + public ApplicationId() { + super(); + } public ApplicationId(String appId) { super(); diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/input/JobNotificationBean.java b/src/main/java/org/gcube/portal/socialnetworking/model/input/JobNotificationBean.java index 71fcbce..b134b49 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/input/JobNotificationBean.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/JobNotificationBean.java @@ -6,6 +6,7 @@ import org.gcube.portal.databook.shared.JobStatusType; import org.gcube.portal.databook.shared.RunningJob; import org.gcube.portal.socialnetworking.model.providers.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; @@ -29,19 +30,23 @@ public class JobNotificationBean { @JsonProperty("job_name") @NotNull(message="job_name cannot be missing") private String jobName; - + @JsonProperty("service_name") @NotNull(message="service_name cannot be missing") private String serviceName; @JsonProperty("status") - @JsonDeserialize(using=JobStatusTypeDeserializer.class) + @JsonDeserialize(using=JobStatusTypeDeserializer.class) @NotNull(message="status cannot be missing") private JobStatusType status; @JsonProperty("status_message") private String statusMessage; - + + public JobNotificationBean() { + super(); + } + /** * @param recipient * @param jobId @@ -108,11 +113,12 @@ public class JobNotificationBean { public void setStatus(JobStatusType status) { this.status = status; } - + + @JsonIgnore public RunningJob getRunningJob(){ - + return new RunningJob(jobId, jobName, status, statusMessage, serviceName); - + } @Override @@ -123,8 +129,8 @@ public class JobNotificationBean { + (jobName != null ? "jobName=" + jobName + ", " : "") + (serviceName != null ? "serviceName=" + serviceName + ", " : "") - + (status != null ? "status=" + status + ", " : "") - + (statusMessage != null ? "statusMessage=" + statusMessage - : "") + "]"; + + (status != null ? "status=" + status + ", " : "") + + (statusMessage != null ? "statusMessage=" + statusMessage + : "") + "]"; } } diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/input/MessageInputBean.java b/src/main/java/org/gcube/portal/socialnetworking/model/input/MessageInputBean.java index 74b9069..6681a31 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/input/MessageInputBean.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/MessageInputBean.java @@ -19,14 +19,6 @@ public class MessageInputBean implements Serializable { private static final long serialVersionUID = -1317811686036127456L; - /*@JsonProperty("sender") - @ApiModelProperty( - example="andrea.rossi", - required=false, - hidden=true, // do not show this information - value="The sender of the message. If not specified is the gcube-token's owner") - private String sender;*/ - @JsonProperty("body") @NotNull(message="body cannot be missing") @Size(min=1, message="body cannot be empty") @@ -42,6 +34,10 @@ public class MessageInputBean implements Serializable { @Size(min=1, message="at least a recipient is needed") @Valid // validate recursively private ArrayList recipients; + + public MessageInputBean(){ + super(); + } public MessageInputBean(String body, String subject, ArrayList recipients) { diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/input/PostInputBean.java b/src/main/java/org/gcube/portal/socialnetworking/model/input/PostInputBean.java index ee85f62..73a0d34 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/input/PostInputBean.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/PostInputBean.java @@ -41,6 +41,10 @@ public class PostInputBean implements Serializable{ @JsonProperty("params") private String params; + + public PostInputBean(){ + super(); + } public PostInputBean(String text, String previewtitle, String previewdescription, String previewhost, String previewurl, diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/input/Recipient.java b/src/main/java/org/gcube/portal/socialnetworking/model/input/Recipient.java index 5534f0a..db9cfe5 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/input/Recipient.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/Recipient.java @@ -23,6 +23,10 @@ public class Recipient implements Serializable{ @NotNull(message="recipient id must not be null") @Size(min=1, message="recipient id must not be empty") private String id; + + public Recipient(){ + super(); + } public Recipient(String id) { super(); diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/output/MessageOutputBeanMixIn.java b/src/main/java/org/gcube/portal/socialnetworking/model/output/MessageOutputBeanMixIn.java new file mode 100644 index 0000000..6d3b61b --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/output/MessageOutputBeanMixIn.java @@ -0,0 +1,62 @@ +package org.gcube.portal.socialnetworking.model.output; + +import java.util.Calendar; +import java.util.List; + +import javax.jcr.ItemNotFoundException; + +import org.gcube.common.homelibrary.home.User; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Used for serialization/deserialization of {@link org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage} + * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + */ +public interface MessageOutputBeanMixIn { + + @JsonProperty("id") + String getId(); + + @JsonProperty("subject") + String getSubject(); + + @JsonProperty("body") + String getBody(); + + @JsonProperty("sender") + User getSender(); + + @JsonProperty("send_time") + Calendar getSendTime(); + + @JsonProperty("read") + boolean isRead(); + + @JsonIgnore + void setStatus(boolean status) throws InternalErrorException; + + @JsonProperty("attachments_ids") + List getAttachmentsIds(); + + @JsonIgnore + List getAttachments() throws InternalErrorException; + + @JsonIgnore + WorkspaceItem saveAttachment(String attachmentId, String destinationFolderId) + throws InternalErrorException, WrongDestinationException, + ItemNotFoundException; + + @JsonIgnore + void open() throws InternalErrorException; + + @JsonProperty("recipients") + List getAddresses(); + + @JsonIgnore + List getCopyAttachmentsIds(); + +} diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/output/ResponseBean.java b/src/main/java/org/gcube/portal/socialnetworking/model/output/ResponseBean.java index b8a9bcc..070b5e0 100644 --- a/src/main/java/org/gcube/portal/socialnetworking/model/output/ResponseBean.java +++ b/src/main/java/org/gcube/portal/socialnetworking/model/output/ResponseBean.java @@ -3,19 +3,17 @@ package org.gcube.portal.socialnetworking.model.output; import java.io.Serializable; /** - * Response bean + * Response bean with real result of type T. * @author Costantino Perciante at ISTI-CNR * (costantino.perciante@isti.cnr.it) */ -public class ResponseBean implements Serializable { +public class ResponseBean implements Serializable { private static final long serialVersionUID = -2725238162673879658L; private boolean success; - private String message; - - private Object result; + private T result; public ResponseBean() { super(); @@ -27,7 +25,7 @@ public class ResponseBean implements Serializable { * @param result * @param help */ - public ResponseBean(boolean success, String message, Object result) { + public ResponseBean(boolean success, String message, T result) { super(); this.success = success; this.message = message; @@ -55,12 +53,12 @@ public class ResponseBean implements Serializable { } - public Object getResult() { + public T getResult() { return result; } - public void setResult(Object result) { + public void setResult(T result) { this.result = result; }