diff --git a/pom.xml b/pom.xml index 65aab9c..77992c1 100644 --- a/pom.xml +++ b/pom.xml @@ -130,6 +130,20 @@ ws-thredds-sync-widget [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) compile + + + home-library-model + org.gcube.common + + + home-library-jcr + org.gcube.common + + + home-library + org.gcube.common + + diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 66efa87..3944dc1 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -140,19 +140,27 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return WsUtil.getGWTWorkspaceBuilder(this.getThreadLocalRequest()); } - /** - * Gets the workspace. - * - * @return the workspace - * @throws InternalErrorException the internal error exception - * @throws HomeNotFoundException the home not found exception - * @throws WorkspaceFolderNotFoundException the workspace folder not found exception - */ - protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException + + + protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException { return WsUtil.getWorkspace(this.getThreadLocalRequest()); } + + /** + * Gets the workspace from storage hub. + * + * @return the workspace from storage hub + * @throws Exception the exception + */ + protected org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspaceFromStorageHub() throws Exception + { + GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); + StorageHubWrapper storageHubWrapper = WsUtil.getStorageHubWrapper(this.getThreadLocalRequest(), null, user); + return storageHubWrapper.getWorkspace(); + } + /** * Gets the notification producer. * @@ -963,21 +971,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT checkItemLocked(itemId); - GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); - StorageHubWrapper storageHubWrapper = WsUtil.getStorageHubWrapper(this.getThreadLocalRequest(), null, user); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem theItem = storageHubWrapper.getWorkspace().getItem(itemId); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspaceSH = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem theItem = workspaceSH.getItem(itemId); boolean sourceItemIsShared = theItem.isShared(); String itemName = theItem.getName(); String sourceFolderSharedId = null; if(sourceItemIsShared){ - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem rootSharedFolder = storageHubWrapper.getWorkspace().getRootSharedFolder(itemId); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem rootSharedFolder = workspaceSH.getRootSharedFolder(itemId); sourceFolderSharedId = rootSharedFolder.getId(); } //HERE REMOVING THE ITEM workspaceLogger.info("Calling storageHub to delete item with id: "+itemId); - storageHubWrapper.getWorkspace().deleteItem(itemId); + workspaceSH.deleteItem(itemId); if(sourceFolderSharedId!=null) NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId); @@ -2680,6 +2687,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return null; } } + + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getLinkForSendToSwitchBoard(java.lang.String) + */ @Override public String getLinkForSendToSwitchBoard(String itemId) throws Exception { String fallbackValue = ConstantsExplorer.CLARIN_SWITCHBOARD_ENDPOINT_FALLBACK; @@ -4416,8 +4427,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Checks if is item under sync. * + * @param itemId the item id * @return true, if is item under sync - * @throws Exception + * @throws Exception the exception */ @Override public Boolean isItemUnderSync(String itemId) throws Exception{ @@ -4440,6 +4452,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } + /** + * Gets the CLARIN switch board endpoint. + * + * @return the CLARIN switch board endpoint + */ private String getCLARINSwitchBoardEndpoint() { //save the context for this resource String currContext = ScopeProvider.instance.get(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index 1ca143d..e7179c1 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -14,12 +14,12 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; import org.gcube.common.homelibrary.home.workspace.Workspace; -import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.storagehubwrapper.server.StorageHubWrapper; +import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException; +import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; @@ -129,17 +129,20 @@ public class WsUtil { } + + /** * Gets the workspace. * * @param httpServletRequest the http servlet request * @return the workspace + * @throws WorkspaceFolderNotFoundException the workspace folder not found exception * @throws InternalErrorException the internal error exception * @throws HomeNotFoundException the home not found exception - * @throws WorkspaceFolderNotFoundException the workspace folder not found exception */ - public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException + public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.exceptions.InternalErrorException, HomeNotFoundException { + logger.trace("Get Workspace"); PortalContextInfo info = getPortalContext(httpServletRequest); logger.trace("PortalContextInfo: "+info); @@ -160,10 +163,12 @@ public class WsUtil { * @param user the user * @return the workspace * @throws InternalErrorException the internal error exception + * @throws InternalErrorException the internal error exception * @throws HomeNotFoundException the home not found exception * @throws WorkspaceFolderNotFoundException the workspace folder not found exception + * @throws WorkspaceFolderNotFoundException the workspace folder not found exception */ - public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException + public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.exceptions.InternalErrorException { logger.info("Get workspace using contextID: "+contextID +", current user: "+user.getUsername()); String currentScope; @@ -420,11 +425,9 @@ public class WsUtil { * @param scopeGroupId the scope group id. If scopeGroupId is null the scope is read by using the request else by using the scopeGroupId * @param user the user * @return the storage hub wrapper - * @throws InternalErrorException the internal error exception - * @throws WorkspaceFolderNotFoundException the workspace folder not found exception * @throws Exception the exception */ - public static StorageHubWrapper getStorageHubWrapper(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws InternalErrorException, WorkspaceFolderNotFoundException, Exception{ + public static StorageHubWrapper getStorageHubWrapper(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws Exception{ if(user==null || user.getUsername().isEmpty()) throw new Exception("Session expired"); @@ -444,7 +447,7 @@ public class WsUtil { return new StorageHubWrapper(scope, token); } catch (Exception e) { logger.error("Error during getting storageHub wrapper", e); - throw new InternalErrorException("Error on gettig the StorageHub wrapper for userId: "+user); + throw new Exception("Error on gettig the StorageHub wrapper for userId: "+user); } }