use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class RemoveRole method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, CannotManageException, ObjectNotFoundException, ObjectCannotBeUpdated {
String[] params = getDataList(requestData);
Logger.msg(3, "RemoveRole: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("RemoveRole must have one paramater:" + Arrays.toString(params));
LookupManager lookup = Gateway.getLookupManager();
RolePath thisRole = lookup.getRolePath(params[0]);
AgentPath[] agents = Gateway.getLookup().getAgents(thisRole);
if (agents.length > 0)
throw new ObjectCannotBeUpdated("Cannot remove role as " + agents.length + " other agents still hold it.");
lookup.delete(thisRole);
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class GraphableVertex method updatePropertiesFromCollection.
public void updatePropertiesFromCollection(BuiltInVertexProperties vertexProp, CastorHashMap newProps) throws InvalidDataException {
switch(vertexProp) {
case ACTIVITY_DEF_URN:
if (this instanceof Activity) {
Object value = null;
Activity thisAct = (Activity) this;
if (newProps.containsKey(thisAct.getID()))
value = newProps.get(thisAct.getID());
else if (newProps.containsKey(thisAct.getTypeName()))
value = newProps.get(thisAct.getTypeName());
if (value != null) {
Logger.msg(5, "GraphableVertex.updatePropertiesFromCollection(" + vertexProp + ") - UPDATING typeName:" + thisAct.getTypeName() + " id:" + thisAct.getID());
mProperties.setBuiltInProperty(ACTIVITY_DEF_URN, value);
} else
Logger.msg(5, "GraphableVertex.updatePropertiesFromCollection(" + vertexProp + ") - SKIPPING typeName:" + thisAct.getTypeName() + " id:" + thisAct.getID());
}
break;
default:
throw new InvalidDataException("Cannot handle BuiltInVertexProperty:" + vertexProp);
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class StateMachineCache method buildObject.
@Override
public StateMachine buildObject(String name, int version, ItemPath path, String data) throws InvalidDataException {
try {
StateMachine thisStateMachine = (StateMachine) Gateway.getMarshaller().unmarshall(data);
thisStateMachine.validate();
thisStateMachine.setName(name);
thisStateMachine.setVersion(version);
thisStateMachine.setItemPath(path);
return thisStateMachine;
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidDataException("Could not unmarshall State Machine '" + name + "' v" + version + ": " + ex.getMessage());
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class Script method parseIncludeTag.
private void parseIncludeTag(NodeList includeList) throws ScriptParsingException {
for (int i = 0; i < includeList.getLength(); i++) {
Element include = (Element) includeList.item(i);
if (!(include.hasAttribute("name") && include.hasAttribute("version")))
throw new ScriptParsingException("Script include declaration incomplete, must have name and version");
String includeName = include.getAttribute("name");
String includeVersion = include.getAttribute("version");
try {
Script includedScript = LocalObjectLoader.getScript(includeName, Integer.parseInt(includeVersion));
includedScript.setContext(context);
mIncludes.add(includedScript);
for (Parameter includeParam : includedScript.getInputParams().values()) {
addIncludedInputParam(includeParam.getName(), includeParam.getType());
}
} catch (NumberFormatException e) {
throw new ScriptParsingException("Invalid version in imported script name:'" + includeName + "', version:'" + includeVersion + "'");
} catch (ScriptingEngineException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script " + includeName + " v" + includeVersion + ": " + e.getMessage());
} catch (ObjectNotFoundException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script " + includeName + " v" + includeVersion + " not found.");
} catch (InvalidDataException e) {
Logger.error(e);
throw new ScriptParsingException("Error parsing imported script " + includeName + " v" + includeVersion + " was invalid: " + e.getMessage());
}
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ActDefCache method buildObject.
@Override
public ActivityDef buildObject(String name, int version, ItemPath path, String data) throws InvalidDataException {
try {
ActivityDef thisActDef = (ActivityDef) Gateway.getMarshaller().unmarshall(data);
thisActDef.setBuiltInProperty(VERSION, version);
thisActDef.setName(name);
thisActDef.setVersion(version);
thisActDef.setItemPath(path);
return thisActDef;
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidDataException("Could not unmarshall Activity '" + name + "' v" + version + ": " + ex.getMessage());
}
}
Aggregations