Added Open TR with parameter on url

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@113568 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-03-11 15:07:47 +00:00
parent 51ee6591cc
commit 85667e846c
3 changed files with 97 additions and 63 deletions

View File

@ -126,7 +126,7 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public TRId restoreUISession() throws TDGWTServiceException;
public TRId restoreUISession(TRId startTRId) throws TDGWTServiceException;
/**
* Resolve Uri

View File

@ -100,7 +100,7 @@ public interface TDGWTServiceAsync {
void pendingTasksRetrieve(AsyncCallback<Integer> callback);
void restoreUISession(AsyncCallback<TRId> callback);
void restoreUISession(TRId startTRId, AsyncCallback<TRId> callback);
void getUriFromResolver(UriResolverSession uriResolverSession,
AsyncCallback<String> callback);

View File

@ -171,6 +171,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalExcept
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFlowException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState;
@ -594,24 +595,56 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* {@inheritDoc}
*/
@Override
public TRId restoreUISession() throws TDGWTServiceException {
public TRId restoreUISession(TRId startTRId) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
// SessionUtil.getAslSession(session);
ASLSession aslSession=SessionUtil.getAslSession(session);
if (startTRId == null || startTRId.getId() == null
|| startTRId.getId().isEmpty()) {
TRId trId = SessionUtil.getTRId(session);
logger.debug("restoreUISession()");
if (trId == null) {
logger.error("No UI Session");
throw new TDGWTServiceException("UI session is null");
TRId trId = SessionUtil.getTRId(session);
logger.debug("restoreUISession()");
if (trId == null) {
logger.error("No UI Session");
return null;
} else {
logger.debug("Restore UI Session():" + trId);
SessionUtil
.removeAllFromCurrentTabularResourcesOpen(session);
TabResource tabResource = SessionUtil
.getTabResource(session);
SessionUtil.addToCurrentTabularResourcesOpen(session,
tabResource);
}
return trId;
} else {
logger.debug("Restore UI Session():" + trId);
SessionUtil.removeAllFromCurrentTabularResourcesOpen(session);
TabResource tabResource = SessionUtil.getTabResource(session);
SessionUtil.addToCurrentTabularResourcesOpen(session,
tabResource);
logger.debug("Restore UI Session() request TabularResource:" + startTRId);
SessionUtil
.removeAllFromCurrentTabularResourcesOpen(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(startTRId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceLocked(tabularResource);
TabResource tabResource=retrieveTRMetadataFromServiceAndLastTable(service, tabularResource, 1);
if(tabResource.getTrId()==null|| tabResource.getTrId().getId()==null||
tabResource.getTrId().getId().isEmpty()){
return null;
} else {
setCurrentTabResource(tabResource, session);
}
return tabResource.getTrId();
}
return trId;
} catch (TDGWTServiceException e) {
throw e;
@ -637,15 +670,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
if (tabResource == null) {
logger.error("Error setting TabResource: null");
throw new TDGWTServiceException(
"Error setting TabResource: null");
}
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, tabResource.getTrId());
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
setCurrentTabResource(tabResource, session);
return;
} catch (TDGWTServiceException e) {
@ -661,6 +686,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
private void setCurrentTabResource(TabResource tabResource,
HttpSession session) throws TDGWTServiceException,
TDGWTSessionExpiredException {
if (tabResource == null) {
logger.error("Error setting TabResource: null");
throw new TDGWTServiceException(
"Error setting TabResource: null");
}
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, tabResource.getTrId());
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
return;
}
/**
*
* {@inheritDoc}
@ -7964,17 +8004,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
public void startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession)
public void startChangeColumnsPosition(
ChangeColumnsPositionSession changeColumnsPositionSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setChangeColumnsPositionSession(session, changeColumnsPositionSession);
SessionUtil.setChangeColumnsPositionSession(session,
changeColumnsPositionSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
@ -7992,8 +8033,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
OpExecution4ChangeColumnsPosition opEx = new OpExecution4ChangeColumnsPosition(service,
changeColumnsPositionSession);
OpExecution4ChangeColumnsPosition opEx = new OpExecution4ChangeColumnsPosition(
service, changeColumnsPositionSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -8632,8 +8673,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("No resolver enable on this application type");
throw new TDGWTServiceException(
"Error retrieving uri from resolver:"
+ " No resolver enable on this application type");
+ " No resolver enable on this application type");
}
@ -8729,7 +8769,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setSaveResourceSession(session, saveResourceSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("SaveResource(): "+saveResourceSession);
logger.debug("SaveResource(): " + saveResourceSession);
FilesStorage storage = new FilesStorage();
String mimeType;
@ -8742,10 +8782,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ResourceTD resource = saveResourceSession.getResourceTDDescriptor()
.getResourceTD();
String uri=null;
String uri = null;
if (resource instanceof StringResourceTD) {
StringResourceTD stringResourceTD=(StringResourceTD)resource;
uri=stringResourceTD.getStringValue();
StringResourceTD stringResourceTD = (StringResourceTD) resource;
uri = stringResourceTD.getStringValue();
} else {
if (resource instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resource;
@ -8762,23 +8802,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
if (uri == null || uri.isEmpty()) {
throw new TDGWTServiceException(
"This resource does not have valid uri: "+uri);
"This resource does not have valid uri: " + uri);
}
logger.debug("Create Item On Workspace: [uri="
+ uri
+ " ,user: " + aslSession.getUsername() + " ,fileName: "
logger.debug("Create Item On Workspace: [uri=" + uri + " ,user: "
+ aslSession.getUsername() + " ,fileName: "
+ saveResourceSession.getFileName() + " ,fileDescription: "
+ saveResourceSession.getFileDescription() + " ,mimetype:"
+ mimeType + " ,folder: "
+ saveResourceSession.getItemId() + "]");
+ mimeType + " ,folder: " + saveResourceSession.getItemId()
+ "]");
storage.createItemOnWorkspace(uri, aslSession.getUsername(),
saveResourceSession.getFileName(), saveResourceSession.getFileDescription(),
mimeType, saveResourceSession.getItemId());
saveResourceSession.getFileName(),
saveResourceSession.getFileDescription(), mimeType,
saveResourceSession.getItemId());
return;
@ -8869,7 +8907,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
@ -8907,8 +8944,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
OpExecution4GeospatialDownscaleCSquare opEx = new OpExecution4GeospatialDownscaleCSquare (
service, geospatialDownscaleCSquareSession);
OpExecution4GeospatialDownscaleCSquare opEx = new OpExecution4GeospatialDownscaleCSquare(
service, geospatialDownscaleCSquareSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -8937,15 +8974,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in downscale C-Square: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException("Error in downscale C-Square: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}