removed unused or commented code
This commit is contained in:
parent
8a492b083d
commit
a716586b69
9
pom.xml
9
pom.xml
|
@ -108,21 +108,18 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.2, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- END FWS -->
|
||||
|
||||
<!-- HOME LIBRARY -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
|
@ -140,7 +137,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -95,76 +95,5 @@ public interface WorkspaceExplorerAppService extends RemoteService {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
String getFolderIdFromEncrypted(String encryptedFolderId) throws Exception;
|
||||
//
|
||||
// /**
|
||||
// * Check name.
|
||||
// *
|
||||
// * @param name the name
|
||||
// * @return true, if successful
|
||||
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||
// */
|
||||
// boolean checkName(String name) throws WorkspaceNavigatorServiceException;
|
||||
//
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Gets the item by category.
|
||||
// *
|
||||
// * @param category the category
|
||||
// * @return the item by category
|
||||
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||
// */
|
||||
// Item getItemByCategory(ItemCategory category)throws WorkspaceNavigatorServiceException;
|
||||
//
|
||||
// /**
|
||||
// * Gets the size by item id.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @return the size by item id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// Long getSizeByItemId(String itemId) throws Exception;
|
||||
//
|
||||
// /**
|
||||
// * Gets the mime type.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @return the mime type
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// String getMimeType(String itemId) throws Exception;
|
||||
//
|
||||
// /**
|
||||
// * Gets the user acl for folder id.
|
||||
// *
|
||||
// * @param folderId the folder id
|
||||
// * @return the user acl for folder id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// String getUserACLForFolderId(String folderId) throws Exception;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Gets the readable size by item id.
|
||||
// *
|
||||
// * @param id the id
|
||||
// * @return the readable size by item id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// String getReadableSizeByItemId(String id) throws Exception;
|
||||
//
|
||||
|
||||
// /**
|
||||
// * Creates the folder.
|
||||
// *
|
||||
// * @param nameFolder the name folder
|
||||
// * @param description the description
|
||||
// * @param parentId the parent id
|
||||
// * @return the item
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// Item createFolder(
|
||||
// String nameFolder, String description, String parentId)
|
||||
// throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -96,75 +96,4 @@ public interface WorkspaceExplorerAppServiceAsync {
|
|||
void getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit,
|
||||
boolean includeItemAsParent, AsyncCallback<List<Item>> callback);
|
||||
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Check name.
|
||||
// *
|
||||
// * @param name the name
|
||||
// * @param callback the callback
|
||||
// */
|
||||
// public void checkName(String name, AsyncCallback<Boolean> callback);
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Gets the item by category.
|
||||
// *
|
||||
// * @param category the category
|
||||
// * @param asyncCallback the async callback
|
||||
// * @return the item by category
|
||||
// */
|
||||
// public void getItemByCategory(ItemCategory category, AsyncCallback<Item> asyncCallback);
|
||||
//
|
||||
|
||||
// /**
|
||||
// * Gets the size by item id.
|
||||
// *
|
||||
// * @param id the id
|
||||
// * @param asyncCallback the async callback
|
||||
// * @return the size by item id
|
||||
// */
|
||||
// public void getSizeByItemId(String id, AsyncCallback<Long> asyncCallback);
|
||||
|
||||
// /**
|
||||
// * Gets the readable size by item id.
|
||||
// *
|
||||
// * @param id the id
|
||||
// * @param asyncCallback the async callback
|
||||
// * @return the readable size by item id
|
||||
// */
|
||||
// public void getReadableSizeByItemId(String id, AsyncCallback<String> asyncCallback);
|
||||
//
|
||||
// /**
|
||||
// * Gets the mime type.
|
||||
// *
|
||||
// * @param id the id
|
||||
// * @param asyncCallback the async callback
|
||||
// * @return the mime type
|
||||
// */
|
||||
// public void getMimeType(String id, AsyncCallback<String> asyncCallback);
|
||||
|
||||
// /**
|
||||
// * Gets the user acl for folder id.
|
||||
// *
|
||||
// * @param id the id
|
||||
// * @param asyncCallback the async callback
|
||||
// * @return the user acl for folder id
|
||||
// */
|
||||
// public void getUserACLForFolderId(String id,
|
||||
// AsyncCallback<String> asyncCallback);
|
||||
|
||||
// /**
|
||||
// * Creates the folder.
|
||||
// *
|
||||
// * @param nameFolder the name folder
|
||||
// * @param description the description
|
||||
// * @param parentId the parent id
|
||||
// * @param callback the callback
|
||||
// */
|
||||
// void createFolder(String nameFolder, String description, String parentId, AsyncCallback<Item> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,14 +4,11 @@
|
|||
package org.gcube.portlets.user.workspaceexplorerapp.server;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -19,17 +16,12 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.GCubeItem;
|
||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
|
||||
|
@ -116,31 +108,31 @@ public class DownloadWorkspaceExplorerServlet extends HttpServlet{
|
|||
try {
|
||||
|
||||
//MULTIPLE DOWNLOAD - CREATE A ZIP FOR SUCH WORKSPACE IDs AND RETURN
|
||||
if(ids.size()>1){
|
||||
List<WorkspaceItem> listWI = toWorkspaceItems(wa, ids);
|
||||
try {
|
||||
//TODO MUST BE IMPLEMENTED
|
||||
// File tmpZip = ZipUtil.zipWorkspaceItems(listWI, null);
|
||||
// resp.setHeader( "Content-Disposition", "attachment; filename=\"gCube Workspace Files - " + new Date() +".zip\"" );
|
||||
// resp.setContentType("application/zip");
|
||||
// resp = setContentLength(resp, tmpZip.length());
|
||||
// OutputStream out = resp.getOutputStream();
|
||||
// if(ids.size()>1){
|
||||
// List<WorkspaceItem> listWI = toWorkspaceItems(wa, ids);
|
||||
// try {
|
||||
// //TODO MUST BE IMPLEMENTED
|
||||
//// File tmpZip = ZipUtil.zipWorkspaceItems(listWI, null);
|
||||
//// resp.setHeader( "Content-Disposition", "attachment; filename=\"gCube Workspace Files - " + new Date() +".zip\"" );
|
||||
//// resp.setContentType("application/zip");
|
||||
//// resp = setContentLength(resp, tmpZip.length());
|
||||
//// OutputStream out = resp.getOutputStream();
|
||||
////
|
||||
//// FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
||||
//// IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
||||
//// fileTmpZip.close();
|
||||
////
|
||||
//// out.close();
|
||||
//// tmpZip.delete();
|
||||
// return;
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// logger.error("Error during folder compression "+itemIds,e);
|
||||
// handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
||||
// IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
||||
// fileTmpZip.close();
|
||||
//
|
||||
// out.close();
|
||||
// tmpZip.delete();
|
||||
return;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Error during folder compression "+itemIds,e);
|
||||
handleError(urlRedirectOnError, req, resp, itemIds, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
//SINGLE DONWLOAD - DOWNLOAD WORKSPACE ITEM
|
||||
item = wa.getItem(ids.get(0));
|
||||
|
|
|
@ -191,21 +191,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the item by category.
|
||||
// *
|
||||
// * @param category the category
|
||||
// * @return the item by category
|
||||
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||
// */
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getItemByCategory(org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory)
|
||||
// */
|
||||
// @Override
|
||||
// public Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
|
||||
// logger.trace("GetItemByCategory category: "+category);
|
||||
// throw new WorkspaceNavigatorServiceException("The method getItemByCategory is not implemented");
|
||||
// }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -248,30 +233,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * {@inheritDoc}
|
||||
// */
|
||||
// @Override
|
||||
// public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
|
||||
// logger.trace("checkName name: "+name);
|
||||
// throw new WorkspaceNavigatorServiceException("The method checkName is not implemented");
|
||||
//// try {
|
||||
//// Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||
//// return workspace.isValidName(name);
|
||||
//// } catch (Exception e) {
|
||||
//// logger.error("Error during folder retrieving", e);
|
||||
//// throw new WorkspaceNavigatorServiceException(e.getMessage());
|
||||
//// }
|
||||
// }
|
||||
|
||||
/*protected void printName(String indentation, Item item)
|
||||
{
|
||||
if(item!=null){
|
||||
_log.trace(indentation+item.getName());
|
||||
for (Item child:item.getChildren()) printName(indentation+"\t", child);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets Breadcrumbs (the list of parents) by item identifier.
|
||||
*
|
||||
|
@ -444,10 +405,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
}
|
||||
|
||||
//WorkspaceItem lastItem = parents.get(parents.size()-1);
|
||||
|
||||
|
||||
|
||||
//Adding the item passed as last first parent
|
||||
if(includeItemAsParent && wsItem.isFolder()) {
|
||||
WorkspaceFolder wsItemAsFolder =(WorkspaceFolder) wsItem;
|
||||
|
@ -503,19 +460,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
fileModel.setParent(parent);
|
||||
}
|
||||
}
|
||||
// if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER OR REACHED PARENT LIMIT
|
||||
// List<Item> breadcrumbs = new ArrayList<Item>();
|
||||
// for (int i=1; i<arrayParents.length; i++) {
|
||||
// if(arrayParents[i]!=null) {
|
||||
// breadcrumbs.add(arrayParents[i]);
|
||||
// }
|
||||
// }
|
||||
// logger.debug("Returning the breadcrumb: "+breadcrumbs);
|
||||
// return breadcrumbs;
|
||||
// }
|
||||
// else {
|
||||
// return new ArrayList<Item>(Arrays.asList(arrayParents));
|
||||
// }
|
||||
|
||||
Collections.reverse(arrayParents);
|
||||
logger.info("Reversed the parent list");
|
||||
|
@ -535,105 +479,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the size by item id.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @return the size by item id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#loadSizeByItemId(java.lang.String)
|
||||
// */
|
||||
// @Override
|
||||
// public Long getSizeByItemId(String itemId) throws Exception {
|
||||
//
|
||||
// logger.info("get Size By ItemId "+ itemId);
|
||||
// try {
|
||||
//
|
||||
// Workspace workspace = getWorkspace();
|
||||
// WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
// Long size = new Long(-1);
|
||||
//
|
||||
// if(wsItem instanceof FileItem){ //ITEM
|
||||
// FileItem fileItem = (FileItem) wsItem;
|
||||
// size = new Long(fileItem.getSize());
|
||||
// } else if (wsItem instanceof WorkspaceFolder ){ //FOLDER
|
||||
// WorkspaceFolder theFolder = (WorkspaceFolder) wsItem;
|
||||
// //size = theFolder.getSize(); NOT SUPPORTED BY SHUB
|
||||
// } else if (wsItem instanceof WorkspaceSharedFolder){ //SHARED FOLDER
|
||||
// WorkspaceSharedFolder theFolder = (WorkspaceSharedFolder) wsItem;
|
||||
// //size = theFolder.getSize(); NOT SUPPORTED BY SHUB
|
||||
// }
|
||||
// logger.info("returning size: " +size);
|
||||
// return size;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// logger.error("get Size By ItemId ", e);
|
||||
// throw new Exception(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Gets the mime type.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @return the mime type
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getMimeType(java.lang.String)
|
||||
// */
|
||||
// @Override
|
||||
// public String getMimeType(String itemId) throws Exception {
|
||||
//
|
||||
// logger.info("get MimeType By ItemId "+ itemId);
|
||||
// try {
|
||||
//
|
||||
// Workspace workspace = getWorkspace();
|
||||
// WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
//
|
||||
// if(wsItem instanceof FileItem) {
|
||||
// FileItem fileItem = (FileItem) wsItem;
|
||||
// return fileItem.getMimeType();
|
||||
// }else
|
||||
// return null;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// logger.error("get MimeType By ItemId ", e);
|
||||
// throw new Exception(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * Gets the user acl for folder id.
|
||||
// *
|
||||
// * @param folderId the folder id
|
||||
// * @return the user acl for folder id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public String getUserACLForFolderId(String folderId) throws Exception{
|
||||
// try {
|
||||
// logger.info("Get user ACL to FOLDER id: "+folderId);
|
||||
// Workspace workspace = getWorkspace();
|
||||
// WorkspaceItem wsItem = workspace.getItem(folderId);
|
||||
//
|
||||
// if(!isASharedFolder(wsItem, false)) {
|
||||
// return "OWNER";
|
||||
// }
|
||||
// else {
|
||||
// return wsItem.getACLUser().toString();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("Error in server get UserACLForFolderId", e);
|
||||
// String error = "An error occurred when getting ACL rules for selected folder. "+e.getMessage();
|
||||
// throw new Exception(error);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is a shared folder.
|
||||
*
|
||||
|
@ -659,95 +504,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Gets the readable size by item id.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @return the readable size by item id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getFormattedSizeByItemId(java.lang.String, org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter)
|
||||
// */
|
||||
// @Override
|
||||
// public String getReadableSizeByItemId(String itemId) throws Exception {
|
||||
//
|
||||
// try{
|
||||
// logger.info("getFormattedSize ByItemId "+ itemId);
|
||||
// long size = getSizeByItemId(itemId);
|
||||
// return StringUtil.readableFileSize(size);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("getFormattedSize By ItemId ", e);
|
||||
// throw new Exception(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Creates the folder.
|
||||
// *
|
||||
// * @param nameFolder the name folder
|
||||
// * @param description the description
|
||||
// * @param parentId the parent id
|
||||
// * @return the item
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.gcube.portlets.user.workspaceexplorerapp.client.rpc.WorkspaceExplorerAppService#createFolder(java.lang.String, java.lang.String, java.lang.String)
|
||||
// */
|
||||
// @Override
|
||||
// public Item createFolder(String nameFolder, String description, String parentId) throws Exception {
|
||||
//
|
||||
// logger.debug("creating folder: "+nameFolder +", parent id: "+parentId);
|
||||
// throw new WorkspaceNavigatorServiceException("The method 'createFolder' is not implemented");
|
||||
//
|
||||
// /*try {
|
||||
//
|
||||
// if(parentId==null || parentId.isEmpty())
|
||||
// throw new Exception("Parent id is null or empty");
|
||||
//
|
||||
// if(nameFolder == null)
|
||||
// nameFolder = "Empty Folder";
|
||||
//
|
||||
// Workspace workspace = getWorkspace();
|
||||
// WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parentId);
|
||||
// List<ItemType> allTypes = Arrays.asList(ItemType.values());
|
||||
//
|
||||
// Item parent = null;
|
||||
// try{
|
||||
// String parentPath = wsFolder.getParent()!=null?wsFolder.getParent().getPath():"";
|
||||
// parent = ItemBuilder.getItem(null, wsFolder.getParent(), parentPath, allTypes, null, false);
|
||||
// }catch(Exception e){
|
||||
// logger.error("Get parent thown an exception, is it the root id? "+parentId);
|
||||
// }
|
||||
//
|
||||
// //TODO PATCH TO AVOID PROBLEM ON GETPATH. FOR EXAMPLE WHEN PARENT IS ROOT
|
||||
// String itemPath = null;
|
||||
// try{
|
||||
// itemPath = wsFolder.getPath();
|
||||
// }catch(Exception e){
|
||||
// logger.error("Get path thown an exception, for id: "+wsFolder.getId());
|
||||
// itemPath= wsFolder.isFolder()?workspace.getRoot().getPath()+"/"+wsFolder.getName():workspace.getRoot().getPath();
|
||||
// }
|
||||
//
|
||||
// return ItemBuilder.getItem(parent, wsFolder, itemPath, allTypes, null, false);
|
||||
//
|
||||
// } catch(InsufficientPrivilegesException e){
|
||||
// String error = "Insufficient Privileges to create the folder";
|
||||
// logger.error(error, e);
|
||||
// throw new Exception(error);
|
||||
// } catch (ItemAlreadyExistException e) {
|
||||
// String error = "An error occurred on creating folder, " +e.getMessage();
|
||||
// logger.error(error, e);
|
||||
// throw new Exception(error);
|
||||
// } catch (Exception e) {
|
||||
// String error = "An error occurred on the sever during creating folder. Try again";
|
||||
// logger.error(error, e);
|
||||
// throw new Exception(error);
|
||||
// }*/
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Gets the public link for item id.
|
||||
*
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class WsUtil.
|
||||
*
|
||||
|
@ -20,6 +21,7 @@ public class WsUtil {
|
|||
|
||||
public static final Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||
public static final String ENVIRONMENT_VARIABLE_SCOPE_NAME = "EnvironmentVariableScope";
|
||||
public static final String ENVIRONMENT_VARIABLE_TOKEN_NAME = "EnvironmentVariableAppToken";
|
||||
public static final String SESSION_SCOPE = "session_scope";
|
||||
|
||||
/**
|
||||
|
@ -33,16 +35,22 @@ public class WsUtil {
|
|||
|
||||
try {
|
||||
String scope = getScope(httpSession);
|
||||
// TODO
|
||||
String applicationToken = getApplicationToken(httpSession);
|
||||
|
||||
if(applicationToken==null || applicationToken.isEmpty()) {
|
||||
String token = "9b397e7a-c683-44dc-b65b-53725b98f7e5-98187548";
|
||||
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() +
|
||||
// TODO
|
||||
logger.warn("\n\n\nALERT!!!! FALLBACK DETECTED TO INSTANCE THE SHUB");
|
||||
logger.warn("Calling the " + StorageHubWrapper.class.getSimpleName() +
|
||||
" by token: " + token.substring(0, 10) +" MASKED TOKEN" +
|
||||
" by using the scope: " + scope);
|
||||
logger.warn("\n\n\n HAVE TO REMOVE THIS CODE!!!\n\n\n");
|
||||
}
|
||||
|
||||
return new StorageHubWrapper(scope, token, false, false, true);
|
||||
return new StorageHubWrapper(scope, applicationToken, false, false, true);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error when instancing the storageHub wrapper", e);
|
||||
throw new Exception("Error on inizializing the StorageHub wrapper");
|
||||
throw new Exception("Error on inizializing the StorageHub wrapper. Please contact the support!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,4 +95,31 @@ public class WsUtil {
|
|||
httpSession.setAttribute(ENVIRONMENT_VARIABLE_SCOPE_NAME, scope);
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the application token.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @return the application token
|
||||
*/
|
||||
public static String getApplicationToken(HttpSession httpSession) {
|
||||
|
||||
String appToken = null;
|
||||
String appTokenEnvVarName = null;
|
||||
try {
|
||||
logger.info("Reading " + ENVIRONMENT_VARIABLE_TOKEN_NAME + " from web.xml context");
|
||||
appTokenEnvVarName = httpSession.getServletContext()
|
||||
.getInitParameter(ENVIRONMENT_VARIABLE_TOKEN_NAME);
|
||||
logger.info("Found param-value '" + appTokenEnvVarName
|
||||
+ "' from web context, reading its value from ENVIRONMENT");
|
||||
appToken = System.getenv(appTokenEnvVarName);
|
||||
logger.info("Value of " + appTokenEnvVarName + " from ENVIRONMENT is: " + appToken);
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("Error on reading the ENV VARIABLE '"+appTokenEnvVarName+"' from ENVIRONMENT");
|
||||
}
|
||||
|
||||
return appToken;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<context-param>
|
||||
<description>Scope used ton instance the HL</description>
|
||||
<description>Value of environment variable used to read the SCOPE to call the SHUB</description>
|
||||
<param-name>EnvironmentVariableScope</param-name>
|
||||
<!-- <param-value>/d4science.research-infrastructures.eu</param-value> -->
|
||||
<param-value>SCOPE</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<description>Value of environment variable used to read the APPLICATION TOKEN to call the SHUB</description>
|
||||
<param-name>EnvironmentVariableAppToken</param-name>
|
||||
<param-value>WORKSPACE_EXPLORER_APP_APPLICATION_TOKEN</param-value>
|
||||
</context-param>
|
||||
<servlet>
|
||||
<servlet-name>workspaceExplorerAppServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl</servlet-class>
|
||||
|
|
Loading…
Reference in New Issue