From 4d1cbb0c1514bc58ccab05fe04d0d096e3c1cd55 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 30 Sep 2014 16:25:29 +0000 Subject: [PATCH] Added save pf shared attachments in VRE Group folder git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@100304 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/ShareUpdateServiceImpl.java | 2 +- .../server/UploadToWorkspaceThread.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index 32fcca5..2250315 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -245,7 +245,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //it means I also should upload a copy on the user's Workspace root folder if (fileName != null && filePathOnServer != null) { //The workspace uploader Thread starts here asyncronously - Thread thread = new Thread(new UploadToWorkspaceThread(username, fileName, filePathOnServer)); + Thread thread = new Thread(new UploadToWorkspaceThread(fullName, username, fileName, filePathOnServer)); thread.start(); } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/UploadToWorkspaceThread.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/UploadToWorkspaceThread.java index 89a2c5a..a89eb0f 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/UploadToWorkspaceThread.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/UploadToWorkspaceThread.java @@ -27,6 +27,10 @@ public class UploadToWorkspaceThread implements Runnable { * the identifier of the workspace you are putting */ private String username; + /** + * the identifier of the workspace you are putting + */ + private String fullName; /** * the name of the file you are putting */ @@ -41,9 +45,10 @@ public class UploadToWorkspaceThread implements Runnable { * @param sClient the instance of the storage client * @param fileToUpload the absolute path of the file */ - public UploadToWorkspaceThread(String username, String fileName, String fileabsolutePathOnServer) { + public UploadToWorkspaceThread(String fullName, String username, String fileName, String fileabsolutePathOnServer) { super(); this.username = username; + this.fullName = fullName; this.fileName = fileName; this.fileabsolutePathOnServer = fileabsolutePathOnServer; } @@ -65,20 +70,22 @@ public class UploadToWorkspaceThread implements Runnable { _log.info("Trying to get Group folder for scope="+currScope); WorkspaceFolder folder = ws.getVREFolderByScope(currScope); + + Workspace ownerWS = HomeLibrary + .getHomeManagerFactory() + .getHomeManager() + .getHome(folder.getOwner().getPortalLogin()).getWorkspace(); + WorkspaceFolder attachment = null; try{ - attachment = (WorkspaceFolder) ws.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER); + attachment = (WorkspaceFolder) ownerWS.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER); } catch (ItemNotFoundException e) { _log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it for "+currScope); - Workspace ownerWS = HomeLibrary - .getHomeManagerFactory() - .getHomeManager() - .getHome(folder.getOwner().getPortalLogin()).getWorkspace(); attachment = ownerWS.createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System", folder.getId()); } String itemName = WorkspaceUtil.getUniqueName(fileName,attachment); - FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File added automatically by Share Updates", null, fileData); + FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File shared by " + fullName + "("+username+")", null, fileData); _log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" + item.getId()); ScopeProvider.instance.set(currScope);