use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ItemProxy method initialise.
/**
* Initialise the new Item with instance data which is normally is created from descriptions
*
* @param agentId the Agent who is creating the Item
* @param itemProps initial list of Properties of the Item
* @param workflow new Lifecycle of the Item
* @param colls the initial state of the Item's collections
*
* @throws AccessRightsException Agent does not the rights to create an Item
* @throws InvalidDataException data was invalid
* @throws PersistencyException there was a database probles during Item initialisation
* @throws ObjectNotFoundException Object not found
* @throws MarshalException there was a problem converting those objects to XML
* @throws ValidationException XML was not valid
* @throws IOException IO errors
* @throws MappingException errors in XML marshall/unmarshall mapping
* @throws InvalidCollectionModification invalid Collection
*/
public void initialise(AgentPath agentId, PropertyArrayList itemProps, CompositeActivity workflow, CollectionArrayList colls) throws AccessRightsException, InvalidDataException, PersistencyException, ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException, InvalidCollectionModification {
Logger.msg(7, "ItemProxy.initialise() - started");
CastorXMLUtility xml = Gateway.getMarshaller();
if (itemProps == null)
throw new InvalidDataException("ItemProxy.initialise() - No initial properties supplied");
String propString = xml.marshall(itemProps);
String wfString = "";
if (workflow != null)
wfString = xml.marshall(workflow);
String collString = "";
if (colls != null)
collString = xml.marshall(colls);
getItem().initialise(agentId.getSystemKey(), propString, wfString, collString);
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ItemProxy method requestAction.
/**
* Executes the given Job
*
* @param thisJob the Job to be executed
* @return the result of the execution
* @throws AccessRightsException Agent does not the rights to execute this operation
* @throws PersistencyException there was a database problems during this operations
* @throws InvalidDataException data was invalid
* @throws InvalidTransitionException the Transition cannot be executed
* @throws ObjectNotFoundException Object not found
* @throws ObjectAlreadyExistsException Object already exists
* @throws InvalidCollectionModification Invalid collection
*/
public String requestAction(Job thisJob) throws AccessRightsException, InvalidTransitionException, ObjectNotFoundException, InvalidDataException, PersistencyException, ObjectAlreadyExistsException, InvalidCollectionModification {
String outcome = thisJob.getOutcomeString();
if (outcome == null) {
if (thisJob.isOutcomeRequired())
throw new InvalidDataException("Outcome is required.");
else
outcome = "";
}
if (thisJob.getAgentPath() == null)
throw new InvalidDataException("No Agent specified.");
Logger.msg(7, "ItemProxy.requestAction() - executing " + thisJob.getStepPath() + " for " + thisJob.getAgentName());
if (thisJob.getDelegatePath() == null)
return getItem().requestAction(thisJob.getAgentPath().getSystemKey(), thisJob.getStepPath(), thisJob.getTransition().getId(), outcome);
else
return getItem().delegatedAction(thisJob.getAgentPath().getSystemKey(), thisJob.getDelegatePath().getSystemKey(), thisJob.getStepPath(), thisJob.getTransition().getId(), outcome);
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class Dependency method addToItemProperties.
/**
* Add Dependency specific values to ItemProperties. First checks if there is a Script to be executed,
* if no Script defined it will use the default conversion implemented for BuiltInCollections
*
* @param props the current list of ItemProperties
*/
public void addToItemProperties(PropertyArrayList props) throws InvalidDataException, ObjectNotFoundException {
Logger.msg(2, "Dependency.addToItemProperties(" + getName() + ") - Starting ...");
// convert to BuiltInCollections
BuiltInCollections builtInColl = BuiltInCollections.getValue(getName());
for (DependencyMember member : getMembers().list) {
String memberUUID = member.getChildUUID();
Integer memberVer = LocalObjectLoader.deriveVersionNumber(member.getBuiltInProperty(VERSION));
if (memberVer == null) {
throw new InvalidDataException("Version is null for Collection:" + getName() + ", MemberUUID:" + memberUUID);
}
// - or this is not a BuiltInCollection
if (convertToItemPropertyByScript(props, member) || builtInColl == null)
continue;
Logger.msg(5, "Dependency.addToItemProperties() - BuiltIn Dependency:" + getName() + " memberUUID:" + memberUUID);
// LocalObjectLoader checks if data is valid and loads object to cache
switch(builtInColl) {
// ***************************************************************************************************
case SCHEMA:
LocalObjectLoader.getSchema(memberUUID, memberVer);
props.put(new Property(SCHEMA_URN, memberUUID + ":" + memberVer));
break;
// ***************************************************************************************************
case SCRIPT:
LocalObjectLoader.getScript(memberUUID, memberVer);
props.put(new Property(SCRIPT_URN, memberUUID + ":" + memberVer));
break;
// ***************************************************************************************************
case QUERY:
LocalObjectLoader.getQuery(memberUUID, memberVer);
props.put(new Property(QUERY_URN, memberUUID + ":" + memberVer));
break;
// ***************************************************************************************************
case STATE_MACHINE:
if (Gateway.getProperties().getBoolean("Dependency.addStateMachineURN", false)) {
LocalObjectLoader.getStateMachine(memberUUID, memberVer);
props.put(new Property(STATE_MACHINE_URN, memberUUID + ":" + memberVer));
}
break;
// ***************************************************************************************************
case WORKFLOW:
if (Gateway.getProperties().getBoolean("Dependency.addWorkflowURN", false)) {
LocalObjectLoader.getCompActDef(memberUUID, memberVer);
props.put(new Property(WORKFLOW_URN, memberUUID + ":" + memberVer));
}
break;
// ***************************************************************************************************
default:
Logger.msg(8, "Dependency.addToItemProperties() - Cannot handle BuiltIn Dependency:" + getName());
break;
}
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class DependencyMember method evaluateScript.
/**
* @return either PropertyArrayList or CastorHashMap
*
* @throws InvalidDataException
* @throws ObjectNotFoundException
*/
protected Object evaluateScript() throws InvalidDataException, ObjectNotFoundException {
Logger.msg(5, "DependencyMember.evaluateScript() - memberUUID:" + getChildUUID());
Script script = LocalObjectLoader.getScript(getProperties());
try {
script.setInputParamValue("dependencyMember", this);
script.setInputParamValue("storage", Gateway.getStorage());
script.setInputParamValue("proxy", Gateway.getProxyManager());
script.setInputParamValue("lookup", Gateway.getLookup());
return script.evaluate(getItemPath(), getProperties(), null, null);
} catch (ScriptingEngineException e) {
Logger.error(e);
throw new InvalidDataException(e.getMessage());
}
}
use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.
the class ActivityDef method configureInstance.
/**
*/
@Override
public void configureInstance(WfVertex act) throws InvalidDataException, ObjectNotFoundException {
super.configureInstance(act);
try {
for (String collName : Gateway.getStorage().getClusterContents(itemPath, ClusterType.COLLECTION)) {
Logger.msg(5, "ActivityDef.configureInstance(" + getName() + ") - Processing collection:" + collName);
String verStr = (mVersion == null || mVersion == -1) ? "last" : String.valueOf(mVersion);
Dependency dep = null;
try {
dep = (Dependency) Gateway.getStorage().get(itemPath, ClusterType.COLLECTION + "/" + collName + "/" + verStr, null);
} catch (ObjectNotFoundException e) {
if (Logger.doLog(8))
Logger.warning("Unavailable Collection path:" + itemPath + "/" + ClusterType.COLLECTION + "/" + collName + "/" + verStr);
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException("Collection:" + collName + " error:" + e.getMessage());
}
if (dep != null)
dep.addToVertexProperties(act.getProperties());
}
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException(e.getMessage());
}
}
Aggregations