use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class RemoveDomainContext method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
String[] params = getDataList(requestData);
Logger.msg(3, "RemoveDomainContext: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("RemoveDomainContext: Invalid parameters " + Arrays.toString(params));
DomainPath pathToDelete = new DomainPath(params[0]);
if (!pathToDelete.exists())
throw new ObjectNotFoundException("Context " + pathToDelete + " does not exist");
try {
pathToDelete.getItemPath();
throw new InvalidDataException("Path " + pathToDelete + " is an Entity. Use its own Erase step instead, or RemoveAgent.");
} catch (ObjectNotFoundException ex) {
}
if (Gateway.getLookup().getChildren(pathToDelete).hasNext())
throw new ObjectCannotBeUpdated("Context " + pathToDelete + " is not empty. Cannot delete.");
Gateway.getLookupManager().delete(pathToDelete);
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class StateMachine method export.
@Override
public void export(Writer imports, File dir) throws IOException, InvalidDataException {
String smXML;
String typeCode = BuiltInResources.STATE_MACHINE_RESOURCE.getTypeCode();
String fileName = getName() + (getVersion() == null ? "" : "_" + getVersion()) + ".xml";
try {
smXML = Gateway.getMarshaller().marshall(this);
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Couldn't marshall state machine " + getName());
}
FileStringUtility.string2File(new File(new File(dir, typeCode), fileName), smXML);
if (imports != null) {
imports.write("<StateMachineResource " + "name=\"" + getName() + "\" " + (getItemPath() == null ? "" : "id=\"" + getItemID() + "\" ") + (getVersion() == null ? "" : "version=\"" + getVersion() + "\">") + "boot/" + typeCode + "/" + fileName + "</StateMachineResource>\n");
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class CompositeActivity method runNext.
@Override
public void runNext(AgentPath agent, ItemPath itemPath, Object locker) throws InvalidDataException {
if (!getStateMachine().getState(state).isFinished()) {
Transition trans = null;
try {
for (Transition possTran : getStateMachine().getPossibleTransitions(this, agent).keySet()) {
if (trans == null || (trans.isFinishing() && !possTran.isFinishing())) {
trans = possTran;
} else if (trans.isFinishing() == possTran.isFinishing()) {
Logger.warning("Unclear choice of transition possible from current state for Composite Activity '" + getName() + "'. Cannot automatically proceed.");
setActive(true);
return;
}
}
} catch (ObjectNotFoundException e) {
Logger.error(e);
throw new InvalidDataException("Problem calculating possible transitions for agent " + agent.toString());
}
if (trans == null) {
// current agent can't proceed
Logger.msg(3, "Not possible for the current agent to proceed with the Composite Activity '" + getName() + "'.");
setActive(true);
return;
} else {
// automatically execute the next outcome if it doesn't require an outcome.
if (trans.hasOutcome(getProperties()) || trans.hasScript(getProperties())) {
Logger.msg(3, "Composite activity '" + getName() + "' has script or schema defined. Cannot proceed automatically.");
setActive(true);
return;
}
try {
request(agent, null, itemPath, trans.getId(), null, locker);
if (// don't run next if we didn't finish
!trans.isFinishing())
return;
} catch (Exception e) {
Logger.error(e);
setActive(true);
throw new InvalidDataException("Problem completing composite activity: " + e.getMessage());
}
}
}
super.runNext(agent, itemPath, locker);
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class CompositeActivity method run.
@Override
public void run(AgentPath agent, ItemPath itemPath, Object locker) throws InvalidDataException {
Logger.msg(8, "CompositeActivity.run() path:" + getPath() + " state:" + getState());
super.run(agent, itemPath, locker);
Transition autoStart = getAutoStart(agent, getStateMachine().getState(state));
if (autoStart != null) {
try {
request(agent, null, itemPath, autoStart.getId(), null, locker);
} catch (RuntimeException e) {
throw e;
} catch (AccessRightsException e) {
Logger.warning("Agent:" + agent + " didn't have permission to start the activity:" + getPath() + ", so leave it waiting");
return;
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Problem initializing composite activity: " + e.getMessage());
}
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ActivitySlotDef method instantiate.
@Override
public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException {
Activity newActivity = (Activity) getTheActivityDef().instantiate();
configureInstance(newActivity);
if (newActivity.getProperties().getAbstract().size() > 0) {
throw new InvalidDataException("Abstract properties not overridden: " + newActivity.getProperties().getAbstract().toString());
}
return newActivity;
}
Aggregations