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:
parent
51ee6591cc
commit
85667e846c
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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}
|
||||
|
@ -6131,7 +6171,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
Long.valueOf(templateApplySession.getTrId().getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
|
||||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
checkTabularResourceIsFinal(tabularResource);
|
||||
|
@ -7963,18 +8003,19 @@ 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();
|
||||
|
@ -8006,7 +8047,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
service.executeSynchMetadataOperation(invocation, tabularResourceId);
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -8553,7 +8594,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
Long.valueOf(mapCreationSession.getTrId().getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
|
||||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
|
||||
|
@ -8627,13 +8668,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("Uri Resolver params: " + params);
|
||||
link = resolver.getLink(params, true); // true, link is shorted
|
||||
// otherwise none
|
||||
break;
|
||||
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");
|
||||
|
||||
+ " No resolver enable on this application type");
|
||||
|
||||
}
|
||||
|
||||
|
@ -8678,7 +8718,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
|
||||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
|
||||
|
@ -8728,10 +8768,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSaveResourceSession(session, saveResourceSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
logger.debug("SaveResource(): "+saveResourceSession);
|
||||
|
||||
logger.debug("SaveResource(): " + saveResourceSession);
|
||||
FilesStorage storage = new FilesStorage();
|
||||
|
||||
|
||||
String mimeType;
|
||||
MimeTypeSupport mimeTypeSupport = saveResourceSession.getMime();
|
||||
if (mimeTypeSupport.compareTo(MimeTypeSupport._unknow) == 0) {
|
||||
|
@ -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;
|
||||
|
@ -8761,24 +8801,22 @@ 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}
|
||||
|
|
Loading…
Reference in New Issue