Updated requests on storage by id

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@114529 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-29 09:51:21 +00:00
parent dfd2fb86e5
commit 3a7cafc7df
4 changed files with 157 additions and 68 deletions

View File

@ -161,6 +161,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TDTypeValueMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.server.uriresolver.UriResolverTDClient;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
@ -193,9 +194,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationM
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorCreator;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
@ -295,7 +296,6 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.PeriodDataT
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.RelationshipData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ValueDataFormat;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
@ -9024,66 +9024,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("Get uri from resolver: " + uriResolverSession);
UriResolverManager resolver;
Map<String, String> params = new HashMap<String, String>();
switch (uriResolverSession.getApplicationType()) {
case GIS:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("gis-UUID", uriResolverSession.getUuid());
params.put("scope", aslSession.getScope());
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
case SMP:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("smp-uri", uriResolverSession.getUuid());
if (uriResolverSession.getFileName() == null) {
params.put("fileName", "");
} else {
params.put("fileName", uriResolverSession.getFileName());
}
if (uriResolverSession.getMimeType() == null) {
params.put("contentType", "");
} else {
params.put("contentType", uriResolverSession.getMimeType());
}
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
case SMP_ID:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("smp-id", uriResolverSession.getUuid());
if (uriResolverSession.getFileName() == null) {
params.put("fileName", "");
} else {
params.put("fileName", uriResolverSession.getFileName());
}
if (uriResolverSession.getMimeType() == null) {
params.put("contentType", "");
} else {
params.put("contentType", uriResolverSession.getMimeType());
}
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
default:
logger.debug("No resolver enable on this application type");
throw new TDGWTServiceException(
"Error retrieving uri from resolver:"
+ " No resolver enable on this application type");
}
logger.debug("Retrieved Link: " + link);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
return link;
} catch (TDGWTServiceException e) {
@ -9258,8 +9202,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
}
String link = getUriFromResolver(uriResolverSession);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
String link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
if (link == null || link.isEmpty()) {
throw new TDGWTServiceException(

View File

@ -0,0 +1,109 @@
package org.gcube.portlets.user.td.gwtservice.server.uriresolver;
import java.util.HashMap;
import java.util.Map;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Client for retrieve link
*
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class UriResolverTDClient {
private static Logger logger = LoggerFactory
.getLogger(UriResolverTDClient.class);
public UriResolverTDClient() {
}
public String resolve(UriResolverSession uriResolverSession,
ASLSession aslSession) throws TDGWTServiceException {
try {
String link = "";
logger.debug("Get uri from resolver: " + uriResolverSession);
UriResolverManager resolver;
Map<String, String> params = new HashMap<String, String>();
switch (uriResolverSession.getApplicationType()) {
case GIS:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("gis-UUID", uriResolverSession.getUuid());
params.put("scope", aslSession.getScope());
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
case SMP:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("smp-uri", uriResolverSession.getUuid());
if (uriResolverSession.getFileName() == null) {
params.put("fileName", "");
} else {
params.put("fileName", uriResolverSession.getFileName());
}
if (uriResolverSession.getMimeType() == null) {
params.put("contentType", "");
} else {
params.put("contentType", uriResolverSession.getMimeType());
}
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
case SMP_ID:
resolver = new UriResolverManager(uriResolverSession
.getApplicationType().toString());
params.put("smp-id", uriResolverSession.getUuid());
if (uriResolverSession.getFileName() == null) {
params.put("fileName", "");
} else {
params.put("fileName", uriResolverSession.getFileName());
}
if (uriResolverSession.getMimeType() == null) {
params.put("contentType", "");
} else {
params.put("contentType", uriResolverSession.getMimeType());
}
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none
break;
default:
logger.debug("No resolver enable on this application type");
throw new TDGWTServiceException(
"Error retrieving uri from resolver:"
+ " No resolver enable on this application type");
}
logger.debug("Retrieved Link: " + link);
return link;
} catch (TDGWTServiceException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error retrieving uri from resolver: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -30,6 +30,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap;
import org.gcube.portlets.user.td.gwtservice.server.uriresolver.UriResolverTDClient;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
@ -40,7 +41,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsJobS;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabExportMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -420,7 +423,14 @@ public class BackgroundOperationMonitorCreator {
+ exportSession.getFileDescription()
+ " ,mimetype: text/csv" + " ,folder: "
+ exportSession.getItemId() + "]");
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
UriResolverSession uriResolverSession = new UriResolverSession(
exportMetadata.getUri(), ApplicationType.SMP_ID);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
String link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
storage.createItemOnWorkspace(link, user,
exportSession.getFileName(),
exportSession.getFileDescription(), "text/csv",
exportSession.getItemId());
@ -466,7 +476,14 @@ public class BackgroundOperationMonitorCreator {
+ exportSession.getFileDescription()
+ " ,mimetype: application/json" + " ,folder: "
+ exportSession.getItemId() + "]");
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
UriResolverSession uriResolverSession = new UriResolverSession(
exportMetadata.getUri(), ApplicationType.SMP_ID);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
String link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
storage.createItemOnWorkspace(link, user,
exportSession.getFileName(),
exportSession.getFileDescription(), "application/json",
exportSession.getItemId());

View File

@ -29,6 +29,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap;
import org.gcube.portlets.user.td.gwtservice.server.uriresolver.UriResolverTDClient;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
@ -40,7 +41,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsJobS;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabExportMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -475,7 +478,14 @@ public class OperationMonitorCreator {
+ exportSession.getFileDescription()
+ " ,mimetype: text/csv" + " ,folder: "
+ exportSession.getItemId() + "]");
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
UriResolverSession uriResolverSession = new UriResolverSession(
exportMetadata.getUri(), ApplicationType.SMP_ID);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
String link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
storage.createItemOnWorkspace(link, user,
exportSession.getFileName(),
exportSession.getFileDescription(), "text/csv",
exportSession.getItemId());
@ -521,7 +531,14 @@ public class OperationMonitorCreator {
+ exportSession.getFileDescription()
+ " ,mimetype: application/json" + " ,folder: "
+ exportSession.getItemId() + "]");
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
UriResolverSession uriResolverSession = new UriResolverSession(
exportMetadata.getUri(), ApplicationType.SMP_ID);
UriResolverTDClient uriResolverTDClient=new UriResolverTDClient();
String link=uriResolverTDClient.resolve(uriResolverSession, aslSession);
storage.createItemOnWorkspace(link, user,
exportSession.getFileName(),
exportSession.getFileDescription(), "application/json",
exportSession.getItemId());