added unshare folder handling and quotes for file names and folders

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@100267 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-09-29 16:47:23 +00:00
parent 46e07fafeb
commit 7431c1575e
4 changed files with 47 additions and 14 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>0.12.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Social Portal ASL Extension</name>
<description>

View File

@ -132,10 +132,31 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
UUID.randomUUID().toString(),
NotificationType.WP_FOLDER_SHARE,
userIdToNotify, //user no notify
sharedFolder.getId(), //the
sharedFolder.getId(),
new Date(),
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"shared the workspace folder "+ sharedFolderName +" with you",
"shared the workspace folder \""+ sharedFolderName +"\" with you",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
aslSession.getUserAvatarId());
return saveNotification(not);
}
/**
* {@inheritDoc}
* @throws Exception
*/
@Override
public boolean notifyFolderUnsharing(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) throws Exception {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.WP_FOLDER_UNSHARE,
userIdToNotify, //user no notify
unsharedFolderId,
new Date(),
getApplicationUrl()+"?itemid="+unsharedFolderId,
"unshared the workspace folder \""+ unsharedFolderName+"\"",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
@ -156,7 +177,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
renamedFolderId, //the
new Date(),
getApplicationUrl()+"?itemid="+renamedFolderId,
"renamed your shared folder "+ previousName +" as " + newName,
"renamed your shared folder \""+ previousName +"\" as \"" + newName+"\"",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
@ -181,7 +202,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
sharedFolder.getId(), //the
new Date(),
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"added "+ user.getFullname() +" to your workspace shared folder "+ sharedFolder.getName(),
"added "+ user.getFullname() +" to your workspace shared folder \""+ sharedFolder.getName()+"\"",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
@ -212,7 +233,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
sharedFolder.getId(), //the
new Date(),
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"added "+ addedUsersFullNames +" to your workspace shared folder "+ sharedFolder.getName(),
"added "+ addedUsersFullNames +" to your workspace shared folder \""+ sharedFolder.getName()+"\"",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
@ -235,7 +256,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
sharedFolder.getId(), //the
new Date(),
getApplicationUrl()+"?itemid="+sharedFolder.getId(),
"unshared his shared folder "+ sharedFolder.getName() + " from your workspace",
"unshared his shared folder \""+ sharedFolder.getName() + "\" from your workspace",
false,
aslSession.getUsername(),
aslSession.getUserFullName(),
@ -275,7 +296,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
@Override
public boolean notifyMovedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
String notifyText = sharedFolder.isVreFolder() ? "removed item "+ item.getName() +" from the workspace group folder " + sharedFolder.getDisplayName():
"removed item "+ item.getName() +" from your workspace shared folder "+ sharedFolder.getName();
"removed item "+ item.getName() +" from your workspace shared folder \""+ sharedFolder.getName()+"\"";
Notification not = new Notification(
UUID.randomUUID().toString(),
@ -298,8 +319,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*/
@Override
public boolean notifyRemovedItem(String userIdToNotify, String itemName, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
String notifyText = sharedFolder.isVreFolder() ? "deleted item "+ itemName +" from the workspace group folder " + sharedFolder.getDisplayName():
" deleted item "+ itemName +" from your workspace shared folder "+ sharedFolder.getName();
String notifyText = sharedFolder.isVreFolder() ? "deleted item \""+ itemName +"\" from the workspace group folder " + sharedFolder.getDisplayName():
" deleted item \""+ itemName +"\" from your workspace shared folder \""+ sharedFolder.getName()+"\"";
Notification not = new Notification(
UUID.randomUUID().toString(),
@ -322,8 +343,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*/
@Override
public boolean notifyUpdatedItem(String userIdToNotify, WorkspaceItem item, WorkspaceSharedFolder sharedFolder) throws InternalErrorException {
String notifyText = sharedFolder.isVreFolder() ? " updated "+ item.getName() +" from the workspace group folder " + sharedFolder.getDisplayName():
" updated "+ item.getName() +" to your workspace shared folder "+ item.getPath().substring(0,item.getPath().lastIndexOf('/'));
String notifyText = sharedFolder.isVreFolder() ? " updated \""+ item.getName() +"\" from the workspace group folder \"" + sharedFolder.getDisplayName()+"\"":
" updated \""+ item.getName() +"\" to your workspace shared folder \""+ item.getPath().substring(0,item.getPath().lastIndexOf('/'))+"\"";
Notification not = new Notification(
UUID.randomUUID().toString(),
@ -346,8 +367,8 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
*/
@Override
public boolean notifyItemRenaming(String userIdToNotify, String previousName, WorkspaceItem renamedItem, WorkspaceSharedFolder rootSharedFolder) throws InternalErrorException {
String notifyText = rootSharedFolder.isVreFolder() ? "renamed "+ previousName +" as " + renamedItem.getName() +" in the workspace group folder " + rootSharedFolder.getDisplayName():
"renamed " + previousName +" as " + renamedItem.getName() +" in your shared folder " + renamedItem.getPath().substring(0, renamedItem.getPath().lastIndexOf('/'));
String notifyText = rootSharedFolder.isVreFolder() ? "renamed \""+ previousName +"\" as \"" + renamedItem.getName() +"\" in the workspace group folder " + rootSharedFolder.getDisplayName():
"renamed \"" + previousName +"\" as \"" + renamedItem.getName() +"\" in your shared folder \"" + renamedItem.getPath().substring(0, renamedItem.getPath().lastIndexOf('/'))+"\"";
Notification not = new Notification(
UUID.randomUUID().toString(),
@ -796,5 +817,6 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
_log.debug("Returning SENDER_EMAIL: " + toReturn );
return toReturn;
}
}

View File

@ -22,6 +22,15 @@ public interface NotificationsManager {
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderSharing(String userIdToNotify, WorkspaceSharedFolder sharedFolder) throws Exception;
/**
* use to notify a user he got a workspace folder shared
*
* @param userIdToNotify the user you want to notify
* @param unsharedFolderId the unshared folder id
* @param unsharedFolderName the unshared folder name
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyFolderUnsharing(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) throws Exception;
/**
* use to notify a user he got a workspace folder renamed
*

View File

@ -256,6 +256,8 @@ public class EmailPlugin {
return "Removed user in a shared folder";
case WP_FOLDER_SHARE:
return notification2Save.getSenderFullName()+ " shared a folder with you";
case WP_FOLDER_UNSHARE:
return notification2Save.getSenderFullName()+ " unshared a folder of yours";
case WP_ITEM_NEW:
return notification2Save.getSenderFullName()+ " added an item in a shared folder";
case WP_ITEM_DELETE: