@Override
public UpdateContainer undoIt(Workspace workspace) {
Worksheet wk = workspace.getWorksheet(worksheetId);
WebService service = null;
DataSource source = null;
if (!wk.containService()) {
logger.error("The worksheet does not have a service object.");
// return new UpdateContainer(new ErrorUpdate(
// "Error occured while deleting the model. The worksheet does not have a service object."));
} else
service = wk.getMetadataContainer().getService();
if (!wk.containSource()) {
logger.error("The worksheet does not have a source object.");
// return new UpdateContainer(new ErrorUpdate(
// "Error occured while deleting the model. The worksheet does not have a source object."));
} else
source = wk.getMetadataContainer().getSource();
try {
// one way to un-publish is just set the service model to null and publish it again.
// in this way the invocation part will be kept in the repository.
// ServicePublisher servicePublisher = new ServicePublisher(service);
// servicePublisher.publish("N3", true);
// deleting the service completely from the repository.
if (service != null) {
WebServiceLoader.getInstance().deleteSourceByUri(service.getUri());
logger.info("Service model has successfully been deleted from repository.");
return new UpdateContainer(new ErrorUpdate(
"Service model has successfully been deleted from repository."));
}
else {
DataSourceLoader.getInstance().deleteSourceByUri(source.getUri());
logger.info("Source model has successfully been deleted from repository.");
return new UpdateContainer(new ErrorUpdate(
"Source model has successfully been deleted from repository."));
}
} catch (Exception e) {
logger.error("Error occured while deleting the source/service " + service.getId(), e);
return new UpdateContainer(new ErrorUpdate(
"Error occured while deleting the source/service " + service.getId()));
}
}