commit 5cd76f214d115295c840a4dcbc3aaccbe0b3b75a Author: Costantino Perciante Date: Sat Oct 21 20:34:40 2017 +0000 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/social-networking/social-networking-service-model@157437 82a268e6-3cf1-43bd-a215-b396298e98cf diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..79174f7 --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..2f9e9ae --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + social-networking-service-model + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..f9fe345 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..2d9616a --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1 @@ +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..fc6be41 --- /dev/null +++ b/distro/README @@ -0,0 +1,62 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Costantino Perciante (costantino.perciante@isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Maintainers +----------- + +* Costantino Perciante (costantino.perciante@isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot} + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot} + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. \ No newline at end of file diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..4613c9b --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,6 @@ + + + First Release + + diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..b3f5628 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,31 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + changelog.xml + profile.xml + + 755 + true + + + + + target/${build.finalName}.${project.packaging} + /${artifactId} + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..4dda0b9 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,25 @@ + + + + Library + + ${description} + Portal + ${artifactId} + 1.0.0 + + + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + + ${build.finalName}.war + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3da8b96 --- /dev/null +++ b/pom.xml @@ -0,0 +1,181 @@ + + + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + + + org.gcube.portal + social-networking-service-model + 1.0.0-SNAPSHOT + jar + social-networking-service-model + Social networking service model classes + + + 1.7 + 2.25.1 + ${project.basedir}/distro + ${project.build.directory}/${project.build.finalName} + distro + UTF-8 + UTF-8 + + + + + + org.gcube.distribution + maven-smartgears-bom + LATEST + pom + import + + + + + + scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} + http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} + + + + + org.gcube.portal + social-networking-library + [1.0.0-SNAPSHOT,) + provided + + + org.slf4j + slf4j-api + provided + + + org.glassfish.jersey.ext + jersey-bean-validation + ${version.jersey} + provided + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${version.jersey} + provided + + + org.glassfish.jersey.core + jersey-client + ${version.jersey} + provided + + + junit + junit + 4.11 + test + + + + + + + src/main/java + + **/*.* + + + + + + maven-compiler-plugin + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + test-jar + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + true + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + fully.qualified.MainClass + + + + + + + + + servicearchive + install + + single + + + + + + + + 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 new file mode 100644 index 0000000..0d674a5 --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/ApplicationId.java @@ -0,0 +1,41 @@ +package org.gcube.portal.socialnetworking.model.input; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + * Application id object + * @author Costantino Perciante at ISTI-CNR + */ +public class ApplicationId { + + @JsonProperty("app_id") + @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(); + this.appId = appId; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + @Override + public String toString() { + return "ApplicationId [appId=" + appId + "]"; + } +} 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 new file mode 100644 index 0000000..41b9313 --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/JobNotificationBean.java @@ -0,0 +1,134 @@ +package org.gcube.portal.socialnetworking.model.input; + +import javax.validation.constraints.NotNull; + +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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The job notification bean class. + * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + */ +@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization +public class JobNotificationBean { + + @JsonProperty("recipient") + @NotNull(message="recipient cannot be missing") + private String recipient; + + @JsonProperty("job_id") + @NotNull(message="job_id cannot be missing") + private String jobId; + + @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) + @NotNull(message="status cannot be missing") + private JobStatusType status; + + @JsonProperty("status_message") + private String statusMessage; + + public JobNotificationBean() { + super(); + } + + /** + * @param recipient + * @param jobId + * @param jobName + * @param serviceName + * @param status + * @param statusMessage + */ + public JobNotificationBean(String recipient, String jobId, String jobName, + String serviceName, JobStatusType status, String statusMessage) { + super(); + this.recipient = recipient; + this.jobId = jobId; + this.jobName = jobName; + this.serviceName = serviceName; + this.status = status; + this.statusMessage = statusMessage; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public String getRecipient() { + return recipient; + } + + public void setRecipient(String recipient) { + this.recipient = recipient; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } + + public JobStatusType getStatus() { + return status; + } + + public void setStatus(JobStatusType status) { + this.status = status; + } + + public RunningJob getRunningJob(){ + + return new RunningJob(jobId, jobName, status, statusMessage, serviceName); + + } + + @Override + public String toString() { + return "JobNotificationBean [" + + (recipient != null ? "recipient=" + recipient + ", " : "") + + (jobId != null ? "jobId=" + jobId + ", " : "") + + (jobName != null ? "jobName=" + jobName + ", " : "") + + (serviceName != null ? "serviceName=" + serviceName + ", " + : "") + + (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 new file mode 100644 index 0000000..4d6864d --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/MessageInputBean.java @@ -0,0 +1,86 @@ +package org.gcube.portal.socialnetworking.model.input; + +import java.io.Serializable; +import java.util.ArrayList; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Generic input bean for methods that allow to write messages + * @author Costantino Perciante at ISTI-CNR + */ +@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization +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") + private String body; + + @JsonProperty("subject") + @NotNull(message="subject cannot be missing") + @Size(min=1, message="subject cannot be empty") + private String subject; + + @JsonProperty("recipients") + @NotNull(message="recipients cannot be missing") + @Size(min=1, message="at least a recipient is needed") + @Valid // validate recursively + private ArrayList recipients; + + public MessageInputBean() { + super(); + } + + public MessageInputBean(String sender, String body, String subject, + ArrayList recipients) { + super(); + //this.sender = sender; + this.body = body; + this.subject = subject; + this.recipients = recipients; + } + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public ArrayList getRecipients() { + return recipients; + } + public void setRecipients(ArrayList recipients) { + this.recipients = recipients; + } + + @Override + public String toString() { + return "MessageInputBean [" + + (body != null ? "body=" + body + ", " : "") + + (subject != null ? "subject=" + subject + ", " : "") + + (recipients != null ? "recipients=" + 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 new file mode 100644 index 0000000..843aa65 --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/PostInputBean.java @@ -0,0 +1,136 @@ +package org.gcube.portal.socialnetworking.model.input; + +import java.io.Serializable; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Generic input bean for methods that allow to write posts + * @author Costantino Perciante at ISTI-CNR + */ +@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization +public class PostInputBean implements Serializable{ + + private static final long serialVersionUID = 5274608088828232980L; + + @JsonProperty("text") + @NotNull(message="text cannot be null") + @Size(min=1, message="text cannot be empty") + private String text; + + @JsonProperty("preview_title") + private String previewtitle; + + @JsonProperty("preview_description") + private String previewdescription; + + @JsonProperty("preview_host") + private String previewhost; + + @JsonProperty("preview_url") + private String previewurl; + + @JsonProperty("image_url") + private String httpimageurl; + + @JsonProperty("enable_notification") + private boolean enablenotification; + + @JsonProperty("params") + private String params; + + public PostInputBean() { + super(); + } + + public PostInputBean(String text, String previewtitle, + String previewdescription, String previewhost, String previewurl, + String httpimageurl, boolean enablenotification, String params) { + super(); + this.text = text; + this.previewtitle = previewtitle; + this.previewdescription = previewdescription; + this.previewhost = previewhost; + this.previewurl = previewurl; + this.httpimageurl = httpimageurl; + this.enablenotification = enablenotification; + this.params = params; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getPreviewtitle() { + return previewtitle; + } + + public void setPreviewtitle(String previewtitle) { + this.previewtitle = previewtitle; + } + + public String getPreviewdescription() { + return previewdescription; + } + + public void setPreviewdescription(String previewdescription) { + this.previewdescription = previewdescription; + } + + public String getPreviewhost() { + return previewhost; + } + + public void setPreviewhost(String previewhost) { + this.previewhost = previewhost; + } + + public String getPreviewurl() { + return previewurl; + } + + public void setPreviewurl(String previewurl) { + this.previewurl = previewurl; + } + + public String getHttpimageurl() { + return httpimageurl; + } + + public void setHttpimageurl(String httpimageurl) { + this.httpimageurl = httpimageurl; + } + + public boolean isEnablenotification() { + return enablenotification; + } + + public void setEnablenotification(boolean enablenotification) { + this.enablenotification = enablenotification; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + @Override + public String toString() { + return "PostInputBean [text=" + text + ", previewtitle=" + previewtitle + + ", previewdescription=" + previewdescription + + ", previewhost=" + previewhost + ", previewurl=" + previewurl + + ", httpimageurl=" + httpimageurl + ", enablenotification=" + + enablenotification + ", params=" + params + "]"; + } + +} 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 new file mode 100644 index 0000000..5f59228 --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/input/Recipient.java @@ -0,0 +1,44 @@ +package org.gcube.portal.socialnetworking.model.input; + +import java.io.Serializable; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Recipient message bean + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization +public class Recipient implements Serializable{ + + private static final long serialVersionUID = 1071412144446514138L; + + @JsonProperty("id") + @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(); + this.id = id; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + @Override + public String toString() { + return "Recipient [id=" + id + "]"; + } +} 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 new file mode 100644 index 0000000..b8a9bcc --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/output/ResponseBean.java @@ -0,0 +1,72 @@ +package org.gcube.portal.socialnetworking.model.output; + +import java.io.Serializable; + +/** + * Response bean + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + */ +public class ResponseBean implements Serializable { + + private static final long serialVersionUID = -2725238162673879658L; + + private boolean success; + + private String message; + + private Object result; + + public ResponseBean() { + super(); + } + + /** + * @param success + * @param message + * @param result + * @param help + */ + public ResponseBean(boolean success, String message, Object result) { + super(); + this.success = success; + this.message = message; + this.result = result; + } + + + public boolean isSuccess() { + return success; + } + + + public void setSuccess(boolean success) { + this.success = success; + } + + + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public Object getResult() { + return result; + } + + + public void setResult(Object result) { + this.result = result; + } + + @Override + public String toString() { + return "ResponseBean [success=" + success + + ", message=" + message + ", result=" + result + "]"; + } +} diff --git a/src/main/java/org/gcube/portal/socialnetworking/model/providers/JobStatusTypeDeserializer.java b/src/main/java/org/gcube/portal/socialnetworking/model/providers/JobStatusTypeDeserializer.java new file mode 100644 index 0000000..dd16f76 --- /dev/null +++ b/src/main/java/org/gcube/portal/socialnetworking/model/providers/JobStatusTypeDeserializer.java @@ -0,0 +1,46 @@ +package org.gcube.portal.socialnetworking.model.providers; + +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{ + + 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; + } + +} \ No newline at end of file