Search in sources :

Example 6 with InvalidDataException

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);
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility)

Example 7 with InvalidDataException

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);
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 8 with InvalidDataException

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;
        }
    }
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Property(org.cristalise.kernel.property.Property)

Example 9 with InvalidDataException

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());
    }
}
Also used : Script(org.cristalise.kernel.scripting.Script) ScriptingEngineException(org.cristalise.kernel.scripting.ScriptingEngineException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 10 with InvalidDataException

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());
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) Dependency(org.cristalise.kernel.collection.Dependency)

Aggregations

InvalidDataException (org.cristalise.kernel.common.InvalidDataException)91 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)40 PersistencyException (org.cristalise.kernel.common.PersistencyException)33 IOException (java.io.IOException)14 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)11 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)11 DomainPath (org.cristalise.kernel.lookup.DomainPath)10 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)9 CannotManageException (org.cristalise.kernel.common.CannotManageException)8 AgentPath (org.cristalise.kernel.lookup.AgentPath)8 Schema (org.cristalise.kernel.persistency.outcome.Schema)8 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)7 ItemPath (org.cristalise.kernel.lookup.ItemPath)7 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)6 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)6 MappingException (org.exolab.castor.mapping.MappingException)6 MarshalException (org.exolab.castor.xml.MarshalException)6 ValidationException (org.exolab.castor.xml.ValidationException)6 ArrayList (java.util.ArrayList)5 XPathExpressionException (javax.xml.xpath.XPathExpressionException)5