|
|
|
@ -57,6 +57,7 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.WorkspaceHandledException;
|
|
|
|
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
|
|
|
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
|
|
|
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter;
|
|
|
|
@ -291,7 +292,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
//ADDING SPECIAL FOLDER?
|
|
|
|
|
if(wsItem.isRoot()){
|
|
|
|
|
//TODO
|
|
|
|
|
//ADD SPECIAL FOLDER
|
|
|
|
|
try{
|
|
|
|
|
workspaceLogger.info("Folder is root, loading special folders..");
|
|
|
|
@ -372,7 +372,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
//ADDING SPECIAL FOLDER?
|
|
|
|
|
if(wsFolder.isRoot()){
|
|
|
|
|
//TODO
|
|
|
|
|
//ADD SPECIAL FOLDER
|
|
|
|
|
try{
|
|
|
|
|
workspaceLogger.info("Folder is root, loading special folders..");
|
|
|
|
@ -2077,31 +2076,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
|
|
|
|
|
|
|
|
|
if(NotificationsUtil.isASharedFolder(wsItem)){
|
|
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
|
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
|
|
List<String> listPortalLogin = wsFolder.getUsers();
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
|
|
|
|
|
|
|
|
|
|
if(isTestMode())
|
|
|
|
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
|
|
|
|
|
|
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
else
|
|
|
|
|
workspaceLogger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
|
|
|
|
|
//DEBUG
|
|
|
|
|
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
}
|
|
|
|
|
return new ArrayList<InfoContactModel>();
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -2113,35 +2104,29 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception{
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedBySharedItem "+ sharedItemId);
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("Get ListUserSharedBySharedItem "+ sharedItemId);
|
|
|
|
|
try {
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(sharedItemId);
|
|
|
|
|
|
|
|
|
|
if(wsItem!=null && wsItem.isShared()){
|
|
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
|
|
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = getSharedWorkspaceFolderForId(sharedItemId);
|
|
|
|
|
if(wsFolder!=null){
|
|
|
|
|
|
|
|
|
|
if(isASharedFolder(wsFolder, true)){
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
|
|
List<String> listPortalLogin = wsFolder.getUsers();
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
|
|
|
|
|
WorkspaceSharedFolder wsSharedFolder = (WorkspaceSharedFolder) wsFolder;
|
|
|
|
|
List<String> listPortalLogin = wsSharedFolder.getUsers();
|
|
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user/s");
|
|
|
|
|
|
|
|
|
|
if(isTestMode())
|
|
|
|
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
|
|
|
|
}else{
|
|
|
|
|
workspaceLogger.warn("wsFolder with id: "+sharedItemId +" is not a: "+WorkspaceItemType.SHARED_FOLDER +", returning null");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return new ArrayList<InfoContactModel>();
|
|
|
|
|
workspaceLogger.warn("wsFolder with id: "+sharedItemId +" is null, returning null");
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
workspaceLogger.error("Error in getListUserSharedByItemId ", e);
|
|
|
|
@ -2161,26 +2146,19 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if(isASharedFolder(folderSharedId, true)){
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("workspace return an item with name "+wsItem.getName());
|
|
|
|
|
|
|
|
|
|
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
|
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
|
|
|
|
|
|
|
|
|
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
|
|
|
|
|
|
|
|
|
|
String sharedFolderName = wsFolder.getName();
|
|
|
|
|
|
|
|
|
|
//RETURN A NEW FOLDER
|
|
|
|
|
wsFolder.unShare();
|
|
|
|
|
workspaceLogger.trace("no error incoming on unsharing");
|
|
|
|
|
unShared = true;
|
|
|
|
|
// if(newFolder!=null)
|
|
|
|
|
// unShared = true;
|
|
|
|
|
|
|
|
|
|
NotificationsProducer np = getNotificationProducer();
|
|
|
|
|
List<InfoContactModel> purgeMyContact = new ArrayList<InfoContactModel>(contacts.size()-1);
|
|
|
|
@ -2197,18 +2175,24 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
np.notifyFolderUnSharing(purgeMyContact, folderSharedId, sharedFolderName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
workspaceLogger.info("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
else{
|
|
|
|
|
String msg = "The item with id: "+folderSharedId+ "is not a base shared folder";
|
|
|
|
|
workspaceLogger.warn("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER +" or root shared folder");
|
|
|
|
|
throw new WorkspaceHandledException(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (InternalErrorException e) {
|
|
|
|
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
|
|
|
|
String error = "An error occerred on unsharing folder. "+ e.getMessage();
|
|
|
|
|
throw new Exception(error);
|
|
|
|
|
|
|
|
|
|
} catch (WorkspaceHandledException e) {
|
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" unshare folder. "+e.getMessage();
|
|
|
|
|
throw new Exception(error);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" un share folder. Refresh folder and " +ConstantsExplorer.TRY_AGAIN;
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" unshare folder. Refresh folder and " +ConstantsExplorer.TRY_AGAIN;
|
|
|
|
|
throw new Exception(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2847,14 +2831,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
public List<ExtendedWorkspaceACL> getUserACLForFolderId(String folderId) throws Exception{
|
|
|
|
|
try {
|
|
|
|
|
workspaceLogger.info("Get user ACL to FOLDER id: "+folderId);
|
|
|
|
|
WorkspaceSharedFolder wsFolder = getSharedFolderForId(folderId);
|
|
|
|
|
WorkspaceFolder wsFolder = getSharedWorkspaceFolderForId(folderId);
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
List<WorkspaceACL> listACL = builder.getWorkspaceACLFromACLs(Arrays.asList(wsFolder.getACLUser()));
|
|
|
|
|
|
|
|
|
|
List<ExtendedWorkspaceACL> listEACL = new ArrayList<ExtendedWorkspaceACL>(listACL.size());
|
|
|
|
|
for (WorkspaceACL workspaceACL : listACL) {
|
|
|
|
|
|
|
|
|
|
boolean isBaseSharedFolder = (wsFolder.getId().compareTo(folderId)==0)?true:false;
|
|
|
|
|
boolean isBaseSharedFolder = isASharedFolder(wsFolder, true) ?true:false;
|
|
|
|
|
ExtendedWorkspaceACL eac = new ExtendedWorkspaceACL(workspaceACL.getId(), workspaceACL.getLabel(), workspaceACL.getDefaultValue(), workspaceACL.getUserType(), workspaceACL.getDescription(), wsFolder.getOwner().getPortalLogin(), folderId, isBaseSharedFolder);
|
|
|
|
|
workspaceLogger.trace("ACL "+workspaceACL+" converted in: "+eac);
|
|
|
|
|
listEACL.add(eac);
|
|
|
|
@ -2877,7 +2861,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
public String getACLsDescriptionForSharedFolderId(String folderId) throws Exception{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = getSharedFolderForId(folderId);
|
|
|
|
|
WorkspaceFolder wsFolder = getSharedWorkspaceFolderForId(folderId);
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
return builder.getFormattedHtmlACLFromACLs(wsFolder.getACLOwner());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -2887,37 +2871,47 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WorkspaceSharedFolder getSharedFolderForId(String folderId) throws Exception{
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param folderId
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private WorkspaceFolder getSharedWorkspaceFolderForId(String folderId) throws Exception{
|
|
|
|
|
|
|
|
|
|
if(folderId == null)
|
|
|
|
|
throw new Exception("Folder id is null");
|
|
|
|
|
|
|
|
|
|
workspaceLogger.trace("Get ACLsDescriptionForFolderId folder id: "+folderId);
|
|
|
|
|
workspaceLogger.trace("Get SharedFolderForId: "+folderId);
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folderId);
|
|
|
|
|
WorkspaceItem wsItem = null;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
wsItem = workspace.getItem(folderId);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
workspaceLogger.error("Get SharedFolderForId error on folder id: "+folderId, e);
|
|
|
|
|
throw new Exception(ConstantsExplorer.SERVER_ERROR +" retrieving item with id: "+folderId+". Try again later!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isASharedFolder(wsItem, false)){
|
|
|
|
|
workspaceLogger.trace("Get SharedFolderForId: folder id "+folderId+" is shared");
|
|
|
|
|
|
|
|
|
|
//TODO REMOVE wsItem.getIdSharedFolder()
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
|
|
|
|
// WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
|
|
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = (WorkspaceFolder) wsItem;
|
|
|
|
|
if(wsFolder!=null){
|
|
|
|
|
workspaceLogger.trace("Get ACLsDescriptionForFolderId shared folder name is: "+wsFolder.getName());
|
|
|
|
|
workspaceLogger.info("Get SharedFolderForId return name: "+wsFolder.getName());
|
|
|
|
|
return wsFolder;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
workspaceLogger.trace("Source item is not a shared folder, throw exception");
|
|
|
|
|
workspaceLogger.warn("Source item is not a shared folder, throw exception");
|
|
|
|
|
throw new Exception("Source item is not a shared folder");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO USE THIS
|
|
|
|
|
// return (WorkspaceFolder) wsItem;
|
|
|
|
|
}else{
|
|
|
|
|
workspaceLogger.trace("Source item is null or not shared, throw exception");
|
|
|
|
|
throw new Exception("Source item is null or not shared");
|
|
|
|
|
workspaceLogger.warn("Source item is null or not shared folder, throw exception");
|
|
|
|
|
throw new Exception("Source item is null or not shared folder for id: "+folderId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2960,7 +2954,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
workspaceLogger.error("Error in server isASharedFolder", e);
|
|
|
|
@ -3223,18 +3216,19 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
if(folderId==null)
|
|
|
|
|
return admins;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem item = workspace.getItem(folderId);
|
|
|
|
|
workspaceLogger.info("Getting administator/s to folder: "+folderId);
|
|
|
|
|
|
|
|
|
|
if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
|
|
|
|
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
|
|
|
|
WorkspaceFolder wsFolder = getSharedWorkspaceFolderForId(folderId);
|
|
|
|
|
if(isASharedFolder(wsFolder, true)){
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(sharedFolder.getAdministrators());
|
|
|
|
|
WorkspaceSharedFolder wsSharedFolder = (WorkspaceSharedFolder) wsFolder;
|
|
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(wsSharedFolder.getAdministrators());
|
|
|
|
|
}else
|
|
|
|
|
throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
throw new WorkspaceHandledException("the item with "+folderId +" is not a base shared folder!");
|
|
|
|
|
|
|
|
|
|
} catch (WorkspaceHandledException e){
|
|
|
|
|
workspaceLogger.error("Error in server getAdministratorsByFolderId: "+e.getMessage());
|
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR +" getting Administrators: "+e.getMessage();
|
|
|
|
|
throw new Exception(error);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
workspaceLogger.error("Error in server getAdministratorsByFolderId: "+e.getMessage());
|
|
|
|
|
workspaceLogger.error(e);
|
|
|
|
@ -3279,15 +3273,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem item = workspace.getItem(identifier);
|
|
|
|
|
WorkspaceFolder sharedFolder = getSharedWorkspaceFolderForId(identifier);
|
|
|
|
|
|
|
|
|
|
if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
|
|
|
|
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
|
|
|
|
//IS ROOT??
|
|
|
|
|
if(isASharedFolder(sharedFolder, true)){
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
|
|
workspaceLogger.info("Read getPrivilege from HL: "+sharedFolder.getACLUser());
|
|
|
|
|
List<WorkspaceACL> wsAcls = builder.getWorkspaceACLFromACLs(Arrays.asList(sharedFolder.getPrivilege()));
|
|
|
|
|
//CASTING TO ROOT
|
|
|
|
|
WorkspaceSharedFolder wsSharedFolder = (WorkspaceSharedFolder) sharedFolder;
|
|
|
|
|
workspaceLogger.info("Read getPrivilege from HL: "+wsSharedFolder.getACLUser());
|
|
|
|
|
List<WorkspaceACL> wsAcls = builder.getWorkspaceACLFromACLs(Arrays.asList(wsSharedFolder.getPrivilege()));
|
|
|
|
|
|
|
|
|
|
if(wsAcls==null || wsAcls.isEmpty()){
|
|
|
|
|
workspaceLogger.info("Converted ACLBySharedFolderId is null or empty, returning null");
|
|
|
|
@ -3296,9 +3290,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|
|
|
|
|
|
|
|
|
workspaceLogger.info("Returning first acl with id: "+wsAcls.get(0).getId());
|
|
|
|
|
return wsAcls.get(0);
|
|
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
workspaceLogger.warn("WorkspaceFolder "+sharedFolder+" is not type of "+WorkspaceItemType.SHARED_FOLDER+ ", returning null");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
workspaceLogger.error("Error in server ACLBySharedFolderId: "+e.getMessage());
|
|
|
|
|