refactored workspace classes

This commit is contained in:
Massimiliano Assante 2022-05-04 11:28:38 +02:00
parent 92bb73c8f9
commit 470cd59192
2 changed files with 16 additions and 16 deletions

View File

@ -2,8 +2,8 @@ package org.gcube.portal.social.networking.ws.mappers;
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceFolderBean;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceFileItemBean;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.FileItemBean;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.FolderBean;
public class WorkspaceItemMapper {
@ -11,7 +11,7 @@ public class WorkspaceItemMapper {
// TODO Auto-generated constructor stub
}
public static SocialFileItem getFileItem(WorkspaceFileItemBean item) {
public static SocialFileItem getFileItem(FileItemBean item) {
String id = null;
String name= null;
String title= null;
@ -31,7 +31,7 @@ public class WorkspaceItemMapper {
return toReturn;
}
public static SocialSharedFolder getSharedFolder(WorkspaceFolderBean item) {
public static SocialSharedFolder getSharedFolder(FolderBean item) {
String id = null;
String name= null;

View File

@ -38,10 +38,10 @@ 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.ErrorMessages;
import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotification;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationAddedItem;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationSharedFolder;
import org.gcube.social_networking.socialnetworking.model.beans.WorkspaceNotificationUnsharedFolder;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.WorkspaceEvent;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.AddedItemEvent;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.SharedFolderEvent;
import org.gcube.social_networking.socialnetworking.model.beans.workspace.UnsharedFolderEvent;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.LoggerFactory;
@ -166,7 +166,7 @@ public class Notifications {
/**
* Send a Workspace notification to a given user
* @param message
* @param event
* @return
* @throws ValidationException
*/
@ -181,7 +181,7 @@ public class Notifications {
public Response workspace(
@NotNull(message="input is missing")
@Valid
WorkspaceNotification message) throws ValidationException{
WorkspaceEvent event) throws ValidationException{
Caller caller = AuthorizationProvider.instance.get();
String context = ScopeProvider.instance.get();
@ -189,7 +189,7 @@ public class Notifications {
logger.debug("workspace notifications from user = " + username);
if (!message.getType().getNotificationClass().isInstance(message)) {
if (!event.getType().getNotificationClass().isInstance(WorkspaceEvent.class)) {
//invalid call
return Response.status(Status.BAD_REQUEST).build();
}
@ -198,28 +198,28 @@ public class Notifications {
Status status = Status.OK;
try {
logger.debug("workspace notifications type is " + message.getType());
logger.debug("workspace notifications type is " + event.getType());
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(username);
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 (event.getType()) {
case ITEM_NEW: {
WorkspaceNotificationAddedItem itemBean = (WorkspaceNotificationAddedItem) message;
AddedItemEvent itemBean = (AddedItemEvent) event;
String userIdToNotify = itemBean.getUserIdToNotify();
nm.notifyAddedItem(userIdToNotify, WorkspaceItemMapper.getFileItem(itemBean.getItem()), WorkspaceItemMapper.getSharedFolder(itemBean.getItem().getParent()));
break;
}
case FOLDER_SHARE: {
WorkspaceNotificationSharedFolder itemBean = (WorkspaceNotificationSharedFolder) message;
SharedFolderEvent itemBean = (SharedFolderEvent) event;
String userIdToNotify = itemBean.getUserIdToNotify();
nm.notifyFolderSharing(userIdToNotify, WorkspaceItemMapper.getSharedFolder(itemBean.getFolder()));
break;
}
case FOLDER_UNSHARE: {
WorkspaceNotificationUnsharedFolder itemBean = (WorkspaceNotificationUnsharedFolder) message;
UnsharedFolderEvent itemBean = (UnsharedFolderEvent) event;
String userIdToNotify = itemBean.getUserIdToNotify();
nm.notifyFolderUnsharing(userIdToNotify, itemBean.getUnsharedFolderId(), itemBean.getUnsharedFolderName());
break;