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:
parent
265b6c35d0
commit
e0f167a5c3
|
@ -222,7 +222,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
_log.trace("Attempting to write onto " + vreScope2Set);
|
_log.trace("Attempting to write onto " + vreScope2Set);
|
||||||
try {
|
try {
|
||||||
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
|
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) {
|
} catch (FeedIDNotFoundException e) {
|
||||||
_log.error("Error writing onto VRES Time Line" + vreScope2Set);
|
_log.error("Error writing onto VRES Time Line" + vreScope2Set);
|
||||||
} //save the feed
|
} //save the feed
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.io.InputStream;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
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.exceptions.ItemNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||||
|
@ -58,18 +60,18 @@ public class UploadToWorkspaceThread implements Runnable {
|
||||||
try {
|
try {
|
||||||
String currScope = ScopeProvider.instance.get();
|
String currScope = ScopeProvider.instance.get();
|
||||||
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
|
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
|
||||||
|
|
||||||
Workspace ws = HomeLibrary
|
Workspace ws = HomeLibrary
|
||||||
.getHomeManagerFactory()
|
.getHomeManagerFactory()
|
||||||
.getHomeManager()
|
.getHomeManager()
|
||||||
.getHome(username).getWorkspace();
|
.getHome(username).getWorkspace();
|
||||||
|
|
||||||
_log.info("File to upload="+fileabsolutePathOnServer);
|
_log.info("File to upload="+fileabsolutePathOnServer);
|
||||||
File file = new File(fileabsolutePathOnServer);
|
File file = new File(fileabsolutePathOnServer);
|
||||||
InputStream fileData = new FileInputStream(file);
|
InputStream fileData = new FileInputStream(file);
|
||||||
|
|
||||||
_log.info("Trying to get Group folder for scope="+currScope);
|
_log.info("Trying to get Group folder for scope="+currScope);
|
||||||
WorkspaceFolder folder = ws.getVREFolderByScope(currScope);
|
WorkspaceSharedFolder folder = ws.getVREFolderByScope(currScope);
|
||||||
|
|
||||||
Workspace ownerWS = HomeLibrary
|
Workspace ownerWS = HomeLibrary
|
||||||
.getHomeManagerFactory()
|
.getHomeManagerFactory()
|
||||||
|
@ -82,10 +84,12 @@ public class UploadToWorkspaceThread implements Runnable {
|
||||||
} catch (ItemNotFoundException e) {
|
} catch (ItemNotFoundException e) {
|
||||||
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it for "+currScope);
|
_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 = 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);
|
WorkspaceFolder theFolderToWriteIn = (WorkspaceFolder) ws.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
|
||||||
FolderItem item = WorkspaceUtil.createExternalFile(attachment, itemName, "File shared by " + fullName + "("+username+")", null, fileData);
|
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());
|
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" + item.getId());
|
||||||
ScopeProvider.instance.set(currScope);
|
ScopeProvider.instance.set(currScope);
|
||||||
|
|
Loading…
Reference in New Issue