reorganized workspace and user utils
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@132915 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a9d2a076a5
commit
cb6df188bf
|
@ -9,9 +9,7 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||||
|
@ -30,7 +28,6 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfile
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceBeanWrapper;
|
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
|
@ -55,44 +52,6 @@ public class Utils {
|
||||||
// Logger
|
// Logger
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Utils.class);
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Utils.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Build up the resource beans.
|
|
||||||
* @param resourceIds
|
|
||||||
* @param ws
|
|
||||||
* @param username
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<ResourceBeanWrapper> getWorkspaceResourcesInformation(
|
|
||||||
List<String> resourceIds, Workspace ws, String username) {
|
|
||||||
|
|
||||||
List<ResourceBeanWrapper> toReturn = null;
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
toReturn = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String resourceId : resourceIds) {
|
|
||||||
|
|
||||||
logger.debug("RESOURCE ID IS " + resourceId);
|
|
||||||
|
|
||||||
ResourceBeanWrapper newResource = new ResourceBeanWrapper();
|
|
||||||
WorkspaceItem item = ws.getItem(resourceId);
|
|
||||||
newResource.setDescription(item.getDescription());
|
|
||||||
newResource.setId(item.getId());
|
|
||||||
newResource.setUrl(item.getPublicLink(true));
|
|
||||||
newResource.setName(item.getName());
|
|
||||||
newResource.setToBeAdded(true); // default is true
|
|
||||||
newResource.setMimeType(((FolderItem)item).getMimeType());
|
|
||||||
toReturn.add(newResource);
|
|
||||||
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
logger.error("Unable to retrieve resources' info", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the gcube item properties.
|
/** Gets the gcube item properties.
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
|
|
|
@ -123,9 +123,48 @@ public class WorkspaceUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ResourceBeanWrapper> listOfResources = Utils.getWorkspaceResourcesInformation(childrenIds, ws, userName);
|
List<ResourceBeanWrapper> listOfResources = getWorkspaceResourcesInformation(childrenIds, ws, userName);
|
||||||
bean.setResources(listOfResources);
|
bean.setResources(listOfResources);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build up the resource beans.
|
||||||
|
* @param resourceIds
|
||||||
|
* @param ws
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<ResourceBeanWrapper> getWorkspaceResourcesInformation(
|
||||||
|
List<String> resourceIds, Workspace ws, String username) {
|
||||||
|
|
||||||
|
List<ResourceBeanWrapper> toReturn = null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
toReturn = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String resourceId : resourceIds) {
|
||||||
|
|
||||||
|
logger.debug("RESOURCE ID IS " + resourceId);
|
||||||
|
|
||||||
|
ResourceBeanWrapper newResource = new ResourceBeanWrapper();
|
||||||
|
WorkspaceItem item = ws.getItem(resourceId);
|
||||||
|
newResource.setDescription(item.getDescription());
|
||||||
|
newResource.setId(item.getId());
|
||||||
|
newResource.setUrl(item.getPublicLink(true));
|
||||||
|
newResource.setName(item.getName());
|
||||||
|
newResource.setToBeAdded(true); // default is true
|
||||||
|
newResource.setMimeType(((FolderItem)item).getMimeType());
|
||||||
|
toReturn.add(newResource);
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Unable to retrieve resources' info", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue