Added Remove Resource

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@101111 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-29 09:14:34 +00:00
parent 7888b24691
commit 9773cf6512
3 changed files with 141 additions and 12 deletions

View File

@ -53,6 +53,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.Normalizati
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
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.rows.DeleteRowsSession;
@ -455,10 +456,10 @@ public interface TDGWTService extends RemoteService {
*/
public ArrayList<ColumnData> getColumns(TRId trId)
throws TDGWTServiceException;
/**
* Retrieves the list of columns in the table provided by trId
* view columns included
* Retrieves the list of columns in the table provided by trId view columns
* included
*
* @param trId
* @return
@ -467,10 +468,9 @@ public interface TDGWTService extends RemoteService {
public ArrayList<ColumnData> getColumnWithViewColumnIncluded(TRId trId)
throws TDGWTServiceException;
/**
* Retrieves the list of columns in the table provided by trId
* for statistical
* Retrieves the list of columns in the table provided by trId for
* statistical
*
* @param trId
* @return
@ -1016,6 +1016,15 @@ public interface TDGWTService extends RemoteService {
public ArrayList<ResourceTDDescriptor> getResourcesTDByType(TRId trId,
ResourceTDType resourceTDType) throws TDGWTServiceException;
/**
* Remove resource
*
* @param removeResourceSession
* @throws TDGWTServiceException
*/
public void removeResource(RemoveResourceSession removeResourceSession)
throws TDGWTServiceException;
// GIS MAP
/**
* Start Map Creation and invokes the client library
@ -1026,8 +1035,7 @@ public interface TDGWTService extends RemoteService {
*/
public String startMapCreation(MapCreationSession mapCreationSession)
throws TDGWTServiceException;
// Statistical
/**
*
@ -1035,9 +1043,8 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public String startStatisticalOperation(StatisticalOperationSession statisticalOperationSession)
throws TDGWTServiceException;
public String startStatisticalOperation(
StatisticalOperationSession statisticalOperationSession)
throws TDGWTServiceException;
}

View File

@ -232,6 +232,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoad
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.OrderInfo;
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.rows.DeleteRowsSession;
@ -2793,6 +2794,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* @param tabResource
* @throws TDGWTServiceException
*/
@Override
public void removeTabularResource(TRId trId) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
@ -7801,6 +7803,72 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* @param tabResource
* @throws TDGWTServiceException
*/
@Override
public void removeResource(RemoveResourceSession removeResourceSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("Remove Resource: " + removeResourceSession);
if (removeResourceSession == null) {
logger.error("Error removing Resource: removeResourceSession null");
throw new TDGWTServiceException(
"Error removing Resource no parameters set");
}
TRId trId = removeResourceSession.getTrId();
if (trId == null) {
logger.error("Error removing Resource: trId is null");
throw new TDGWTServiceException(
"Error removing Resource no tabular resource set");
}
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTRId(trId);
TabularResourceId tabResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabResourceId);
checkTabularResourceLocked(tabularResource);
String owner = tabularResource.getOwner();
if (owner != null && owner.compareTo(aslSession.getUsername()) == 0) {
if (removeResourceSession.getResourceTDDescriptor() == null) {
logger.error("Error removing Resource: descriptor null");
throw new TDGWTServiceException(
"Error removing Resource no descriptor set");
}
service.removeResurce(removeResourceSession
.getResourceTDDescriptor().getId());
} else {
throw new TDGWTServiceException(
"You are not the owner of this tabular resource (owner: "
+ owner + ")");
}
return;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Security exception, you haven't rights!");
} catch (Throwable e) {
logger.error(
"Error deleting the resource: " + e.getLocalizedMessage(),
e);
throw new TDGWTServiceException("Error deleting the resource: "
+ e.getLocalizedMessage());
}
}
@Override
public String startMapCreation(MapCreationSession mapCreationSession)
throws TDGWTServiceException {

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.resources;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RemoveResourceSession implements Serializable {
private static final long serialVersionUID = -48669918467995522L;
protected TRId trId;
protected ResourceTDDescriptor resourceTDDescriptor;
public RemoveResourceSession(){
}
public RemoveResourceSession(TRId trId,
ResourceTDDescriptor resourceTDDescriptor) {
super();
this.trId = trId;
this.resourceTDDescriptor = resourceTDDescriptor;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ResourceTDDescriptor getResourceTDDescriptor() {
return resourceTDDescriptor;
}
public void setResourceTDDescriptor(ResourceTDDescriptor resourceTDDescriptor) {
this.resourceTDDescriptor = resourceTDDescriptor;
}
@Override
public String toString() {
return "RemoveResourceSession [trId=" + trId
+ ", resourceTDDescriptor=" + resourceTDDescriptor + "]";
}
}