diff --git a/distro/changelog.xml b/distro/changelog.xml index 3ca03d6..695e6ec 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,7 @@ + + Removed ASL Dependency, ported to gCube Client Context + [Feature #5091] Added load for folder ID to SelectDialog and SelectPanel diff --git a/pom.xml b/pom.xml index 68e5db8..70296a9 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 org.gcube.portlets.widgets workspace-explorer - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT gCube Workspace Explorer gCube Workspace Explorer widget allows to navigate (gCube) Workspace @@ -81,8 +81,8 @@ - org.gcube.applicationsupportlayer - aslcore + org.gcube.common.portal + portal-manager provided @@ -90,37 +90,25 @@ org.gcube.common home-library-model - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) provided org.gcube.common home-library-jcr - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided org.gcube.common home-library - - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided - - - asm-all - asm - - - org.gcube.dvos usermanagement-core provided - - + com.liferay.portal portal-service diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java index 330bba5..91d2292 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java @@ -10,8 +10,6 @@ import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpSession; -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.application.framework.core.session.SessionManager; import org.gcube.common.homelibary.model.items.type.WorkspaceItemType; import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; @@ -24,6 +22,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivil 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.folder.FolderItem; +import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants; import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService; @@ -43,7 +42,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; * The Class WorkspaceExplorerServiceImpl. * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Sep 21, 2016 + * @author Massimiliano Assante, CNR-ISTI */ @SuppressWarnings("serial") public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implements WorkspaceExplorerService { @@ -55,56 +54,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement // public static final String PRODUCTION_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION /** - * Gets the ASL session. - * - * @param httpSession the http session - * @return the ASL session - * @throws Exception the exception - */ - private ASLSession getASLSession(HttpSession httpSession) throws Exception { - String sessionID = httpSession.getId(); - String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE); - ASLSession session; - - //TODO we check for the older attribute name - if (user == null) { - user = (String) httpSession.getAttribute("user"); - } - - if (user == null) { - - /*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING - * COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/ - user=TEST_USER; - - logger.warn("WORKSPACE EXPLORER STARTING IN TEST MODE - NO USER FOUND - USING FOLLOWING SETTINGS:"); - - if (!UserUtil.isWithinPortal()) { //DEV MODE - user = "francesco.mangiacrapa"; - } - - logger.warn("session id: "+sessionID); - logger.warn("TEST_USER: "+user); - logger.warn("TEST_SCOPE: "+TEST_SCOPE); - logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE); - session = SessionManager.getInstance().getASLSession(sessionID, user); - if(session==null) - throw new Exception("ASLSession is null"); - - session.setScope(TEST_SCOPE); - - //SET HTTP SESSION ATTRIBUTE - httpSession.setAttribute(USERNAME_ATTRIBUTE, user); - - return session; - } - else { - logger.trace("user found in session "+user); - } - return SessionManager.getInstance().getASLSession(sessionID, user); - } - - + /** * Gets the workspace. * @@ -112,11 +62,11 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement * @throws Exception the exception */ protected Workspace getWorkspace() throws Exception { - ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); + PortalContext pContext = PortalContext.getConfiguration(); Workspace workspace; try{ - ScopeProvider.instance.set(session.getScope()); - workspace = HomeLibrary.getUserWorkspace(session.getUsername()); + ScopeProvider.instance.set(pContext.getCurrentScope(getThreadLocalRequest())); + workspace = HomeLibrary.getUserWorkspace(pContext.getCurrentUser(getThreadLocalRequest()).getUsername()); }catch(InternalErrorException | HomeNotFoundException | WorkspaceFolderNotFoundException e){ String msg = "Sorry, an error occurred when retrieving workspace item, Refresh an try again"; logger.error("HL error: ",e); @@ -231,8 +181,8 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement switch(category){ case HOME:{ WorkspaceItem root = workspace.getRoot(); - ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); - String fullName = UserUtil.getUserFullName(session.getUsername()); + PortalContext pContext = PortalContext.getConfiguration(); + String fullName = pContext.getCurrentUser(getThreadLocalRequest()).getFullname(); if(fullName.indexOf(" ")>0){ fullName = fullName.substring(0, fullName.indexOf(" ")); }else if(fullName.indexOf(".")>0){ @@ -309,8 +259,8 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement public boolean checkName(String name) throws WorkspaceNavigatorServiceException { logger.trace("checkName name: "+name); try { - ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); - Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); + PortalContext pContext = PortalContext.getConfiguration(); + Workspace workspace = HomeLibrary.getUserWorkspace(pContext.getCurrentUser(getThreadLocalRequest()).getUsername()); return workspace.isValidName(name); } catch (Exception e) { logger.error("Error during folder retrieving", e);