Added Uri Resolver
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@100790 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
78182ecb33
commit
ee8ba0adb2
9
pom.xml
9
pom.xml
|
@ -177,6 +177,13 @@
|
|||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Uri Resolver Manager -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>uri-resolver-manager</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- tabular-data-widget-common-event -->
|
||||
<dependency>
|
||||
|
@ -186,6 +193,8 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
@ -106,6 +107,16 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public TRId restoreUISession() throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Resolve Uri
|
||||
*
|
||||
* @param uriResolverSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String getUriFromResolver(UriResolverSession uriResolverSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// TabularResource
|
||||
/**
|
||||
* Get current TRId
|
||||
|
@ -121,8 +132,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public TabResource getInSessionTabResourceInfo() throws TDGWTServiceException;
|
||||
|
||||
public TabResource getInSessionTabResourceInfo()
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Get informations on the current tabular resource call service
|
||||
|
@ -245,8 +256,8 @@ public interface TDGWTService extends RemoteService {
|
|||
public void closeAllTabularResources() throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Close Tabular Resource with TRId equals to closeTRId
|
||||
* and open if not null that with TRId equals to openTRId
|
||||
* Close Tabular Resource with TRId equals to closeTRId and open if not null
|
||||
* that with TRId equals to openTRId
|
||||
*
|
||||
* @param openTRId
|
||||
* @throws TDGWTServiceException
|
||||
|
@ -354,7 +365,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setShare(ShareTabResource shareInfo) throws TDGWTServiceException;
|
||||
public void setShare(ShareTabResource shareInfo)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Share template
|
||||
|
@ -363,9 +375,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setShareTemplate(ShareTemplate shareTemplate) throws TDGWTServiceException;
|
||||
|
||||
|
||||
public void setShareTemplate(ShareTemplate shareTemplate)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Open
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
@ -85,6 +86,8 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void restoreUISession(AsyncCallback<TRId> callback);
|
||||
|
||||
void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback<String> callback);
|
||||
|
||||
// TabularResource
|
||||
void getCurrentTRId(AsyncCallback<TRId> callback);
|
||||
|
||||
|
|
|
@ -82,13 +82,12 @@ public class SessionUtil {
|
|||
|
||||
// Remove comment for Test
|
||||
/*
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
* username = Constants.DEFAULT_USER; String scope =
|
||||
* Constants.DEFAULT_SCOPE;
|
||||
*
|
||||
* httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
|
||||
* username); session = SessionManager.getInstance().getASLSession(
|
||||
* httpSession.getId(), username); session.setScope(scope);
|
||||
*/
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
|
@ -206,6 +205,10 @@ public class SessionUtil {
|
|||
|
||||
public static void addToCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession, TabResource tabResource) {
|
||||
if (tabResource.getTrId() != null
|
||||
&& tabResource.getTrId().getId() != null
|
||||
& !tabResource.getTrId().getId().isEmpty()) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> t = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
|
@ -227,6 +230,7 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(
|
||||
SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFromCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession, TRId trId) {
|
||||
|
|
|
@ -243,9 +243,11 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.RelationshipData;
|
||||
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;
|
||||
|
@ -1777,8 +1779,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
|
||||
GregorianCalendar validUntilToC = new GregorianCalendar();
|
||||
validUntilToC.setTime(dateU);
|
||||
ValidUntilMetadata validUntil = new ValidUntilMetadata();
|
||||
validUntil.setValue(validUntilToC);
|
||||
ValidUntilMetadata validUntil = new ValidUntilMetadata(
|
||||
validUntilToC);
|
||||
tr.setMetadata(validUntil);
|
||||
} catch (ParseException e) {
|
||||
logger.info("ValidUntilMetadata is not set, no valid calendar present");
|
||||
|
@ -5099,8 +5101,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
|
||||
GregorianCalendar validUntilToC = new GregorianCalendar();
|
||||
validUntilToC.setTime(dateU);
|
||||
ValidUntilMetadata validUntil = new ValidUntilMetadata();
|
||||
validUntil.setValue(validUntilToC);
|
||||
ValidUntilMetadata validUntil = new ValidUntilMetadata(
|
||||
validUntilToC);
|
||||
tr.setMetadata(validUntil);
|
||||
} catch (ParseException e) {
|
||||
logger.info("ValidUntilMetadata is not set, no valid calendar present");
|
||||
|
@ -7215,4 +7217,49 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getUriFromResolver(UriResolverSession uriResolverSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
String link = "";
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
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());
|
||||
link = resolver.getLink(params, true); // true, link is shorted otherwise none
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return link;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error retrieving uri from resolver: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,17 +88,14 @@ public class ResourceTDCreator {
|
|||
* @param resource
|
||||
* @return
|
||||
*/
|
||||
public ResourceTD createResourceTD(Resource resource) {
|
||||
protected ResourceTD createResourceTD(Resource resource) {
|
||||
ResourceTD resourceTD = null;
|
||||
|
||||
Class<? extends Resource> resourceClass = resource.getResourceType();
|
||||
if (resourceClass == InternalURI.class) {
|
||||
InternalURI internalURI = (InternalURI) resource;
|
||||
String uri=null;
|
||||
if(internalURI.getUri()!=null){
|
||||
uri=internalURI
|
||||
.getUri().toString();
|
||||
}
|
||||
|
||||
return new InternalURITD(internalURI.getFileId(),uri);
|
||||
} else {
|
||||
if (resourceClass == StringResource.class) {
|
||||
|
@ -119,4 +116,7 @@ public class ResourceTDCreator {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.uriresolver;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class UriResolverSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8088974004393312527L;
|
||||
|
||||
private String uuid;
|
||||
private ApplicationType applicationType;
|
||||
|
||||
public UriResolverSession() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UriResolverSession(String uuid, ApplicationType applicationType) {
|
||||
super();
|
||||
this.uuid = uuid;
|
||||
this.applicationType = applicationType;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public ApplicationType getApplicationType() {
|
||||
return applicationType;
|
||||
}
|
||||
|
||||
public void setApplicationType(ApplicationType applicationType) {
|
||||
this.applicationType = applicationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UriResolverSession [uuid=" + uuid + ", applicationType="
|
||||
+ applicationType + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue