Added Save Resource On Workspace

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@101597 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-11-12 14:00:23 +00:00
parent b892edd99c
commit edece3e4d1
7 changed files with 299 additions and 67 deletions

View File

@ -58,6 +58,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.Replace
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SaveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
@ -1039,6 +1040,17 @@ public interface TDGWTService extends RemoteService {
*/
public void removeResource(RemoveResourceSession removeResourceSession)
throws TDGWTServiceException;
/**
* Save resource on Workspace
*
* @param saveResourceSession
* @throws TDGWTServiceException
*/
public void saveResource(
SaveResourceSession saveResourceSession)
throws TDGWTServiceException;
// GIS MAP
/**

View File

@ -57,6 +57,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.Replace
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SaveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
@ -376,6 +377,9 @@ public interface TDGWTServiceAsync {
void removeResource(RemoveResourceSession removeResourceSession,
AsyncCallback<Void> callback);
void saveResource(SaveResourceSession saveResourceSession,
AsyncCallback<Void> callback);
// GIS MAP
void startMapCreation(MapCreationSession mapCreationSession,

View File

@ -7,103 +7,103 @@ package org.gcube.portlets.user.td.gwtservice.server;
*
*/
public class SessionConstants {
protected static final String CURRENT_TR_ID = "CURRENT_TR_ID";
protected static final String CURRENT_TABULAR_RESOURCE = "CURRENT_TABULAR_RESOURCE";
protected static final String CURRENT_TABULAR_RESOURCES_OPEN = "CURRENT_TABULAR_RESOURCES_OPEN";
public static final String CURRENT_TR_ID = "CURRENT_TR_ID";
public static final String CURRENT_TABULAR_RESOURCE = "CURRENT_TABULAR_RESOURCE";
public static final String CURRENT_TABULAR_RESOURCES_OPEN = "CURRENT_TABULAR_RESOURCES_OPEN";
protected static final String TDOPEN_SESSION = "TDOPEN_SESSION";
protected static final String TABULAR_RESOURCE_LIST = "TABULAR_RESOURCE_LIST";
public static final String TDOPEN_SESSION = "TDOPEN_SESSION";
public static final String TABULAR_RESOURCE_LIST = "TABULAR_RESOURCE_LIST";
protected static final String OPERATIONS_TASKS_STARTED="OPERATION_TASKS_STARTED";
protected static final String OPERATIONS_TASKS_IN_BACKGROUND="OPERATION_TASKS_IN_BACKGROUND";
protected static final String OPERATIONS_TASKS_ABORTED="OPERATION_TASKS_ABORTED";
protected static final String OPERATIONS_TASKS_HIDDEN="OPERATION_TASKS_HIDDEN";
protected static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR";
public static final String OPERATIONS_TASKS_STARTED="OPERATION_TASKS_STARTED";
public static final String OPERATIONS_TASKS_IN_BACKGROUND="OPERATION_TASKS_IN_BACKGROUND";
public static final String OPERATIONS_TASKS_ABORTED="OPERATION_TASKS_ABORTED";
public static final String OPERATIONS_TASKS_HIDDEN="OPERATION_TASKS_HIDDEN";
public static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR";
protected static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";
public static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";
protected static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE";
public static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE";
protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
protected static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
protected static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
public static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
public static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
public static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
protected static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
public static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
protected static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
protected static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
protected static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE";
public static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
public static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
public static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE";
protected static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
protected static final String CSV_EXPORT_END = "CSV_EXPORT_END";
public static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
public static final String CSV_EXPORT_END = "CSV_EXPORT_END";
protected static final String JSON_EXPORT_SESSION = "JSON_EXPORT_SESSION";
protected static final String JSON_EXPORT_END = "JSON_EXPORT_END";
public static final String JSON_EXPORT_SESSION = "JSON_EXPORT_SESSION";
public static final String JSON_EXPORT_END = "JSON_EXPORT_END";
protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
public static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
protected static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
public static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
protected static final String ADD_COLUMN_SESSION = "ADD_COLUMN_SESSION";
public static final String ADD_COLUMN_SESSION = "ADD_COLUMN_SESSION";
protected static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION";
public static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION";
protected static final String FILTER_COLUMN_SESSION = "FILTER_COLUMN_SESSION";
public static final String FILTER_COLUMN_SESSION = "FILTER_COLUMN_SESSION";
protected static final String REPLACE_COLUMN_BY_EXPRESSION_SESSION = "REPLACE_COLUMN_BY_EXPRESSION_SESSION";
public static final String REPLACE_COLUMN_BY_EXPRESSION_SESSION = "REPLACE_COLUMN_BY_EXPRESSION_SESSION";
protected static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION";
public static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION";
protected static final String TASK_RESUBMIT_SESSION = "TASK_RESUBMIT_SESSION";
public static final String TASK_RESUBMIT_SESSION = "TASK_RESUBMIT_SESSION";
protected static final String TASK_RESUME_SESSION = "TASK_RESUME_SESSION";
public static final String TASK_RESUME_SESSION = "TASK_RESUME_SESSION";
protected static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION";
public static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION";
protected static final String GROUPBY_SESSION = "GROUPBY_SESSION";
public static final String GROUPBY_SESSION = "GROUPBY_SESSION";
protected static final String TIME_AGGREGATION_SESSION = "TIME_AGGREGATION_SESSION";
public static final String TIME_AGGREGATION_SESSION = "TIME_AGGREGATION_SESSION";
protected static final String UNION_SESSION = "UNION_SESSION";
public static final String UNION_SESSION = "UNION_SESSION";
protected static final String REPLACE_BY_EXTERNAL_SESSION = "REPLACE_BY_EXTERNAL_SESSION";
public static final String REPLACE_BY_EXTERNAL_SESSION = "REPLACE_BY_EXTERNAL_SESSION";
protected static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION";
public static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION";
protected static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION";
public static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION";
protected static final String DENORMALIZATION_SESSION = "DENORMALIZATION_SESSION";
public static final String DENORMALIZATION_SESSION = "DENORMALIZATION_SESSION";
protected static final String REPLACE_BATCH_COLUMN_SESSION = "REPLACE_BATCH_COLUMN_SESSION";
public static final String REPLACE_BATCH_COLUMN_SESSION = "REPLACE_BATCH_COLUMN_SESSION";
protected static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION";
public static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION";
protected static final String CHANGE_TABLE_TYPE_SESSION = "CHANGE_TABLE_TYPE_SESSION";
public static final String CHANGE_TABLE_TYPE_SESSION = "CHANGE_TABLE_TYPE_SESSION";
protected static final String DELETE_ROWS_SESSION = "DELETE_ROWS_SESSION";
public static final String DELETE_ROWS_SESSION = "DELETE_ROWS_SESSION";
protected static final String DUPLICATES_ROWS_SESSION = "DUPLICATES_ROWS_SESSION";
public static final String DUPLICATES_ROWS_SESSION = "DUPLICATES_ROWS_SESSION";
protected static final String MAP_CREATION_SESSION = "MAP_CREATION_SESSION";
public static final String MAP_CREATION_SESSION = "MAP_CREATION_SESSION";
protected static final String TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION";
public static final String TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION";
protected static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED";
protected static final String CODELISTS_PAGING_LOADED_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY";
protected static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
public static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED";
public static final String CODELISTS_PAGING_LOADED_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY";
public static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
protected static final String ROLLBACK_SESSION = "ROLLBACK_SESSION";
public static final String ROLLBACK_SESSION = "ROLLBACK_SESSION";
protected static final String EXTRACT_CODELIST_SESSION = "EXTRACT_CODELIST_SESSION";
public static final String EXTRACT_CODELIST_SESSION = "EXTRACT_CODELIST_SESSION";
protected static final String SPLIT_COLUMN_SESSION = "SPLIT_COLUMN_SESSION";
public static final String SPLIT_COLUMN_SESSION = "SPLIT_COLUMN_SESSION";
protected static final String MERGE_COLUMN_SESSION = "MERGE_COLUMN_SESSION";
public static final String MERGE_COLUMN_SESSION = "MERGE_COLUMN_SESSION";
protected static final String CODELIST_MAPPING_SESSION = "CODELIST_MAPPING_SESSION";
protected static final String CODELIST_MAPPING_FILE_UPLOAD_SESSION = "CODELIST_MAPPING_FILE_UPLOAD_SESSION";
protected static final String CHART_TOPRATING_SESSION = "CHART_TOPRATING_SESSION";
public static final String CODELIST_MAPPING_SESSION = "CODELIST_MAPPING_SESSION";
public static final String CODELIST_MAPPING_FILE_UPLOAD_SESSION = "CODELIST_MAPPING_FILE_UPLOAD_SESSION";
public static final String CHART_TOPRATING_SESSION = "CHART_TOPRATING_SESSION";
public static final String RESOURCE_SAVE_SESSION = "RESOURCE_SAVE_SESSION";
}

View File

@ -53,6 +53,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.Denormaliza
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SaveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
@ -1827,5 +1828,32 @@ public class SessionUtil {
fileUploadMonitor);
}
//
public static SaveResourceSession getSaveResourceSession(HttpSession httpSession) {
SaveResourceSession saveResourceSession = (SaveResourceSession) httpSession
.getAttribute(SessionConstants.RESOURCE_SAVE_SESSION);
if (saveResourceSession != null) {
return saveResourceSession;
} else {
saveResourceSession = new SaveResourceSession();
httpSession.setAttribute(SessionConstants.RESOURCE_SAVE_SESSION,
saveResourceSession);
return saveResourceSession;
}
}
public static void setSaveResourceSession(HttpSession httpSession,
SaveResourceSession saveResourceSession) {
SaveResourceSession srs = (SaveResourceSession) httpSession
.getAttribute(SessionConstants.RESOURCE_SAVE_SESSION);
if (srs != null) {
httpSession.removeAttribute(SessionConstants.RESOURCE_SAVE_SESSION);
}
httpSession.setAttribute(SessionConstants.RESOURCE_SAVE_SESSION,
saveResourceSession);
}
}

