use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class CompositeActivityDef method setChildrenGraphModel.
@Override
public void setChildrenGraphModel(GraphModel childrenGraph) throws InvalidDataException {
super.setChildrenGraphModel(childrenGraph);
childrenGraph.setVertexOutlineCreator(new LifecycleVertexOutlineCreator());
try {
setRefChildActDef(findRefActDefs(childrenGraph));
} catch (ObjectNotFoundException e) {
throw new InvalidDataException(e.getMessage());
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class AddC2KObject method runActivityLogic.
// requestdata is xmlstring
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, PersistencyException {
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddC2KObject: agent:" + " item:" + item + " params:" + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("AddC2KObject: Invalid parameters " + Arrays.toString(params));
try {
C2KLocalObject obj = (C2KLocalObject) Gateway.getMarshaller().unmarshall(params[0]);
Gateway.getStorage().put(item, obj, locker);
} catch (Exception e) {
throw new InvalidDataException("AddC2KObject: Could not unmarshall new object: " + params[0]);
}
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class AddMemberToCollection method runActivityLogic.
/**
* <pre>
* Generates a new slot in a Dependency for the given item
*
* Params:
* 0 - collection name
* 1 - target entity key
* 2 - slot properties
* </pre>
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException, InvalidCollectionModification {
String collName;
ItemPath newChild;
Dependency dep;
CastorHashMap props = null;
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddMemberToCollection: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
try {
collName = params[0];
try {
newChild = new ItemPath(params[1]);
} catch (InvalidItemPathException e) {
newChild = new DomainPath(params[1]).getItemPath();
}
if (params.length > 2) {
Logger.msg(5, "AddMemberToCollection: Unmarshalling Properties:" + params[2]);
props = (CastorHashMap) Gateway.getMarshaller().unmarshall(params[2]);
}
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("AddMemberToCollection: Invalid parameters " + Arrays.toString(params));
}
// load collection
C2KLocalObject collObj = Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
if (!(collObj instanceof Dependency))
throw new InvalidDataException("AddMemberToCollection operates on Dependency only.");
dep = (Dependency) collObj;
// find member and assign entity
if (props == null)
dep.addMember(newChild);
else
dep.addMember(newChild, props, dep.getClassProps());
Gateway.getStorage().put(item, dep, locker);
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ClearSlot method runActivityLogic.
/**
* Params: 0 - collection name 1 - slot number
*
* @throws ObjectNotFoundException
* @throws PersistencyException
* @throws ObjectCannotBeUpdated
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated {
String collName;
int slotNo;
Aggregation agg;
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "ClearSlot: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
try {
collName = params[0];
slotNo = Integer.parseInt(params[1]);
} catch (Exception e) {
throw new InvalidDataException("ClearSlot: Invalid parameters " + Arrays.toString(params));
}
// load collection
try {
agg = (Aggregation) Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
} catch (PersistencyException ex) {
Logger.error(ex);
throw new PersistencyException("ClearSlot: Error loading collection '" + collName + "': " + ex.getMessage());
}
// find member and clear
boolean stored = false;
for (AggregationMember member : agg.getMembers().list) {
if (member.getID() == slotNo) {
if (member.getItemPath() == null)
throw new ObjectCannotBeUpdated("ClearSlot: Member slot " + slotNo + " already empty");
member.clearItem();
stored = true;
break;
}
}
if (!stored) {
throw new ObjectNotFoundException("ClearSlot: Member slot " + slotNo + " not found.");
}
try {
Gateway.getStorage().put(item, agg, locker);
} catch (PersistencyException e) {
Logger.error(e);
throw new PersistencyException("ClearSlot: Error storing collection");
}
return requestData;
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class WriteProperty method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, PersistencyException {
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "WriteProperty: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 2)
throw new InvalidDataException("WriteProperty: invalid parameters " + Arrays.toString(params));
String name = params[0];
String value = params[1];
write(item, name, value, locker);
return requestData;
}
Aggregations