updated shared attachment in workspace to make upload user be the owner of the file

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@100785 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-17 14:29:23 +00:00
parent 265b6c35d0
commit e0f167a5c3
2 changed files with 12 additions and 7 deletions

View File

@ -222,7 +222,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
_log.trace("Attempting to write onto " + vreScope2Set);
try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
store.saveHashTags(toShare.getKey(), vreScope2Set, hashtags);
if (hashtags != null && !hashtags.isEmpty())
store.saveHashTags(toShare.getKey(), vreScope2Set, hashtags);
} catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope2Set);
} //save the feed

View File

@ -7,6 +7,8 @@ import java.io.InputStream;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.util.WorkspaceUtil;
@ -58,18 +60,18 @@ public class UploadToWorkspaceThread implements Runnable {
try {
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(username).getWorkspace();
_log.info("File to upload="+fileabsolutePathOnServer);
File file = new File(fileabsolutePathOnServer);
InputStream fileData = new FileInputStream(file);
_log.info("Trying to get Group folder for scope="+currScope);
WorkspaceFolder folder = ws.getVREFolderByScope(currScope);
WorkspaceSharedFolder folder = ws.getVREFolderByScope(currScope);
Workspace ownerWS = HomeLibrary
.getHomeManagerFactory()
@ -82,10 +84,12 @@ public class UploadToWorkspaceThread implements Runnable {
} catch (ItemNotFoundException e) {
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it for "+currScope);
attachment = ownerWS.createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System", folder.getId());
attachment.setACL(folder.getUsers(), ACLType.WRITE_OWNER);
}
String itemName = WorkspaceUtil.getUniqueName(fileName,attachment);
FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File shared by " + fullName + "("+username+")", null, fileData);
WorkspaceFolder theFolderToWriteIn = (WorkspaceFolder) ws.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
String itemName = WorkspaceUtil.getUniqueName(fileName, theFolderToWriteIn);
FolderItem item = WorkspaceUtil.createExternalFile(theFolderToWriteIn, itemName, "File shared by " + fullName + "("+username+")", null, fileData);
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" + item.getId());
ScopeProvider.instance.set(currScope);