View File

@ -239,6 +239,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.Replace
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SaveResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
@ -7654,6 +7655,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<LicenceData> getLicences() throws TDGWTServiceException {
@ -7688,6 +7690,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
// TODO
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<OperationMonitor> getBackgroundOperationMonitor(
BackgroundOperationMonitorSession backgroundOperationMonitorSession)
@ -7746,7 +7752,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<ResourceTDDescriptor> getResourcesTD(TRId trId)
throws TDGWTServiceException {
@ -7787,7 +7797,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<ResourceTDDescriptor> getResourcesTDByType(TRId trId,
ResourceTDType resourceTDType) throws TDGWTServiceException {
@ -7836,8 +7850,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
*
* @param tabResource
* @throws TDGWTServiceException
* {@inheritDoc}
*/
@Override
public void removeResource(RemoveResourceSession removeResourceSession)
@ -7898,7 +7911,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public String startMapCreation(MapCreationSession mapCreationSession)
throws TDGWTServiceException {
@ -7956,6 +7973,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
*
* {@inheritDoc}
*/
@Override
public String getUriFromResolver(UriResolverSession uriResolverSession)
@ -8000,7 +8018,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public String startChartTopRating(
ChartTopRatingSession chartTopRatingSession)
@ -8059,5 +8081,50 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public void saveResource(
SaveResourceSession saveResourceSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil
.setSaveResourceSession(session, saveResourceSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
FilesStorage storage = new FilesStorage();
logger.debug("Create Item On Workspace: [ uri: "
+ saveResourceSession.getUri() + " ,user: " + aslSession.getUsername()
+ " ,fileName: " + saveResourceSession.getFileName()
+ " ,fileDescription: "
+ saveResourceSession.getFileDescription()
+ " ,mimetype:"+saveResourceSession.getMimeType() + " ,folder: "
+ saveResourceSession.getItemId() + "]");
storage.createItemOnWorkspace(saveResourceSession.getUri(), aslSession.getUsername(),
saveResourceSession.getFileName(),
saveResourceSession.getFileDescription(), saveResourceSession.getMimeType(),
saveResourceSession.getItemId());
return;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error saving the resource: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -78,7 +78,8 @@ public class ResourceTDCreator {
}
}
logger.debug("Resources retrieved: "+resourcesTD);
return resourcesTD;
}
@ -94,8 +95,7 @@ public class ResourceTDCreator {
Class<? extends Resource> resourceClass = resource.getResourceType();
if (resourceClass == InternalURI.class) {
InternalURI internalURI = (InternalURI) resource;
String uri=null;
String uri= internalURI.getUri().toString();
return new InternalURITD(internalURI.getFileId(),uri);
} else {
if (resourceClass == StringResource.class) {

View File

@ -0,0 +1,121 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.resources;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.destination.Destination;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SaveResourceSession implements Serializable {
private static final long serialVersionUID = 2282498402676932983L;
private String uri;
private String mimeType;
private String extension;
private Destination destination;
private String itemId;
private String fileName;
private String fileDescription;
public SaveResourceSession() {
super();
}
/**
*
* @param uri
* @param mimeType
* @param extension
* @param destination
* @param itemId
* @param fileName
* @param fileDescription
*/
public SaveResourceSession(String uri, String mimeType, String extension,
Destination destination, String itemId, String fileName,
String fileDescription) {
super();
this.uri = uri;
this.mimeType = mimeType;
this.extension = extension;
this.destination = destination;
this.itemId = itemId;
this.fileName = fileName;
this.fileDescription = fileDescription;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public Destination getDestination() {
return destination;
}
public void setDestination(Destination destination) {
this.destination = destination;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileDescription() {
return fileDescription;
}
public void setFileDescription(String fileDescription) {
this.fileDescription = fileDescription;
}
@Override
public String toString() {
return "SaveResourceSession [uri=" + uri + ", mimeType=" + mimeType
+ ", extension=" + extension + ", destination=" + destination
+ ", itemId=" + itemId + ", fileName=" + fileName
+ ", fileDescription=" + fileDescription + "]";
}
}