added folder unshare
This commit is contained in:
parent
fd1eb389c3
commit
be9f36822f
|
@ -3,6 +3,10 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.14.0.xsd">
|
xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.14.0.xsd">
|
||||||
<api-classes>
|
<api-classes>
|
||||||
|
<include
|
||||||
|
pattern="org.gcube.portal.social.networking.**"/>
|
||||||
|
<include
|
||||||
|
pattern="org.gcube.social_networking.socialnetworking.model.beans.**"/>
|
||||||
<exclude
|
<exclude
|
||||||
pattern="org.gcube.portal.social.networking.ws.docs.DocsGenerator" />
|
pattern="org.gcube.portal.social.networking.ws.docs.DocsGenerator" />
|
||||||
</api-classes>
|
</api-classes>
|
||||||
|
|
16
pom.xml
16
pom.xml
|
@ -73,7 +73,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.social-networking</groupId>
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
<artifactId>social-service-model</artifactId>
|
<artifactId>social-service-model</artifactId>
|
||||||
<version>[1.1.0-SNAPSHOT, 2.0.0)</version>
|
<version>[1.1.1-SNAPSHOT, 2.0.0)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sf.ehcache</groupId>
|
<groupId>net.sf.ehcache</groupId>
|
||||||
|
@ -313,7 +313,19 @@
|
||||||
<groupId>com.webcohesion.enunciate</groupId>
|
<groupId>com.webcohesion.enunciate</groupId>
|
||||||
<artifactId>enunciate-maven-plugin</artifactId>
|
<artifactId>enunciate-maven-plugin</artifactId>
|
||||||
<version>${enunciate.version}</version>
|
<version>${enunciate.version}</version>
|
||||||
<configuration></configuration>
|
<configuration>
|
||||||
|
<sourcepath-includes>
|
||||||
|
<sourcepath-include>
|
||||||
|
<!-- Include the "com.external:external" artifact on the sourcepath. -->
|
||||||
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
|
<artifactId>social-service-model</artifactId>
|
||||||
|
</sourcepath-include>
|
||||||
|
<sourcepath-include>
|
||||||
|
<groupId>org.gcube.portal</groupId>
|
||||||
|
<artifactId>social-networking-library</artifactId>
|
||||||
|
</sourcepath-include>
|
||||||
|
</sourcepath-includes>
|
||||||
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>assemble</id>
|
<id>assemble</id>
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||||
import org.gcube.common.authorization.library.utils.Caller;
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
|
||||||
import org.gcube.portal.databook.shared.Notification;
|
import org.gcube.portal.databook.shared.Notification;
|
||||||
import org.gcube.portal.notifications.bean.GenericItemBean;
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||||
import org.gcube.portal.notifications.thread.JobStatusNotificationThread;
|
import org.gcube.portal.notifications.thread.JobStatusNotificationThread;
|
||||||
|
@ -39,10 +38,11 @@ import org.gcube.portal.social.networking.ws.mappers.WorkspaceItemMapper;
|
||||||
import org.gcube.portal.social.networking.ws.outputs.ResponseBean;
|
import org.gcube.portal.social.networking.ws.outputs.ResponseBean;
|
||||||
import org.gcube.portal.social.networking.ws.utils.CassandraConnection;
|
import org.gcube.portal.social.networking.ws.utils.CassandraConnection;
|
||||||
import org.gcube.portal.social.networking.ws.utils.ErrorMessages;
|
import org.gcube.portal.social.networking.ws.utils.ErrorMessages;
|
||||||
import org.gcube.social_networking.socialnetworking.model.beans.SharedFolderBean;
|
|
||||||
import org.gcube.social_networking.socialnetworking.model.beans.WSAddedItemNotificationBean;
|
import org.gcube.social_networking.socialnetworking.model.beans.WSAddedItemNotificationBean;
|
||||||
import org.gcube.social_networking.socialnetworking.model.beans.WSSharedFolderNotificationBean;
|
import org.gcube.social_networking.socialnetworking.model.beans.WSSharedFolderNotificationBean;
|
||||||
|
import org.gcube.social_networking.socialnetworking.model.beans.WSUnsharedFolderNotificationBean;
|
||||||
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceFileItemBean;
|
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceFileItemBean;
|
||||||
|
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationBean;
|
||||||
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationMessage;
|
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationMessage;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -171,14 +171,14 @@ public class Notifications {
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("notify-ws/")
|
@Path("workspace/")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@StatusCodes ({
|
@StatusCodes ({
|
||||||
@ResponseCode ( code = 200, condition = "Workspace Notification is sent correctly"),
|
@ResponseCode ( code = 200, condition = "Workspace Notification is sent correctly"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||||
})
|
})
|
||||||
public Response notifyWs(
|
public Response workspace(
|
||||||
@NotNull(message="input is missing")
|
@NotNull(message="input is missing")
|
||||||
@Valid
|
@Valid
|
||||||
WorkspaceNotificationMessage message) throws ValidationException{
|
WorkspaceNotificationMessage message) throws ValidationException{
|
||||||
|
@ -193,19 +193,32 @@ public class Notifications {
|
||||||
|
|
||||||
ResponseBean responseBean = new ResponseBean();
|
ResponseBean responseBean = new ResponseBean();
|
||||||
Status status = Status.OK;
|
Status status = Status.OK;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
||||||
|
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByEmail(LiferayJSONWsCredentials.getSingleton().getUser());
|
||||||
|
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
||||||
|
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
||||||
switch (message.getType()) {
|
switch (message.getType()) {
|
||||||
case WP_ITEM_NEW:
|
case ITEM_NEW: {
|
||||||
WSAddedItemNotificationBean wpItemBean = (WSAddedItemNotificationBean) message.getBean();
|
WSAddedItemNotificationBean itemBean = (WSAddedItemNotificationBean) message.getBean();
|
||||||
GCubeUser userRecipient = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(wpItemBean.getUserIdToNotify());
|
String userIdToNotify = itemBean.getUserIdToNotify();
|
||||||
// notifications are sent by using the user allowed to use liferay's json apis
|
nm.notifyAddedItem(userIdToNotify, WorkspaceItemMapper.getFileItem(itemBean.getItem()), WorkspaceItemMapper.getSharedFolder(itemBean.getFolder()));
|
||||||
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
|
||||||
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByEmail(LiferayJSONWsCredentials.getSingleton().getUser());
|
|
||||||
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
|
||||||
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
|
||||||
nm.notifyAddedItem(context, WorkspaceItemMapper.getFileItem(wpItemBean.getItem()), WorkspaceItemMapper.getSharedFolder(wpItemBean.getFolder()));
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case FOLDER_SHARE: {
|
||||||
|
WSSharedFolderNotificationBean itemBean = (WSSharedFolderNotificationBean) message.getBean();
|
||||||
|
String userIdToNotify = itemBean.getUserIdToNotify();
|
||||||
|
nm.notifyFolderSharing(userIdToNotify, WorkspaceItemMapper.getSharedFolder(itemBean.getFolder()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FOLDER_UNSHARE: {
|
||||||
|
WSUnsharedFolderNotificationBean itemBean = (WSUnsharedFolderNotificationBean) message.getBean();
|
||||||
|
String userIdToNotify = itemBean.getUserIdToNotify();
|
||||||
|
nm.notifyFolderUnsharing(userIdToNotify, itemBean.getUnsharedFolderId(), itemBean.getUnsharedFolderName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -220,50 +233,4 @@ public class Notifications {
|
||||||
return Response.status(status).entity(responseBean).build();
|
return Response.status(status).entity(responseBean).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a Workspace notification to a given user
|
|
||||||
* @param userIdToNotify the user you want to notify
|
|
||||||
* @param newItem the new shared {@link SocialFileItem} instance
|
|
||||||
* @param sharedFolder the shared folder {@link SocialSharedFolder} instance
|
|
||||||
* @return
|
|
||||||
* @throws ValidationException
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Path("notify-ws-item-new/")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@StatusCodes ({
|
|
||||||
@ResponseCode ( code = 200, condition = "Workspace Notification is sent correctly"),
|
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
|
||||||
})
|
|
||||||
public Response notifyWsItemNew(
|
|
||||||
@NotNull(message="input is missing")
|
|
||||||
@Valid
|
|
||||||
String userIdToNotify,
|
|
||||||
@NotNull(message="input is missing")
|
|
||||||
@Valid
|
|
||||||
WorkspaceFileItemBean fileItem) throws ValidationException{
|
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
|
||||||
String context = ScopeProvider.instance.get();
|
|
||||||
ResponseBean responseBean = new ResponseBean();
|
|
||||||
Status status = Status.OK;
|
|
||||||
|
|
||||||
try{
|
|
||||||
// notifications are sent by using the user allowed to use liferay's json apis
|
|
||||||
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
|
||||||
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByEmail(LiferayJSONWsCredentials.getSingleton().getUser());
|
|
||||||
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
|
||||||
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
|
||||||
nm.notifyAddedItem(context, WorkspaceItemMapper.getFileItem(fileItem), WorkspaceItemMapper.getSharedFolder(fileItem.getParent()));
|
|
||||||
} catch(Exception e){
|
|
||||||
logger.error("Unable to send job notification", e);
|
|
||||||
responseBean.setSuccess(false);
|
|
||||||
responseBean.setMessage(e.getMessage());
|
|
||||||
status = Status.INTERNAL_SERVER_ERROR;
|
|
||||||
}
|
|
||||||
return Response.status(status).entity(responseBean).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue