git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@167824 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2308b24a1b
commit
9067bee0fa
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.widgets.wsexplorer.server;
|
package org.gcube.portlets.widgets.wsexplorer.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -418,62 +419,31 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public org.gcube.portlets.widgets.wsexplorer.shared.Item createFolder(String nameFolder, String description, String parentId) throws Exception {
|
public org.gcube.portlets.widgets.wsexplorer.shared.Item createFolder(String folderName, String description, String parentId) throws Exception {
|
||||||
|
|
||||||
_log.debug("creating folder: "+nameFolder +", parent id: "+parentId);
|
_log.debug("creating folder: "+folderName +", parent id: "+parentId);
|
||||||
//TODO
|
if(parentId==null || parentId.isEmpty())
|
||||||
return null;
|
throw new Exception("Parent id is null or empty");
|
||||||
// try {
|
if(folderName == null)
|
||||||
//
|
folderName = "New Folder";
|
||||||
// if(parentId==null || parentId.isEmpty())
|
try {
|
||||||
// throw new Exception("Parent id is null or empty");
|
FolderItem createdFolder = StorageHubServiceUtil.createFolder(getThreadLocalRequest(), parentId, folderName, description);
|
||||||
//
|
_log.info("Path returned by StoHub: "+createdFolder.getPath());
|
||||||
// if(nameFolder == null)
|
List<ItemType> allTypes = Arrays.asList(ItemType.values());
|
||||||
// nameFolder = "Empty Folder";
|
return ItemBuilder.getItem(null, createdFolder, createdFolder.getPath(), allTypes, null, false, false);
|
||||||
//
|
// } catch(InsufficientPrivilegesException e){
|
||||||
// Workspace workspace = getWorkspace();
|
// String error = "Insufficient Privileges to create the folder";
|
||||||
// WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parentId);
|
// _log.error(error, e);
|
||||||
//
|
// throw new Exception(error);
|
||||||
//// _log.info("Path returned by HL: "+wsFolder.getPath());
|
// } catch (ItemAlreadyExistException e) {
|
||||||
//
|
// String error = "An error occurred on creating folder, " +e.getMessage();
|
||||||
// List<ItemType> allTypes = Arrays.asList(ItemType.values());
|
// _log.error(error, e);
|
||||||
//
|
// throw new Exception(error);
|
||||||
// org.gcube.portlets.widgets.wsexplorer.shared.Item parent = null;
|
} catch (Exception e) {
|
||||||
// try{
|
String error = "An error occurred on the sever during creating folder. Try again";
|
||||||
// String parentPath = wsFolder.getParent()!=null?wsFolder.getParent().getPath():"";
|
_log.error(error, e);
|
||||||
// parent = ItemBuilder.getItem(null, wsFolder.getParent(), parentPath, allTypes, null, false, false);
|
throw new Exception(error);
|
||||||
// }catch(Exception e){
|
}
|
||||||
// logger.error("Get parent thown an exception, is it the root id? "+parentId);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //TODO PATCH TO AVOID PROBLEM ON GETPATH. FOR EXAMPLE WHEN PARENT IS ROOT
|
|
||||||
// String itemPath = null;
|
|
||||||
// try{
|
|
||||||
// itemPath = wsFolder.getPath();
|
|
||||||
// logger.info("itemPath: "+itemPath);
|
|
||||||
// }catch(Exception e){
|
|
||||||
// logger.error("Get path thrown an exception, for id: "+wsFolder.getId() +" name: "+wsFolder.getName(), e);
|
|
||||||
//// itemPath= wsFolder.isFolder()?workspace.getRoot().getPath()+"/"+wsFolder.getName():workspace.getRoot().getPath();
|
|
||||||
// //PATCH TO RETURN ABSOLUTE PATH
|
|
||||||
// itemPath= workspace.getRoot().getPath()+"/"+wsFolder.getName();
|
|
||||||
// logger.warn("returning base path: "+itemPath);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return ItemBuilder.getItem(parent, wsFolder, itemPath, allTypes, null, false, false);
|
|
||||||
//
|
|
||||||
// } catch(InsufficientPrivilegesException e){
|
|
||||||
// String error = "Insufficient Privileges to create the folder";
|
|
||||||
// logger.error(error, e);
|
|
||||||
// throw new Exception(error);
|
|
||||||
// } catch (ItemAlreadyExistException e) {
|
|
||||||
// String error = "An error occurred on creating folder, " +e.getMessage();
|
|
||||||
// logger.error(error, e);
|
|
||||||
// throw new Exception(error);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// String error = "An error occurred on the sever during creating folder. Try again";
|
|
||||||
// logger.error(error, e);
|
|
||||||
// throw new Exception(error);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||||
import org.gcube.common.storagehub.model.acls.ACL;
|
import org.gcube.common.storagehub.model.acls.ACL;
|
||||||
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
import org.gcube.common.storagehub.model.items.SharedFolder;
|
import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||||
import org.gcube.common.storagehub.model.items.VreFolder;
|
|
||||||
|
|
||||||
import com.liferay.portal.kernel.log.Log;
|
import com.liferay.portal.kernel.log.Log;
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
|
@ -58,6 +58,17 @@ public class StorageHubServiceUtil {
|
||||||
List<? extends Item> toReturn = client.getAnchestors(itemId, ACCOUNTING_HL_NODE_NAME);
|
List<? extends Item> toReturn = client.getAnchestors(itemId, ACCOUNTING_HL_NODE_NAME);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) {
|
||||||
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
|
String userName = pContext.getCurrentUser(request).getUsername();
|
||||||
|
String scope = pContext.getCurrentScope(request);
|
||||||
|
String authorizationToken = pContext.getCurrentUserToken(scope, userName);
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
SecurityTokenProvider.instance.set(authorizationToken);
|
||||||
|
ItemManagerClient client = AbstractPlugin.item().build();
|
||||||
|
return client.createFolder(parentId, userName, description);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -106,7 +117,6 @@ public class StorageHubServiceUtil {
|
||||||
|
|
||||||
boolean found = false; //this is needed because in case o VRE Foder the permission is assigned ot the group and not to the user.
|
boolean found = false; //this is needed because in case o VRE Foder the permission is assigned ot the group and not to the user.
|
||||||
for (ACL acl : acls) {
|
for (ACL acl : acls) {
|
||||||
System.out.println("ACL: "+acl.getPricipal().toString() + " types: "+ acl.getAccessTypes().toString());
|
|
||||||
if (acl.getPricipal().compareTo(userName) == 0) {
|
if (acl.getPricipal().compareTo(userName) == 0) {
|
||||||
found = true;
|
found = true;
|
||||||
return acl.getAccessTypes().get(0).toString();
|
return acl.getAccessTypes().get(0).toString();
|
||||||
|
|
Loading…
Reference in New Issue