Ported to storagehub-client-wrapper [1.0.0, 2.0.0-SNAPSHOT)
This commit is contained in:
parent
061fae3cbc
commit
333cd2b7b1
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="lib" path="/home/francesco-mangiacrapa/libraries/asm-5.0.3/lib/asm-5.0.3.jar"/>
|
||||
<classpathentry kind="src" output="target/species-discovery-3.10.0/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/species-discovery-3.11.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/species-discovery-3.10.0/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/species-discovery-3.11.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -41,5 +41,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/species-discovery-3.10.0/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/species-discovery-3.11.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/species-discovery/target/species-discovery-3.10.0
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/species-discovery/target/species-discovery-3.11.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="species-discovery-3.10.0">
|
||||
|
||||
<wb-module deploy-name="species-discovery-3.11.0-SNAPSHOT">
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
|
||||
<property name="context-root" value="species-discovery"/>
|
||||
</wb-module>
|
||||
|
||||
</wb-module>
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- Ported to maven-portal-bom v3.6.3
|
||||
- Ported to workspace-explorer v2.X.Y
|
||||
- Ported to geonetwork [3.4.5,4.0.0-SNAPSHOT)
|
||||
- Ported to storagehub-client-wrapper [1.0.0, 2.0.0-SNAPSHOT)
|
||||
|
||||
## [v3.10.0] - 22-05-2020
|
||||
|
||||
|
|
17
pom.xml
17
pom.xml
|
@ -245,6 +245,7 @@
|
|||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
|
@ -263,6 +264,20 @@
|
|||
<!-- <scope>provided</scope> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- PORTAL MANAGER -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-wrapper</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
|
@ -293,7 +308,7 @@
|
|||
<!-- <version>1.6.4</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,33 +3,99 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.speciesdiscovery.server.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Oct 7, 2013
|
||||
* The Class GetWorkspaceUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 27, 2021
|
||||
*/
|
||||
public class GetWorkspaceUtil {
|
||||
|
||||
protected static Logger logger = Logger.getLogger(GetWorkspaceUtil.class);
|
||||
|
||||
public static Workspace getWorskspace(ASLSession session) throws Exception {
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
* @param request the request
|
||||
* @param session the session
|
||||
* @return the workspace
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static Workspace getWorkspace(final HttpServletRequest request, ASLSession session) throws Exception {
|
||||
|
||||
if(session==null)
|
||||
if (session == null)
|
||||
throw new Exception("ASL session is null");
|
||||
|
||||
if(session.getScope()==null)
|
||||
if (session.getScope() == null)
|
||||
throw new Exception("Scope into ASL session is null");
|
||||
|
||||
String scope = session.getScope().toString();
|
||||
//logger.trace("Get workspace for scope "+scope);
|
||||
//ScopeProvider.instance.set(scope);
|
||||
//logger.trace("ScopeProvider instancied for scope "+scope);
|
||||
logger.trace("retuning workspace for username "+session.getUsername());
|
||||
return HomeLibrary.getUserWorkspace(session.getUsername());
|
||||
// logger.trace("Get workspace for scope "+scope);
|
||||
// ScopeProvider.instance.set(scope);
|
||||
// logger.trace("ScopeProvider instancied for scope "+scope);
|
||||
logger.trace("retuning workspace for username " + session.getUsername());
|
||||
return getStorageHubWrapper(null, null, session.getUsername()).getWorkspace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is within portal.
|
||||
*
|
||||
* @return true if you're running into the portal, false if in development
|
||||
*/
|
||||
public static boolean isWithinPortal() {
|
||||
try {
|
||||
UserLocalServiceUtil.getService();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
logger.trace("Development Mode ON");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the storage hub wrapper.
|
||||
*
|
||||
* @param request the request
|
||||
* @param scopeGroupId the scope group id. If scopeGroupId is null the scope is
|
||||
* read by using the request else by using the scopeGroupId
|
||||
* @param username the username
|
||||
* @return the storage hub wrapper
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static StorageHubWrapper getStorageHubWrapper(final HttpServletRequest request, String scopeGroupId,
|
||||
String username) throws Exception {
|
||||
|
||||
if (username == null || username.isEmpty())
|
||||
throw new Exception("Session expired");
|
||||
|
||||
try {
|
||||
String scope;
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
if (isWithinPortal() && scopeGroupId != null) {
|
||||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
logger.debug(scope + " has retrieved by using the scopeGroupId=" + scopeGroupId);
|
||||
} else
|
||||
scope = pContext.getCurrentScope(request);
|
||||
|
||||
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() + " for user: " + username
|
||||
+ " by using the scope: " + scope);
|
||||
String token = pContext.getCurrentUserToken(scope, username);
|
||||
return new StorageHubWrapper(scope, token, false, false, true);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during getting storageHub wrapper", e);
|
||||
throw new Exception("Error on gettig the StorageHub wrapper for userId: " + username);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in New Issue