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
This commit is contained in:
parent
459bdee19a
commit
4d1cbb0c15
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue