Costantino Perciante 2017-10-21 20:34:40 +00:00
commit 5cd76f214d
18 changed files with 927 additions and 0 deletions

26
.classpath Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" 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="src" output="target/test-classes" path="src/test/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"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>social-networking-service-model</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

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

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

1
distro/LICENSE Normal file
View File

@ -0,0 +1 @@
${gcube.license}

62
distro/README Normal file
View File

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

6
distro/changelog.xml Normal file
View File

@ -0,0 +1,6 @@
<ReleaseNotes>
<Changeset component="org.gcube.portal.social-networking-service-model.1-0-0"
date="2017-11-21">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

31
distro/descriptor.xml Normal file
View File

@ -0,0 +1,31 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

25
distro/profile.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>${description}</Description>
<Class>Portal</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.war</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

181
pom.xml Normal file
View File

@ -0,0 +1,181 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-service-model</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>social-networking-service-model</name>
<description>Social networking service model classes</description>
<properties>
<java-version>1.7</java-version>
<version.jersey>2.25.1</version.jersey>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<distroDirectory>distro</distroDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-smartgears-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</url>
</scm>
<dependencies>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>${version.jersey}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${version.jersey}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${version.jersey}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<!-- <descriptorRefs> -->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
<!-- </descriptorRefs> -->
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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 + "]";
}
}

View File

@ -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
: "") + "]";
}
}

View File

@ -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<Recipient> recipients;
public MessageInputBean() {
super();
}
public MessageInputBean(String sender, String body, String subject,
ArrayList<Recipient> 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<Recipient> getRecipients() {
return recipients;
}
public void setRecipients(ArrayList<Recipient> recipients) {
this.recipients = recipients;
}
@Override
public String toString() {
return "MessageInputBean ["
+ (body != null ? "body=" + body + ", " : "")
+ (subject != null ? "subject=" + subject + ", " : "")
+ (recipients != null ? "recipients=" + recipients : "") + "]";
}
}

View File

@ -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 + "]";
}
}

View File

@ -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 + "]";
}
}

View File

@ -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 + "]";
}
}

View File

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