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:
Giancarlo Panichi 2014-10-17 16:39:53 +00:00
parent 78182ecb33
commit ee8ba0adb2
7 changed files with 175 additions and 49 deletions

View File

@ -177,6 +177,13 @@
<artifactId>storage-manager-wrapper</artifactId> <artifactId>storage-manager-wrapper</artifactId>
</dependency> </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 --> <!-- tabular-data-widget-common-event -->
<dependency> <dependency>
@ -186,6 +193,8 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- LOGGING --> <!-- LOGGING -->
<dependency> <dependency>
<groupId>com.allen-sauer.gwt.log</groupId> <groupId>com.allen-sauer.gwt.log</groupId>

View File

@ -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.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; 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.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.gwtservice.shared.user.UserInfo;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -106,6 +107,16 @@ public interface TDGWTService extends RemoteService {
*/ */
public TRId restoreUISession() throws TDGWTServiceException; public TRId restoreUISession() throws TDGWTServiceException;
/**
* Resolve Uri
*
* @param uriResolverSession
* @return
* @throws TDGWTServiceException
*/
public String getUriFromResolver(UriResolverSession uriResolverSession)
throws TDGWTServiceException;
// TabularResource // TabularResource
/** /**
* Get current TRId * Get current TRId
@ -121,8 +132,8 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public TabResource getInSessionTabResourceInfo() throws TDGWTServiceException; public TabResource getInSessionTabResourceInfo()
throws TDGWTServiceException;
/** /**
* Get informations on the current tabular resource call service * Get informations on the current tabular resource call service
@ -245,8 +256,8 @@ public interface TDGWTService extends RemoteService {
public void closeAllTabularResources() throws TDGWTServiceException; public void closeAllTabularResources() throws TDGWTServiceException;
/** /**
* Close Tabular Resource with TRId equals to closeTRId * Close Tabular Resource with TRId equals to closeTRId and open if not null
* and open if not null that with TRId equals to openTRId * that with TRId equals to openTRId
* *
* @param openTRId * @param openTRId
* @throws TDGWTServiceException * @throws TDGWTServiceException
@ -354,7 +365,8 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void setShare(ShareTabResource shareInfo) throws TDGWTServiceException; public void setShare(ShareTabResource shareInfo)
throws TDGWTServiceException;
/** /**
* Share template * Share template
@ -363,9 +375,8 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void setShareTemplate(ShareTemplate shareTemplate) throws TDGWTServiceException; public void setShareTemplate(ShareTemplate shareTemplate)
throws TDGWTServiceException;
// Open // Open

View File

@ -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.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; 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.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.gwtservice.shared.user.UserInfo;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -85,6 +86,8 @@ public interface TDGWTServiceAsync {
void restoreUISession(AsyncCallback<TRId> callback); void restoreUISession(AsyncCallback<TRId> callback);
void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback<String> callback);
// TabularResource // TabularResource
void getCurrentTRId(AsyncCallback<TRId> callback); void getCurrentTRId(AsyncCallback<TRId> callback);

View File

@ -82,13 +82,12 @@ public class SessionUtil {
// Remove comment for Test // Remove comment for Test
/* /*
username = Constants.DEFAULT_USER; * username = Constants.DEFAULT_USER; String scope =
String scope = Constants.DEFAULT_SCOPE; * Constants.DEFAULT_SCOPE;
*
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username); * httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
session = SessionManager.getInstance().getASLSession( * username); session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); * httpSession.getId(), username); session.setScope(scope);
session.setScope(scope);
*/ */
} else { } else {
session = SessionManager.getInstance().getASLSession( session = SessionManager.getInstance().getASLSession(
@ -206,6 +205,10 @@ public class SessionUtil {
public static void addToCurrentTabularResourcesOpen( public static void addToCurrentTabularResourcesOpen(
HttpSession httpSession, TabResource tabResource) { HttpSession httpSession, TabResource tabResource) {
if (tabResource.getTrId() != null
&& tabResource.getTrId().getId() != null
& !tabResource.getTrId().getId().isEmpty()) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<TabResource> t = (ArrayList<TabResource>) httpSession ArrayList<TabResource> t = (ArrayList<TabResource>) httpSession
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN); .getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
@ -227,6 +230,7 @@ public class SessionUtil {
httpSession.setAttribute( httpSession.setAttribute(
SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t); SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t);
} }
}
public static void removeFromCurrentTabularResourcesOpen( public static void removeFromCurrentTabularResourcesOpen(
HttpSession httpSession, TRId trId) { HttpSession httpSession, TRId trId) {

View File

@ -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.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; 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.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.gwtservice.shared.user.UserInfo;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; 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.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.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -1777,8 +1779,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Date dateU = sdfDate.parse(tabResource.getValidUntilTo()); Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC = new GregorianCalendar(); GregorianCalendar validUntilToC = new GregorianCalendar();
validUntilToC.setTime(dateU); validUntilToC.setTime(dateU);
ValidUntilMetadata validUntil = new ValidUntilMetadata(); ValidUntilMetadata validUntil = new ValidUntilMetadata(
validUntil.setValue(validUntilToC); validUntilToC);
tr.setMetadata(validUntil); tr.setMetadata(validUntil);
} catch (ParseException e) { } catch (ParseException e) {
logger.info("ValidUntilMetadata is not set, no valid calendar present"); 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()); Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC = new GregorianCalendar(); GregorianCalendar validUntilToC = new GregorianCalendar();
validUntilToC.setTime(dateU); validUntilToC.setTime(dateU);
ValidUntilMetadata validUntil = new ValidUntilMetadata(); ValidUntilMetadata validUntil = new ValidUntilMetadata(
validUntil.setValue(validUntilToC); validUntilToC);
tr.setMetadata(validUntil); tr.setMetadata(validUntil);
} catch (ParseException e) { } catch (ParseException e) {
logger.info("ValidUntilMetadata is not set, no valid calendar present"); 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());
}
}
} }

View File

@ -88,17 +88,14 @@ public class ResourceTDCreator {
* @param resource * @param resource
* @return * @return
*/ */
public ResourceTD createResourceTD(Resource resource) { protected ResourceTD createResourceTD(Resource resource) {
ResourceTD resourceTD = null; ResourceTD resourceTD = null;
Class<? extends Resource> resourceClass = resource.getResourceType(); Class<? extends Resource> resourceClass = resource.getResourceType();
if (resourceClass == InternalURI.class) { if (resourceClass == InternalURI.class) {
InternalURI internalURI = (InternalURI) resource; InternalURI internalURI = (InternalURI) resource;
String uri=null; String uri=null;
if(internalURI.getUri()!=null){
uri=internalURI
.getUri().toString();
}
return new InternalURITD(internalURI.getFileId(),uri); return new InternalURITD(internalURI.getFileId(),uri);
} else { } else {
if (resourceClass == StringResource.class) { if (resourceClass == StringResource.class) {
@ -119,4 +116,7 @@ public class ResourceTDCreator {
} }
} }

View File

@ -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 + "]";
}
}