Added Locked

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99564 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-05 14:39:34 +00:00
parent 53ea631110
commit 59808d9050
5 changed files with 263 additions and 133 deletions

View File

@ -13,11 +13,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -26,7 +26,6 @@ import java.util.Set;
import javax.servlet.http.HttpSession;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.Home;
import org.gcube.common.homelibrary.home.HomeLibrary;
@ -46,6 +45,7 @@ import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDesc
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.tasks.ValidationDescriptor;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
@ -381,6 +381,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
currentTR.setValid(tr.isValid());
currentTR.setFinalized(tr.isFinalized());
currentTR.setLocked(tr.isLocked());
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
SessionUtil.setTabResource(session, currentTR);
@ -441,6 +442,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
currentTR.setValid(tr.isValid());
currentTR.setFinalized(tr.isFinalized());
currentTR.setLocked(tr.isLocked());
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
logger.debug("GetTabResourceInformation() updated information:"
@ -1490,6 +1492,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
// TODO
/**
*
*
@ -1497,7 +1500,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* @param tabResource
*/
protected void syncTRMetaData(TabularResource tr, TabResource tabResource) {
logger.debug("TRservice [id:" + tr.getId() + " ,creationDate:"
+ tr.getCreationDate() + "]");
logger.debug("TabResource [name:" + tabResource.getName()
@ -1506,6 +1509,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ tabResource.getRight() + "]");
tabResource.setDate(sdf.format(tr.getCreationDate().getTime()));
tabResource.setValid(tr.isValid());
tabResource.setFinalized(tr.isFinalized());
tabResource.setLocked(tr.isLocked());
tr.setMetadata(new NameMetadata(tabResource.getName()));
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
// tr.setMetadata(new CreationDateMetadata(date));
@ -1514,47 +1519,49 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
tr.setMetadata(new AgencyMetadata(tabResource.getAgency()));
}
tr.setMetadata(new RightsMetadata(tabResource.getRight()));
if(tabResource.getValidFrom()!=null&& !tabResource.getValidFrom().isEmpty()){
try{
Date dateF=sdfDate.parse(tabResource.getValidFrom());
GregorianCalendar validFromC= new GregorianCalendar();
if (tabResource.getValidFrom() != null
&& !tabResource.getValidFrom().isEmpty()) {
try {
Date dateF = sdfDate.parse(tabResource.getValidFrom());
GregorianCalendar validFromC = new GregorianCalendar();
validFromC.setTime(dateF);
ValidSinceMetadata validSince=new ValidSinceMetadata();
ValidSinceMetadata validSince = new ValidSinceMetadata();
validSince.setValue(validFromC);
tr.setMetadata(validSince);
} catch(ParseException e){
} catch (ParseException e) {
logger.info("ValidFromMetadata is not set, no valid calendar present");
}
}
if(tabResource.getValidUntilTo()!=null&& !tabResource.getValidUntilTo().isEmpty()){
try{
Date dateU=sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC= new GregorianCalendar();
if (tabResource.getValidUntilTo() != null
&& !tabResource.getValidUntilTo().isEmpty()) {
try {
Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC = new GregorianCalendar();
validUntilToC.setTime(dateU);
ValidUntilMetadata validUntil=new ValidUntilMetadata();
ValidUntilMetadata validUntil = new ValidUntilMetadata();
validUntil.setValue(validUntilToC);
tr.setMetadata(validUntil);
} catch(ParseException e){
} catch (ParseException e) {
logger.info("ValidUntilMetadata is not set, no valid calendar present");
}
}
if(tabResource.getLicence()!=null && !tabResource.getLicence().isEmpty()){
LicenceMetadata licenceMetadata=new LicenceMetadata();
Licence licence=LicenceMap.map(tabResource.getLicence());
if(licence!=null){
if (tabResource.getLicence() != null
&& !tabResource.getLicence().isEmpty()) {
LicenceMetadata licenceMetadata = new LicenceMetadata();
Licence licence = LicenceMap.map(tabResource.getLicence());
if (licence != null) {
licenceMetadata.setValue(licence);
tr.setMetadata(licenceMetadata);
} else {
logger.error("Licence type not found: "+tabResource.getLicence());
logger.error("Licence type not found: "
+ tabResource.getLicence());
}
}
}
/**
@ -1589,6 +1596,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
t.setTrId(trId);
t.setValid(tr.isValid());
t.setFinalized(tr.isFinalized());
t.setLocked(tr.isLocked());
Contacts owner = new Contacts("", tr.getOwner(), false);
t.setOwner(owner);
@ -1614,46 +1622,45 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
t.setAgency("");
}
t.setDate(sdf.format(tr.getCreationDate().getTime()));
if (tr.contains(ValidSinceMetadata.class)) {
ValidSinceMetadata validSinceMeta = tr
.getMetadata(ValidSinceMetadata.class);
if (validSinceMeta != null && validSinceMeta.getValue() != null) {
Calendar validSinceC=validSinceMeta.getValue();
Calendar validSinceC = validSinceMeta.getValue();
t.setValidFrom(sdfDate.format(validSinceC.getTime()));
} else {
}
} else {
}
if (tr.contains(ValidUntilMetadata.class)) {
ValidUntilMetadata validUntilMeta = tr
.getMetadata(ValidUntilMetadata.class);
if (validUntilMeta != null && validUntilMeta.getValue() != null) {
Calendar validUntilC=validUntilMeta.getValue();
Calendar validUntilC = validUntilMeta.getValue();
t.setValidUntilTo(sdfDate.format(validUntilC.getTime()));
} else {
}
} else {
}
if (tr.contains(LicenceMetadata.class)) {
LicenceMetadata licenceMeta = tr
.getMetadata(LicenceMetadata.class);
if (licenceMeta != null && licenceMeta.getValue() != null) {
t.setLicence(licenceMeta.getValue().toString());
} else {
}
} else {
}
// logger.debug("TabResource: "+t);
return t;
@ -2255,6 +2262,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResourceId id = new TabularResourceId(Long.valueOf(trId
.getId()));
TabularResource tr = service.getTabularResource(id);
if (tr.isLocked()) {
throw new TDGWTServiceException("Tabular Resource Is Locked");
}
String owner = tr.getOwner();
if (owner != null && owner.compareTo(aslSession.getUsername()) == 0) {
service.removeTabularResource(id);
@ -2309,8 +2320,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
serviceTR.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
tabResource.setTrId(trId);
tabResource.setValid(serviceTR.isValid());
tabResource.setFinalized(serviceTR.isFinalized());
return tabResource;
} catch (TDGWTSessionExpiredException e) {
@ -3061,6 +3071,45 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
* Check locked status of a tabular resource
*
* @param trId
* @return
* @throws TDGWTServiceException
*/
public Boolean isTabularResourceLocked(TRId trId)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("IsTabularResourceLocked: " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResource tr = service
.getTabularResource(new TabularResourceId(Long.valueOf(trId
.getId())));
logger.debug("IsTabularResourceLocked: " + tr.isLocked());
return tr.isLocked();
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Security exception, you haven't rights!");
} catch (Throwable e) {
logger.error("Error checking if it is a locked tabular resource: "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error checking if it is a locked tabular resource: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -3118,24 +3167,26 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
if (trMetadata instanceof ValidSinceMetadata) {
TRValidSinceMetadata validSinceMetadata = new TRValidSinceMetadata();
Calendar cal= ((ValidSinceMetadata) trMetadata)
.getValue();
validSinceMetadata
.setValue(sdfDate.format(cal.getTime()));
Calendar cal = ((ValidSinceMetadata) trMetadata)
.getValue();
validSinceMetadata.setValue(sdfDate
.format(cal.getTime()));
listTRMetadata.add(validSinceMetadata);
} else {
if (trMetadata instanceof ValidUntilMetadata) {
TRValidUntilMetadata validUntilMetadata = new TRValidUntilMetadata();
Calendar cal= ((ValidUntilMetadata) trMetadata)
.getValue();
validUntilMetadata
.setValue(sdfDate.format(cal.getTime()));
Calendar cal = ((ValidUntilMetadata) trMetadata)
.getValue();
validUntilMetadata.setValue(sdfDate
.format(cal.getTime()));
listTRMetadata.add(validUntilMetadata);
} else {
if (trMetadata instanceof LicenceMetadata) {
TRLicenceMetadata licenceMetadata = new TRLicenceMetadata();
licenceMetadata
.setValue(((LicenceMetadata) trMetadata).getValue().toString());
.setValue(((LicenceMetadata) trMetadata)
.getValue()
.toString());
listTRMetadata.add(licenceMetadata);
} else {
@ -3431,6 +3482,46 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return parameterInstances;
}
/**
*
* @param service
* @param trId
* @throws TDGWTServiceException
*/
protected void checkTabularResourceLocked(TabularDataService service,
TRId trId) throws TDGWTServiceException {
try {
if (trId == null) {
logger.error("TRId is null");
new TDGWTServiceException(
"No valid tabular resource id present");
}
if (trId.getId() == null || trId.getId().isEmpty()) {
logger.error("TRId not valid: " + trId);
new TDGWTServiceException(
"No valid tabular resource id present");
}
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
if (tabularResource.isLocked()) {
throw new TDGWTServiceException("Tabular Resource Is Locked");
}
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param exportSession
@ -3473,6 +3564,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, trId);
// Export SDMX Codelist
OperationDefinition exportSDMXOperation = OperationDefinitionMap
.map(OperationsId.SDMXCodelistExport.toString(), service);
@ -3546,6 +3639,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, trId);
// Export CSV file
OperationDefinition exportCSVFileOperation = OperationDefinitionMap
@ -3598,6 +3692,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, changeColumnTypeSession
.getColumnData().getTrId());
OpExecution4ChangeColumnType opEx = new OpExecution4ChangeColumnType(
service, changeColumnTypeSession);
@ -3652,6 +3748,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, addColumnSession.getTrId());
OpExecution4AddColumn opEx = new OpExecution4AddColumn(service,
addColumnSession);
@ -3705,6 +3802,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, deleteColumnSession.getTrId());
OpExecution4DeleteColumn opEx = new OpExecution4DeleteColumn(
service, deleteColumnSession);
@ -3772,9 +3870,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, filterColumnSession.getColumn()
.getTrId());
OpExecution4FilterColumn opEx = new OpExecution4FilterColumn(service,
filterColumnSession, expression);
OpExecution4FilterColumn opEx = new OpExecution4FilterColumn(
service, filterColumnSession, expression);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -3785,8 +3885,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error in invocation: Operation not supported");
}
Long id = Long.valueOf(
filterColumnSession.getColumn().getTrId().getId());
Long id = Long.valueOf(filterColumnSession.getColumn().getTrId()
.getId());
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocations.toString());
@ -3795,7 +3895,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.FilterColumn, filterColumnSession
.getColumn().getTrId());
.getColumn().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
return trTask.getId().getValue();
@ -3813,8 +3913,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
@ -3830,6 +3928,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, labelColumnSession.getTrId());
OpExecution4LabelColumn opEx = new OpExecution4LabelColumn(service,
labelColumnSession);
@ -3843,14 +3942,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Operation not supported");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(labelColumnSession.getTrId()
.getId()));
Long.valueOf(labelColumnSession.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocations);
Task trTask = service.executeBatch(invocations, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeColumnLabel, labelColumnSession
.getTrId());
UIOperationsId.ChangeColumnLabel,
labelColumnSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
return trTask.getId().getValue();
@ -3885,6 +3983,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service,
changeTableTypeSession.getTrId());
OpExecution4ChangeTableType opEx = new OpExecution4ChangeTableType(
service, changeTableTypeSession);
@ -4056,6 +4156,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, deleteRowsSession.getTrId());
OpExecution4DeleteRows opEx = new OpExecution4DeleteRows(service,
deleteRowsSession);
@ -4098,6 +4199,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
*
* {@inheritDoc}
*/
@Override
public String startCloneTabularResource(
CloneTabularResourceSession cloneTabularResourceSession)
@ -4113,6 +4215,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ cloneTabularResourceSession);
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service,
cloneTabularResourceSession.getTrId());
OpExecution4Clone opEx = new OpExecution4Clone(service,
cloneTabularResourceSession);
@ -4193,6 +4297,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, duplicatesSession.getTrId());
OpExecution4Duplicates opEx = new OpExecution4Duplicates(service,
duplicatesSession);
@ -4299,8 +4404,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, shareInfo.getTabResource()
.getTrId());
TabularResourceId serviceTR = new TabularResourceId(
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(shareInfo.getTabResource().getTrId().getId()));
List<AuthorizationToken> users = new ArrayList<AuthorizationToken>();
@ -4317,7 +4424,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.toArray(new AuthorizationToken[0]);
logger.debug("Share with Users: " + users);
service.share(serviceTR, usersArray);
service.share(tabularResourceId, usersArray);
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -4378,6 +4485,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, tabResource.getTrId());
TabularResourceId tabularResourceId = new TabularResourceId(
new Long(tabResource.getTrId().getId()));
@ -4407,49 +4515,57 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
tabResource.getRight());
tr.setMetadata(rights);
}
if(tabResource.getValidFrom()!=null&& !tabResource.getValidFrom().isEmpty()){
try{
Date dateF=sdfDate.parse(tabResource.getValidFrom());
GregorianCalendar validFromC= new GregorianCalendar();
if (tabResource.getValidFrom() != null
&& !tabResource.getValidFrom().isEmpty()) {
try {
Date dateF = sdfDate.parse(tabResource.getValidFrom());
GregorianCalendar validFromC = new GregorianCalendar();
validFromC.setTime(dateF);
ValidSinceMetadata validSince=new ValidSinceMetadata();
ValidSinceMetadata validSince = new ValidSinceMetadata();
validSince.setValue(validFromC);
tr.setMetadata(validSince);
} catch(ParseException e){
} catch (ParseException e) {
logger.info("ValidFromMetadata is not set, no valid calendar present");
}
}
if(tabResource.getValidUntilTo()!=null&& !tabResource.getValidUntilTo().isEmpty()){
try{
Date dateU=sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC= new GregorianCalendar();
if (tabResource.getValidUntilTo() != null
&& !tabResource.getValidUntilTo().isEmpty()) {
try {
Date dateU = sdfDate.parse(tabResource.getValidUntilTo());
GregorianCalendar validUntilToC = new GregorianCalendar();
validUntilToC.setTime(dateU);
ValidUntilMetadata validUntil=new ValidUntilMetadata();
ValidUntilMetadata validUntil = new ValidUntilMetadata();
validUntil.setValue(validUntilToC);
tr.setMetadata(validUntil);
} catch(ParseException e){
} catch (ParseException e) {
logger.info("ValidUntilMetadata is not set, no valid calendar present");
}
}
if(tabResource.getLicence()!=null && !tabResource.getLicence().isEmpty()){
LicenceMetadata licenceMetadata=new LicenceMetadata();
Licence licence=LicenceMap.map(tabResource.getLicence());
if(licence!=null){
if (tabResource.getLicence() != null
&& !tabResource.getLicence().isEmpty()) {
LicenceMetadata licenceMetadata = new LicenceMetadata();
Licence licence = LicenceMap.map(tabResource.getLicence());
if (licence != null) {
licenceMetadata.setValue(licence);
tr.setMetadata(licenceMetadata);
} else {
logger.error("Licence type not found: "+tabResource.getLicence());
logger.error("Licence type not found: "
+ tabResource.getLicence());
}
}
if (tabResource.isFinalized()) {
if (!tr.isFinalized()) {
tr.finalize();
if (tr.isValid()) {
if (!tr.isFinalized()) {
tr.finalize();
}
} else {
throw new TDGWTServiceException(
"Only valid tabular resource can be finalized!");
}
}
logger.debug("setTabResourceInformation - new information:" + tr);
@ -4590,6 +4706,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, templateApplySession.getTrId());
TemplateId templateId = new TemplateId(templateApplySession
.getTemplateData().getId());
@ -4678,6 +4795,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, replaceColumnSession.getTrId());
OpExecution4ReplaceColumn opEx = new OpExecution4ReplaceColumn(
service, replaceColumnSession);
@ -4736,6 +4854,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service,
replaceBatchColumnSession.getTrId());
OpExecution4ReplaceBatch opEx = new OpExecution4ReplaceBatch(
service, replaceBatchColumnSession);
@ -5068,6 +5188,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, trId);
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
@ -5137,6 +5258,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, rollBackSession.getTrId());
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(rollBackSession.getTrId().getId()));
@ -5186,7 +5308,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ArrayList<TaskS> taskSList = new ArrayList<TaskS>();
List<Task> tasks = service.getTasks(tabularResourceId);
for (Task task : tasks) {
if(tasks.size()>0) {
Task task=tasks.get(0);
ArrayList<JobS> jobSList = new ArrayList<JobS>();
int j = 1;
for (Job job : task.getTaskJobs()) {
@ -5275,6 +5398,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, editRowSession.getTrId());
OpExecution4EditRow opEx = new OpExecution4EditRow(service,
editRowSession);
@ -5372,15 +5496,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setTaskResubmitSession(session, taskResubmitSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("StartTaskResubmit: " + taskResubmitSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
if (taskResubmitSession == null) {
logger.error("TaskResubmitSession is null");
throw new TDGWTServiceException(
"Error in resubmit task: TaskResubmitSession is null");
}
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, taskResubmitSession.getTrId());
if (taskResubmitSession.getTaskId() == null
|| taskResubmitSession.getTaskId().isEmpty()) {
logger.error("Task Id is: " + taskResubmitSession.getTaskId());
@ -5421,15 +5546,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setTaskResumeSession(session, taskResumeSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("StartTaskResume: " + taskResumeSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
if (taskResumeSession == null) {
logger.error("TaskResumeSession is null");
throw new TDGWTServiceException(
"Error in resume: TaskResumeSession is null");
}
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, taskResumeSession.getTrId());
if (taskResumeSession.getTaskId() == null
|| taskResumeSession.getTaskId().isEmpty()) {
logger.error("Task Id is: " + taskResumeSession.getTaskId());
@ -5560,16 +5686,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setExtractCodelistSession(session,
extractCodelistSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("StartExtractCodelist: " + extractCodelistSession);
if (extractCodelistSession == null) {
logger.error("ExtractCodelistSession is null");
throw new TDGWTServiceException(
"Error in extract codelist: ExtractCodelistSession is null");
}
logger.debug("StartExtractCodelist: " + extractCodelistSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service,
extractCodelistSession.getTrId());
OpExecution4ExtractCodelist opEx = new OpExecution4ExtractCodelist(
service, extractCodelistSession);
@ -5610,7 +5737,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
// TODO
public String startSplitColumn(SplitColumnSession splitColumnSession,
HttpSession session) throws TDGWTServiceException {
try {
@ -5627,6 +5753,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, splitColumnSession
.getColumnData().getTrId());
OpExecution4SplitColumn opEx = new OpExecution4SplitColumn(service,
splitColumnSession);
@ -5685,6 +5813,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, mergeColumnSession
.getColumnDataSource1().getTrId());
OpExecution4MergeColumn opEx = new OpExecution4MergeColumn(service,
mergeColumnSession);
@ -5859,7 +5989,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
logger.debug("StartCodelistMappingImport: "
+ codelistMappingSession.toString());
+ codelistMappingSession);
SessionUtil.setCodelistMappingSession(session,
codelistMappingSession);
@ -5925,6 +6055,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(aslSession
.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, codelistMappingSession.getTrId());
OpExecution4CodelistMapping opEx = new OpExecution4CodelistMapping(
service, codelistMappingSession, importUrl);
@ -5964,7 +6095,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, groupBySession.getTrId());
OpExecution4GroupBy opEx = new OpExecution4GroupBy(service,
groupBySession);
OpExecutionDirector director = new OpExecutionDirector();
@ -6017,7 +6149,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, normalizationSession.getTrId());
OpExecution4Normalization opEx = new OpExecution4Normalization(
service, normalizationSession);
OpExecutionDirector director = new OpExecutionDirector();
@ -6075,7 +6208,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, denormalizationSession.getTrId());
OpExecution4Denormalization opEx = new OpExecution4Denormalization(
service, denormalizationSession);
OpExecutionDirector director = new OpExecutionDirector();
@ -6129,7 +6263,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTabularResourceLocked(service, unionSession.getTrId());
OpExecution4Union opEx = new OpExecution4Union(service,
unionSession);
OpExecutionDirector director = new OpExecutionDirector();
@ -6199,27 +6334,27 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
*/
@Override
public ArrayList<LicenceData> getLicences() throws TDGWTServiceException {
public ArrayList<LicenceData> getLicences() throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
ArrayList<LicenceData> licences=new ArrayList<LicenceData>();
Licence[] licencesArray=Licence.values();
ArrayList<LicenceData> licences = new ArrayList<LicenceData>();
Licence[] licencesArray = Licence.values();
Licence licence;
LicenceData licenceData;
for(int i=0; i<licencesArray.length;i++){
licence=licencesArray[i];
licenceData=new LicenceData(i, licence.toString());
for (int i = 0; i < licencesArray.length; i++) {
licence = licencesArray[i];
licenceData = new LicenceData(i, licence.toString());
licences.add(licenceData);
}
logger.debug("Licences: "+licences.size());
logger.debug("Licences: " + licences.size());
return licences;
} catch (TDGWTSessionExpiredException e) {
@ -6233,7 +6368,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Error in get Licences: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -39,11 +39,6 @@ public class OpExecution4Clone extends OpExecutionBuilder {
@Override
public void buildOpEx() throws TDGWTServiceException {
logger.debug(cloneTabularResourceSession.toString());
if(cloneTabularResourceSession.getTrId()==null){
logger.error("TRId is null");
new TDGWTServiceException("No valid tabular resource id present");
}
TRId trId=cloneTabularResourceSession.getTrId();
TableId tableId;

View File

@ -40,12 +40,6 @@ public class OpExecution4FilterColumn extends OpExecutionBuilder {
@Override
public void buildOpEx() throws TDGWTServiceException {
logger.debug(filterColumnSession.toString());
if(filterColumnSession.getColumn().getTrId()==null){
logger.error("TRId is null");
new TDGWTServiceException("No valid tabular resource id present");
}
OperationDefinition operationDefinition;
operationDefinition = OperationDefinitionMap.map(

View File

@ -42,11 +42,10 @@ public class OpExecution4ReplaceBatch extends OpExecutionBuilder {
@Override
public void buildOpEx() throws TDGWTServiceException {
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
logger.debug(replaceBatchColumnSession.toString());
for (ReplaceEntry re : replaceBatchColumnSession.getReplaceEntryList()) {
OperationExecution invocation = null;
logger.debug(replaceBatchColumnSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();

View File

@ -28,7 +28,8 @@ public class TabResource implements Serializable {
protected Contacts owner;
protected boolean valid;
protected boolean finalized;
protected boolean locked;
public TabResource() {
}
@ -166,6 +167,14 @@ public class TabResource implements Serializable {
this.licence = licence;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
@Override
public String toString() {
return "TabResource [trId=" + trId + ", id=" + id + ", name=" + name
@ -173,10 +182,8 @@ public class TabResource implements Serializable {
+ ", date=" + date + ", right=" + right + ", validFrom="
+ validFrom + ", validUntilTo=" + validUntilTo + ", licence="
+ licence + ", owner=" + owner + ", valid=" + valid
+ ", finalized=" + finalized + "]";
+ ", finalized=" + finalized + ", locked=" + locked + "]";
}
}