Search in sources :

Example 61 with InvalidDataException

use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.

the class ActivityDef method makeDescCollection.

public Dependency makeDescCollection(BuiltInCollections collection, DescriptionObject... descs) throws InvalidDataException {
    // TODO: restrict membership based on kernel property desc
    Dependency descDep = new Dependency(collection.getName());
    if (mVersion != null && mVersion > -1) {
        descDep.setVersion(mVersion);
    }
    for (DescriptionObject thisDesc : descs) {
        if (thisDesc == null)
            continue;
        try {
            DependencyMember descMem = descDep.addMember(thisDesc.getItemPath());
            descMem.setBuiltInProperty(VERSION, thisDesc.getVersion());
        } catch (Exception e) {
            Logger.error(e);
            throw new InvalidDataException("Problem creating description collection for " + thisDesc + " in " + getName());
        }
    }
    return descDep;
}
Also used : DependencyMember(org.cristalise.kernel.collection.DependencyMember) DescriptionObject(org.cristalise.kernel.utils.DescriptionObject) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Dependency(org.cristalise.kernel.collection.Dependency) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 62 with InvalidDataException

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

Example 63 with InvalidDataException

use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.

the class ActivityRenderer method draw.

/**
 * Draws the Activity as a 3D rectangle without borders, with text lines for Name, DefinitionName, State, WaitTime and errors
 */
@Override
public void draw(Graphics2D g2d, Vertex vertex) {
    Activity activity = (Activity) vertex;
    boolean hasError = !activity.verify();
    drawOutline3DRect(g2d, vertex, getActColor(activity, hasError));
    // String description = activity.getDescription();
    ArrayList<String> linesOfText = new ArrayList<String>();
    String type = activity.getTypeName();
    if (type != null)
        linesOfText.add("(" + type + ")");
    linesOfText.add(activity.getName());
    if (hasError) {
        linesOfText.add(activity.getErrors());
    } else {
        String stateName = "Invalid State";
        try {
            stateName = activity.getStateName();
        } catch (InvalidDataException | NullPointerException ex) {
        }
        linesOfText.add(stateName + (" " + getWaitTime(activity.getStateDate())));
    }
    drawLinesOfTexts(g2d, vertex, linesOfText, mTextPaint);
}
Also used : ArrayList(java.util.ArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Activity(org.cristalise.kernel.lifecycle.instance.Activity)

Example 64 with InvalidDataException

use of org.cristalise.kernel.common.InvalidDataException in project kernel by cristal-ise.

the class AddDomainPath method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
    String[] params = getDataList(requestData);
    if (Logger.doLog(3))
        Logger.msg(3, "AddDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
    if (params.length != 1)
        throw new InvalidDataException("AddDomainPath: Invalid parameters: " + Arrays.toString(params));
    Gateway.getLookupManager().add(new DomainPath(params[0], item));
    return requestData;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 65 with InvalidDataException

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

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