use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class ActivitySlotDef method getTheActivityDef.
public ActivityDef getTheActivityDef() throws ObjectNotFoundException, InvalidDataException {
if (theActivityDef == null) {
try {
Logger.msg(5, "ActivitySlotDef.getTheActivityDef() - try to load from item desc collection of ActSlotDef:" + getName());
DescriptionObject[] parentActDefs = ((CompositeActivityDef) getParent()).getBuiltInCollectionResource(ACTIVITY);
for (DescriptionObject thisActDef : parentActDefs) {
String childUUID = thisActDef.getItemID();
Logger.msg(5, "ActivitySlotDef.getTheActivityDef() - Collection childUUID:" + childUUID + " of ActSlotDef:" + getName());
if (childUUID.equals(getActivityDef()) || thisActDef.getName().equals(getActivityDef())) {
ActivityDef currentActDef = (ActivityDef) thisActDef;
Integer requiredVersion = deriveVersionNumber(getBuiltInProperty(VERSION));
if (// collection indicated a different version - get the right one
currentActDef.getVersion() != requiredVersion)
setTheActivityDef(LocalObjectLoader.getActDef(childUUID, requiredVersion));
else
// use the existing one
setTheActivityDef(currentActDef);
break;
}
}
}// old def with no collection
catch (ObjectNotFoundException ex) {
}
if (theActivityDef == null) {
// try to load from property
Logger.msg(5, "ActivitySlotDef.getTheActivityDef() - try to load from property of ActSlotDef:" + getName());
Integer version = deriveVersionNumber(getBuiltInProperty(VERSION));
if (version == null)
throw new InvalidDataException("No version defined in ActivityDefSlot " + getName());
setTheActivityDef(LocalObjectLoader.getActDef(getActivityDef(), version));
}
}
return theActivityDef;
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class CompositeActivityDef method export.
@Override
public void export(Writer imports, File dir) throws InvalidDataException, ObjectNotFoundException, IOException {
// rebuild the child refs in case any slots have been removed
setRefChildActDef(findRefActDefs(getChildrenGraphModel()));
// export child activitz defs, routing scripts and schemas
for (GraphableVertex vert : getChildren()) {
if (vert instanceof AndSplitDef) {
try {
((AndSplitDef) vert).getRoutingScript().export(imports, dir);
} catch (ObjectNotFoundException ex) {
}
} else if (vert instanceof ActivitySlotDef) {
ActivityDef refAct = ((ActivitySlotDef) vert).getTheActivityDef();
refAct.export(imports, dir);
}
}
String tc = COMP_ACT_DESC_RESOURCE.getTypeCode();
try {
// export marshalled compAct
String compactXML = Gateway.getMarshaller().marshall(this);
FileStringUtility.string2File(new File(new File(dir, tc), getActName() + (getVersion() == null ? "" : "_" + getVersion()) + ".xml"), compactXML);
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Couldn't marshall composite activity def " + getActName());
}
if (imports != null) {
imports.write("<Workflow " + getExportAttributes(tc) + ">" + getExportCollections());
for (ActivityDef childActDef : refChildActDef) {
imports.write("<Activity name=\"" + childActDef.getActName() + "\" id=\"" + childActDef.getItemID() + "\" version=\"" + childActDef.getVersion() + "\"/>");
}
imports.write("</Workflow>\n");
}
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class AndSplitDef method getRoutingScript.
public Script getRoutingScript() throws ObjectNotFoundException, InvalidDataException {
String scriptName = (String) getBuiltInProperty(ROUTING_SCRIPT_NAME);
Integer scriptVersion;
try {
String scriptVerStr = (String) getBuiltInProperty(ROUTING_SCRIPT_VERSION);
if (scriptVerStr != null && !scriptVerStr.isEmpty())
scriptVersion = Integer.valueOf(scriptVerStr.toString());
else
throw new ObjectNotFoundException();
} catch (NumberFormatException e) {
throw new InvalidDataException(e.getMessage());
}
return LocalObjectLoader.getScript(scriptName, scriptVersion);
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class JobPusher method run.
@Override
public void run() {
String tName = "Agent job pusher for " + itemPath + ":" + activity.getPath() + " to role " + myRole;
Thread.currentThread().setName(tName);
Logger.msg(7, "JobPusher.run() - Started:" + tName);
try {
for (AgentPath nextAgent : Gateway.getLookup().getAgents(myRole)) {
Logger.msg(7, "JobPusher.run() - Calculating jobs for agent:" + nextAgent);
try {
// get joblist for agent
JobArrayList jobList = new JobArrayList(this.activity.calculateJobs(nextAgent, itemPath, false));
// push it to the agent
String stringJobs = Gateway.getMarshaller().marshall(jobList);
Agent thisAgent = AgentHelper.narrow(nextAgent.getIOR());
Logger.msg(7, "JobPusher.run() - Calling refreshJobList() with " + jobList.list.size() + " jobs for agent " + nextAgent + " from " + activity.getPath());
thisAgent.refreshJobList(itemPath.getSystemKey(), activity.getPath(), stringJobs);
} catch (Exception ex) {
Logger.error("JobPusher.run() - Agent " + nextAgent + " of role " + myRole + " could not be found to be informed of a change in " + itemPath);
Logger.error(ex);
}
}
} catch (ObjectNotFoundException e) {
Logger.warning("JobPusher cannot push jobs, it did not find any agents for role:" + myRole);
}
Logger.msg(7, "JobPusher.run() - FINISHED:" + tName);
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class AddNewCollectionDescription method runActivityLogic.
/**
* Params: 0 - collection name 1 - collection type (Aggregation, Dependency)
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException {
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddNewCollectionDescription: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 2)
throw new InvalidDataException("AddNewCollectionDescription: Invalid parameters " + Arrays.toString(params));
String collName = params[0];
String collType = params[1];
// check if collection already exists
try {
Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
throw new ObjectAlreadyExistsException("Collection '" + collName + "' already exists");
} catch (ObjectNotFoundException ex) {
// collection doesn't exist
}
CollectionDescription<?> newCollDesc;
if (collType.equalsIgnoreCase("Aggregation"))
newCollDesc = new AggregationDescription(collName);
else if (collType.equalsIgnoreCase("Dependency"))
newCollDesc = new DependencyDescription(collName);
else
throw new InvalidDataException("AddNewCollectionDescription: Invalid type: '" + collType + "' /Aggregation or Dependency)");
// store it
try {
Gateway.getStorage().put(item, newCollDesc, locker);
} catch (PersistencyException e) {
throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '" + collName + "': " + e.getMessage());
}
return requestData;
}
Aggregations