Search in sources :

Example 41 with InvalidDataException

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

Example 42 with InvalidDataException

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

Example 43 with InvalidDataException

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

Example 44 with InvalidDataException

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());
        }
    }
}
Also used : CompiledScript(javax.script.CompiledScript) Element(org.w3c.dom.Element) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 45 with InvalidDataException

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

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