diff --git a/pom.xml b/pom.xml
index f968070..cd7b048 100644
--- a/pom.xml
+++ b/pom.xml
@@ -176,7 +176,14 @@
org.gcube.contentmanagement
storage-manager-wrapper
-
+
+
+
+ org.gcube.portlets.user
+ uri-resolver-manager
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+
+
@@ -185,6 +192,8 @@
[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
provided
+
+
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
index c08a0cf..91bb58c 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
@@ -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;
@@ -97,7 +98,7 @@ public interface TDGWTService extends RemoteService {
* @throws TDGWTServiceException
*/
public UserInfo hello() throws TDGWTServiceException;
-
+
/**
* Restore UI session
*
@@ -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,9 +132,9 @@ 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,15 +256,15 @@ 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
*/
public void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId)
throws TDGWTServiceException;
-
+
/**
* Close Tabular Resource with TRId equals to closeTRId
*
@@ -262,7 +273,7 @@ public interface TDGWTService extends RemoteService {
*/
public void closeTabularResource(TRId closeTRId)
throws TDGWTServiceException;
-
+
/**
* Set Current Tabular Resource that passed as parameter if not null
*
@@ -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,10 +375,9 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
- public void setShareTemplate(ShareTemplate shareTemplate) throws TDGWTServiceException;
+ public void setShareTemplate(ShareTemplate shareTemplate)
+ throws TDGWTServiceException;
-
-
// Open
/**
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
index 6b62288..749bb92 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
@@ -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 callback);
+ void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback callback);
+
// TabularResource
void getCurrentTRId(AsyncCallback callback);
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
index 2e8fb9d..0d10d8d 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
@@ -78,18 +78,17 @@ public class SessionUtil {
ASLSession session;
if (username == null) {
logger.warn("no user found in session, using test one");
- throw new TDGWTSessionExpiredException("Session Expired!");
+ throw new TDGWTSessionExpiredException("Session Expired!");
// 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(
httpSession.getId(), username);
@@ -206,26 +205,31 @@ public class SessionUtil {
public static void addToCurrentTabularResourcesOpen(
HttpSession httpSession, TabResource tabResource) {
- @SuppressWarnings("unchecked")
- ArrayList t = (ArrayList) httpSession
- .getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
- if (t != null) {
- for (TabResource tr : t) {
- if (tr.getTrId().getId()
- .compareTo(tabResource.getTrId().getId()) == 0) {
- t.remove(tr);
- break;
+ if (tabResource.getTrId() != null
+ && tabResource.getTrId().getId() != null
+ & !tabResource.getTrId().getId().isEmpty()) {
+
+ @SuppressWarnings("unchecked")
+ ArrayList t = (ArrayList) httpSession
+ .getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
+ if (t != null) {
+ for (TabResource tr : t) {
+ if (tr.getTrId().getId()
+ .compareTo(tabResource.getTrId().getId()) == 0) {
+ t.remove(tr);
+ break;
+ }
}
+ t.add(tabResource);
+ httpSession
+ .removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
+ } else {
+ t = new ArrayList();
+ t.add(tabResource);
}
- t.add(tabResource);
- httpSession
- .removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
- } else {
- t = new ArrayList();
- t.add(tabResource);
+ httpSession.setAttribute(
+ SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t);
}
- httpSession.setAttribute(
- SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t);
}
public static void removeFromCurrentTabularResourcesOpen(
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
index 9b9305f..a39219d 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
@@ -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");
@@ -7214,5 +7216,50 @@ 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 params = new HashMap();
+
+ 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());
+ }
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java
index 7ac854c..fa2e45f 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java
@@ -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) {
@@ -118,5 +115,8 @@ public class ResourceTDCreator {
return resourceTD;
}
+
+
+
}
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/uriresolver/UriResolverSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/uriresolver/UriResolverSession.java
new file mode 100644
index 0000000..508ba18
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/uriresolver/UriResolverSession.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}