From 86217393b9ede6601514019761dbb1888688ff77 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 27 Sep 2013 15:39:28 +0000 Subject: [PATCH] Refactor to new Home Library dependencies org.gcube.common home-library-jcr 1.0.0-SNAPSHOT provided org.gcube.common home-library 1.0.0-SNAPSHOT provided git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@82110 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 27 ++++++- .../server/DownloadPublicLinkServlet.java | 11 ++- .../workspace/server/DownloadServlet.java | 49 ++++++------ .../workspace/server/GWTWorkspaceBuilder.java | 80 +++++++++---------- .../server/GWTWorkspaceServiceImpl.java | 55 +++++++------ .../user/workspace/server/ImageServlet.java | 16 ++-- .../user/workspace/server/UploadServlet.java | 36 ++++----- .../notifications/NotificationsProducer.java | 8 +- .../notifications/NotificationsUtil.java | 10 +-- .../server/util/WorkspaceEventCollector.java | 4 +- .../user/workspace/server/util/WsUtil.java | 26 ++++-- .../user/workspace/DonwloadServletTest.java | 23 ++---- .../user/workspace/PublicLinkTest.java | 37 ++++----- .../user/workspace/UploadServletTest.java | 30 ++++--- .../user/workspace/UriResolverReaderRR.java | 14 ++-- 15 files changed, 221 insertions(+), 205 deletions(-) diff --git a/pom.xml b/pom.xml index cb3fc45..8c83963 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,12 @@ provided + + org.gcube.core + common-encryption + 1.0.0-SNAPSHOT + + org.gcube.core gcf @@ -94,16 +100,29 @@ provided + + + + + + + + + + + - org.gcube.portlets.user - home-library + org.gcube.common + home-library-jcr + 1.0.0-SNAPSHOT provided - org.gcube.portlets.user - home-library-jcr + org.gcube.common + home-library + 1.0.0-SNAPSHOT provided diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadPublicLinkServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadPublicLinkServlet.java index b53d66d..c1b4378 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadPublicLinkServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadPublicLinkServlet.java @@ -14,12 +14,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; -import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty; import org.gcube.portlets.user.workspace.shared.HandlerResultMessage; @@ -162,7 +161,7 @@ public class DownloadPublicLinkServlet extends HttpServlet{ try{ - Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa", GCUBEScope.getScope("/gcube/devsec")).getWorkspace(); + Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace(); // // ExternalFile f = (ExternalFile) ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b"); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java index 9d090d2..1d1bd75 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java @@ -19,31 +19,30 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; -import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ExternalResourceBrokenLinkException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ExternalResourcePluginNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.AquaMapsItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalImage; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalResourceLink; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Query; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Document; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Metadata; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries; -import org.gcube.portlets.user.homelibrary.util.Extensions; -import org.gcube.portlets.user.homelibrary.util.MimeTypeUtil; -import org.gcube.portlets.user.homelibrary.util.zip.ZipUtil; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.exceptions.ExternalResourceBrokenLinkException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ExternalResourcePluginNotFoundException; +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.items.AquaMapsItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalResourceLink; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl; +import org.gcube.common.homelibrary.home.workspace.folder.items.Query; +import org.gcube.common.homelibrary.home.workspace.folder.items.Report; +import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.Document; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.Metadata; +import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries; +import org.gcube.common.homelibrary.util.Extensions; +import org.gcube.common.homelibrary.util.MimeTypeUtil; +import org.gcube.common.homelibrary.util.zip.ZipUtil; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty; import org.gcube.portlets.user.workspace.server.util.WsUtil; @@ -712,7 +711,7 @@ public class DownloadServlet extends HttpServlet{ try{ - Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa", GCUBEScope.getScope("/gcube/devsec")).getWorkspace(); + Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace(); // // ExternalFile f = (ExternalFile) ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b"); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index b715f62..a8a8fde 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -14,46 +14,46 @@ import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import org.gcube.common.core.utils.logging.GCUBEClientLog; -import org.gcube.portlets.user.homelibrary.home.User; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Properties; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSmartFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntry; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryAdd; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryCreate; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryCut; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryPaste; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRead; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRemoval; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRenaming; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryShare; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryUnshare; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryUpdate; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.AquaMapsItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalImage; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalPDFFile; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Query; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.WorkflowReport; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.WorkflowTemplate; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Document; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.DocumentMetadata; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.ImageDocument; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Metadata; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.PDFDocument; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.UrlDocument; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeriesInfo; -import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchFolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem; -import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage; +import org.gcube.common.homelibrary.home.User; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.Properties; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceSmartFolder; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntry; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryAdd; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryCreate; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryCut; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryPaste; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryRead; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryRemoval; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryRenaming; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryShare; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryUnshare; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryUpdate; +import org.gcube.common.homelibrary.home.workspace.folder.FolderBulkCreator; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.AquaMapsItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl; +import org.gcube.common.homelibrary.home.workspace.folder.items.Query; +import org.gcube.common.homelibrary.home.workspace.folder.items.Report; +import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate; +import org.gcube.common.homelibrary.home.workspace.folder.items.WorkflowReport; +import org.gcube.common.homelibrary.home.workspace.folder.items.WorkflowTemplate; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.Document; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.DocumentMetadata; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.ImageDocument; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.Metadata; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.PDFDocument; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.UrlDocument; +import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries; +import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeriesInfo; +import org.gcube.common.homelibrary.home.workspace.search.SearchFolderItem; +import org.gcube.common.homelibrary.home.workspace.search.SearchItem; +import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel; 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 84ceef3..ddbb28d 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 @@ -11,29 +11,30 @@ import org.apache.log4j.Logger; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBEClientLog; -import org.gcube.portlets.user.homelibrary.home.Home; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSmartFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntry; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongDestinationException; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries; -import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem; -import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage; +import org.gcube.common.homelibrary.home.Home; +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.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceSmartFolder; +import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntry; +import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException; +import org.gcube.common.homelibrary.home.workspace.folder.FolderBulkCreator; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItemType; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl; +import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries; +import org.gcube.common.homelibrary.home.workspace.search.SearchItem; +import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage; +import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel; @@ -173,7 +174,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(scopeId.compareTo(ScopeUtilFilter.IDALLSCOPE)!=0){ gcubeScope = GCUBEScope.getScope(scopeId); } - WorkspaceFolder root = workspace.getRoot(gcubeScope); + + + WorkspaceFolder root = workspace.getRoot(); // WorkspaceFolder root = workspace.getRoot(); // WorkspaceFolder root = workspace.getRoot(scopeId); @@ -1140,8 +1143,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(WsUtil.isVRE(session)){ + ScopeProvider.instance.set(session.getScope()); + // GET WORKSPACE - Workspace workspace = HomeLibrary.getUserWorkspace(session); + Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); // GET ITEM FROM WORKSPACE WorkspaceItem item = workspace.getItem(oid); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java index 0c1c93a..074c57c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/ImageServlet.java @@ -14,14 +14,14 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Image; +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.WorkspaceItemType; +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.FolderItemType; +import org.gcube.common.homelibrary.home.workspace.folder.items.Image; import org.gcube.portlets.user.workspace.client.util.ImageRequestType; import org.gcube.portlets.user.workspace.server.util.WsUtil; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java index a2fefa8..d66387c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java @@ -23,24 +23,24 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.FilenameUtils; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongDestinationException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongItemTypeException; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate; -import org.gcube.portlets.user.homelibrary.util.Extensions; -import org.gcube.portlets.user.homelibrary.util.MimeTypeUtil; -import org.gcube.portlets.user.homelibrary.util.WorkspaceUtil; -import org.gcube.portlets.user.homelibrary.util.zip.UnzipUtil; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.Report; +import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate; +import org.gcube.common.homelibrary.util.Extensions; +import org.gcube.common.homelibrary.util.MimeTypeUtil; +import org.gcube.common.homelibrary.util.WorkspaceUtil; +import org.gcube.common.homelibrary.util.zip.UnzipUtil; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil; import org.gcube.portlets.user.workspace.server.util.WsUtil; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java index 14984b1..13aaa25 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java @@ -11,10 +11,10 @@ import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBEClientLog; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.server.util.DiffereceBeetweenInfoContactModel; import org.gcube.portlets.user.workspace.server.util.UserUtil; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java index fa7c44c..a448a8e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java @@ -9,11 +9,11 @@ import java.util.List; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.util.WsUtil; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WorkspaceEventCollector.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WorkspaceEventCollector.java index e701fbe..39e1d55 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WorkspaceEventCollector.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WorkspaceEventCollector.java @@ -7,8 +7,8 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.portlets.user.homelibrary.home.workspace.events.WorkspaceEvent; -import org.gcube.portlets.user.homelibrary.home.workspace.events.WorkspaceListener; +import org.gcube.common.homelibrary.home.workspace.events.WorkspaceEvent; +import org.gcube.common.homelibrary.home.workspace.events.WorkspaceListener; /** * @author Federico De Faveri defaveri@isti.cnr.it 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 124f080..9cd3b2e 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 @@ -6,18 +6,20 @@ package org.gcube.portlets.user.workspace.server.util; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.common.core.utils.logging.GCUBELog; +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.scope.api.ScopeProvider; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer; @@ -62,6 +64,8 @@ public class WsUtil { public static GCUBEClientLog defaultLogger = new GCUBEClientLog(WsUtil.class); + protected static Logger logger = Logger.getLogger(WsUtil.class); + public static boolean withoutPortal = false; public static ASLSession getAslSession(HttpSession httpSession) @@ -74,10 +78,10 @@ public class WsUtil { /*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING * COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/ - user=TEST_USER; +// user=TEST_USER; //UNCOMMENT THIS IN DEVELOP ENVIROMENT -// user = "francesco.mangiacrapa"; + user = "francesco.mangiacrapa"; defaultLogger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); defaultLogger.warn("session id: "+sessionID); @@ -115,9 +119,15 @@ public class WsUtil { public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException { + + logger.trace("Get Workspace"); final ASLSession session = getAslSession(httpSession); + logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername()); - Workspace workspace = HomeLibrary.getUserWorkspace(session); + ScopeProvider.instance.set(session.getScope()); + logger.trace("Scope provider instancied"); + + Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); final GCUBELog logger = getLogger(workspace); diff --git a/src/test/java/org/gcube/portlets/user/workspace/DonwloadServletTest.java b/src/test/java/org/gcube/portlets/user/workspace/DonwloadServletTest.java index 9262914..6b49a30 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/DonwloadServletTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/DonwloadServletTest.java @@ -3,21 +3,15 @@ */ package org.gcube.portlets.user.workspace; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; import java.util.List; -import org.apache.commons.io.IOUtils; -import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; -import org.gcube.portlets.user.homelibrary.jcr.repository.external.GCUBEStorage; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItemType; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it @@ -39,8 +33,7 @@ public class DonwloadServletTest { Workspace ws = HomeLibrary .getHomeManagerFactory() .getHomeManager() - .getHome("francesco.mangiacrapa", - GCUBEScope.getScope("/gcube/devsec")) + .getHome("francesco.mangiacrapa") .getWorkspace(); // diff --git a/src/test/java/org/gcube/portlets/user/workspace/PublicLinkTest.java b/src/test/java/org/gcube/portlets/user/workspace/PublicLinkTest.java index f3b151f..ad8b474 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/PublicLinkTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/PublicLinkTest.java @@ -7,25 +7,18 @@ import java.util.List; import org.apache.log4j.Logger; import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalImage; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalPDFFile; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.WorkflowReport; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Document; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.ImageDocument; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.PDFDocument; -import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; -import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; -import org.gcube.portlets.user.workspace.client.model.FileModel; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile; +import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.ImageDocument; +import org.gcube.common.scope.api.ScopeProvider; /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it @@ -41,11 +34,13 @@ public class PublicLinkTest { try { + GCUBEScope scope = GCUBEScope.getScope("/gcube/devsec"); + ScopeProvider.instance.set(scope.toString()); + Workspace ws = HomeLibrary .getHomeManagerFactory() .getHomeManager() - .getHome("francesco.mangiacrapa", - GCUBEScope.getScope("/gcube/devsec")) + .getHome("francesco.mangiacrapa") .getWorkspace(); // diff --git a/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java b/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java index 3730f28..ae82fe9 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java @@ -11,21 +11,20 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.portlets.user.homelibrary.home.exceptions.UserNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; -import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongDestinationException; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile; -import org.gcube.portlets.user.homelibrary.util.MimeTypeUtil; -import org.gcube.portlets.user.homelibrary.util.WorkspaceUtil; +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.exceptions.UserNotFoundException; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException; +import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; +import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.common.homelibrary.util.MimeTypeUtil; +import org.gcube.common.homelibrary.util.WorkspaceUtil; /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it @@ -42,8 +41,7 @@ public static void main(String[] args) throws InternalErrorException, MalformedS Workspace workspace = HomeLibrary .getHomeManagerFactory() .getHomeManager() - .getHome("francesco.mangiacrapa", - GCUBEScope.getScope("/gcube/devsec")) + .getHome("francesco.mangiacrapa") .getWorkspace(); String filePath = "/home/francesco-mangiacrapa/Desktop/icongeoexplorer"; diff --git a/src/test/java/org/gcube/portlets/user/workspace/UriResolverReaderRR.java b/src/test/java/org/gcube/portlets/user/workspace/UriResolverReaderRR.java index e4ccc8b..41b975e 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/UriResolverReaderRR.java +++ b/src/test/java/org/gcube/portlets/user/workspace/UriResolverReaderRR.java @@ -15,15 +15,14 @@ import java.util.List; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; -import org.gcube.common.core.scope.GCUBEScope; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.homelibrary.home.HomeLibrary; -import org.gcube.portlets.user.homelibrary.home.workspace.Workspace; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; -import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType; -import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem; import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter; import org.gcube.portlets.user.workspace.server.shortener.UrlShortener; @@ -167,8 +166,7 @@ public class UriResolverReaderRR { Workspace workspace = HomeLibrary .getHomeManagerFactory() .getHomeManager() - .getHome("francesco.mangiacrapa", - GCUBEScope.getScope(scope)) + .getHome("francesco.mangiacrapa") .getWorkspace(); GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();