Added Delete Rule

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114199 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-16 16:37:25 +00:00
parent b2ed6e163a
commit 023c72d122
3 changed files with 60 additions and 2 deletions

View File

@ -58,4 +58,6 @@ public interface ExpressionService extends RemoteService {
public String saveColumnRule(RuleDescriptionData ruleDescriptionData)
throws TDGWTServiceException;
public void removeRuleById(String ruleId) throws TDGWTServiceException;
}

View File

@ -43,5 +43,6 @@ public interface ExpressionServiceAsync {
void saveColumnRule(RuleDescriptionData ruleDescriptionData,
AsyncCallback<String> callback);
void removeRuleById(String ruleId, AsyncCallback<Void> callback);
}

View File

@ -353,7 +353,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
String ruleIdent=null;
if(ruleId!=null){
ruleIdent=String.valueOf(ruleId.getId());
ruleIdent=String.valueOf(ruleId.getValue());
}
return ruleIdent;
@ -373,6 +373,61 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public void removeRuleById(
String ruleId)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("RemoveRuleById() :" + ruleId);
if(ruleId==null|| ruleId.isEmpty()){
throw new TDGWTServiceException("Error removing the rule, ruleId="+ruleId);
}
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
long rId=0;
try{
rId=Long.parseLong(ruleId);
} catch(NumberFormatException e){
throw new TDGWTServiceException("Error removing the rule, ruleId="+ruleId);
}
RuleId id=new RuleId(rId);
service.removeRuleById(id);
return;
} catch (TDGWTServiceException e) {
logger.error(e.getLocalizedMessage());
throw e;
} catch (SecurityException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw e;
} catch (Throwable e) {
logger.error("Error in getRule(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error removing the rules: "
+ e.getLocalizedMessage());
}
}
/**
* Retrieve and set Tabular Resource Type