starting migration to SHUB

This commit is contained in:
Francesco Mangiacrapa 2020-04-08 18:17:48 +02:00
parent ceb922e245
commit 06b3a2a987
8 changed files with 143 additions and 103 deletions

View File

@ -17,11 +17,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -2,4 +2,5 @@
<faceted-project>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.5"/>
<installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>

30
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-explorer-app</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<packaging>war</packaging>
<description>
@ -73,7 +73,6 @@
<scope>compile</scope>
</dependency>
<!-- GwtMaterial -->
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
@ -114,24 +113,16 @@
<!-- END FWS -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.applicationsupportlayer</groupId> -->
<!-- <artifactId>aslcore</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- HOME LIBRARY -->
<dependency>
<!-- <dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>asm-debug-all</artifactId>
@ -143,13 +134,19 @@
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>asm-all</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>[0.0.1, 1.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -166,13 +163,6 @@
<version>1.8</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.widgets</groupId> -->
<!-- <artifactId>workspace-explorer</artifactId> -->
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<!-- </dependency> -->
<!-- LOGGER -->
<dependency>
<groupId>org.slf4j</groupId>
@ -249,7 +239,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<!-- <version>${maven-war-plugin.version}</version> -->
<executions>
<execution>
<phase>compile</phase>

View File

@ -10,13 +10,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
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.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
import org.gcube.portlets.user.workspaceexplorerapp.client.Util;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.shared.FilterCriteria;
@ -163,32 +158,38 @@ public class ItemBuilder {
* @return the item type
* @throws InternalErrorException the internal error exception
*/
protected static ItemType getItemType(WorkspaceItem item) throws InternalErrorException
{
switch(item.getType())
{
case SHARED_FOLDER:
case FOLDER:{
protected static ItemType getItemType(WorkspaceItem item) {
switch (item.getType()) {
case SHARED_FOLDER:
case FOLDER: {
// if (item.isRoot()) return ItemType.ROOT;
return ItemType.FOLDER;
}
case FOLDER_ITEM: return getFolderItemType((FolderItem) item);
return ItemType.FOLDER;
}
case FILE_ITEM:
default:
return null;
if (item instanceof FileItem)
return getFileItemType((FileItem) item);
else
return ItemType.UNKNOWN_TYPE;
default:
return null;
}
}
/**
* Gets the folder item type.
* Gets the file item type.
*
* @param item the item
* @return the folder item type
* @return the file item type
*/
protected static ItemType getFolderItemType(FolderItem item){
protected static ItemType getFileItemType(FileItem item){
try{
return ItemType.valueOf(item.getFolderItemType().toString());
return ItemType.valueOf(item.getFileItemType().toString());
}catch (Exception e) {
_log.error("Item Type non found: ",e);
return ItemType.UNKNOWN_TYPE;

View File

@ -7,15 +7,9 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
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.WorkspaceSharedFolder;
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.folder.FolderItem;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.client.rpc.WorkspaceExplorerAppService;
import org.gcube.portlets.user.workspaceexplorerapp.shared.FilterCriteria;
@ -57,7 +51,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
logger.trace("Start getRoot...");
WorkspaceItem root = workspace.getRoot();
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder root = workspace.getRoot();
logger.trace("GetRoot - Replyiing root");
long startTime = System.currentTimeMillis();

View File

@ -5,22 +5,15 @@ package org.gcube.portlets.user.workspaceexplorerapp.server;
import javax.servlet.http.HttpSession;
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.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/**
* The Class WsUtil.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 13, 2016
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 13, 2016
*/
public class WsUtil {
@ -29,40 +22,88 @@ public class WsUtil {
public static final String SESSION_SCOPE = "session_scope";
/**
* Gets the workspace.
* Gets the storage hub wrapper.
*
* @param httpSession the http session
* @return the workspace
* @throws InternalErrorException the internal error exception
* @throws HomeNotFoundException the home not found exception
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
* @throws UserNotFoundException the user not found exception
* @return the storage hub wrapper
* @throws Exception the exception
*/
public static Workspace getWorkspace(HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException {
// ASLSession session = getASLSession(httpSession);
public static StorageHubWrapper getStorageHubWrapper(HttpSession httpSession) throws Exception {
String scope = getScope(httpSession);
//GET CONTEXT
logger.info("Setting scope: "+scope);
ScopeProvider.instance.set(scope);
return HomeLibrary.getHomeManagerFactory().getHomeManager().getGuestLogin().getWorkspace();
try {
String scope = getScope(httpSession);
// TODO
String token = "MUST BE PROVIDED";
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() +
" by token: " + token.substring(0, 10) +" MASKED TOKEN" +
" by using the scope: " + scope);
return new StorageHubWrapper(scope, token, false, false, true);
} catch (Exception e) {
logger.error("Error during getting storageHub wrapper", e);
throw new Exception("Error on inizializing the StorageHub");
}
}
/**
* Gets the workpace.
*
* @param httpSession the http session
* @return the workpace
* @throws Exception the exception
*/
public static org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspace(HttpSession httpSession) throws Exception {
try {
StorageHubWrapper wrapper = getStorageHubWrapper(httpSession);
return wrapper.getWorkspace();
} catch (Exception e) {
logger.error("Error on getting the Workspace", e);
throw new Exception("Error on getting the Workspace");
}
}
// /**
// * Gets the workspace.
// *
// * @param httpSession the http session
// * @return the workspace
// * @throws InternalErrorException the internal error exception
// * @throws HomeNotFoundException the home not found exception
// * @throws WorkspaceFolderNotFoundException the workspace folder not found
// * exception
// * @throws UserNotFoundException the user not found exception
// */
// public static Workspace getWorkspace(HttpSession httpSession) throws InternalErrorException, HomeNotFoundException,
// WorkspaceFolderNotFoundException, UserNotFoundException {
//// ASLSession session = getASLSession(httpSession);
//
// String scope = getScope(httpSession);
// // GET CONTEXT
// logger.info("Setting scope: " + scope);
// ScopeProvider.instance.set(scope);
// return HomeLibrary.getHomeManagerFactory().getHomeManager().getGuestLogin().getWorkspace();
// }
/**
* Gets the scope.
*
* @param httpSession the http session
* @return the scope
*/
public static String getScope(HttpSession httpSession){
String scope = (String) httpSession.getAttribute(SESSION_SCOPE);
logger.info("Variable "+SESSION_SCOPE + " read from httpsession is: "+scope);
public static String getScope(HttpSession httpSession) {
String scope = (String) httpSession.getAttribute(SESSION_SCOPE);
logger.info("Variable " + SESSION_SCOPE + " read from httpsession is: " + scope);
if(scope==null){
logger.info("Variable "+SESSION_SCOPE + " is null reading from web.xml context");
String variableScopeName = httpSession.getServletContext().getInitParameter(ENVIRONMENT_VARIABLE_SCOPE_NAME);
logger.info("Found param-value '"+variableScopeName+"' from web context, reading its value from ENVIRONMENT");
if (scope == null) {
logger.info("Variable " + SESSION_SCOPE + " is null reading from web.xml context");
String variableScopeName = httpSession.getServletContext()
.getInitParameter(ENVIRONMENT_VARIABLE_SCOPE_NAME);
logger.info("Found param-value '" + variableScopeName
+ "' from web context, reading its value from ENVIRONMENT");
scope = System.getenv(variableScopeName);
logger.info("Value of "+variableScopeName+" from ENVIRONMENT is: "+scope);
logger.info("Value of " + variableScopeName + " from ENVIRONMENT is: " + scope);
}
httpSession.setAttribute(ENVIRONMENT_VARIABLE_SCOPE_NAME, scope);

View File

@ -3,29 +3,40 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.shared;
/**
* The Enum ItemType.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 18, 2015
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 18, 2015
*/
public enum ItemType {
FOLDER, //MANDATORY
EXTERNAL_IMAGE,
EXTERNAL_FILE,
EXTERNAL_PDF_FILE,
EXTERNAL_URL,
QUERY,
REPORT_TEMPLATE,
REPORT,
FOLDER,
// KINDS OF FILES
/**
* Document.
*/
DOCUMENT,
METADATA,
PDF_DOCUMENT,
/**
* Image document.
*/
IMAGE_DOCUMENT,
/**
* PDF document.
*/
PDF_DOCUMENT,
/**
* Url document.
*/
URL_DOCUMENT,
/**
* Metadata.
*/
METADATA,
/**
* A gCube item.
*/
GCUBE_ITEM,
TIME_SERIES,
UNKNOWN_TYPE;
UNKNOWN_TYPE
}