Search in sources :

Example 36 with ObjectNotFoundException

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

Example 37 with ObjectNotFoundException

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");
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) File(java.io.File) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) IOException(java.io.IOException)

Example 38 with ObjectNotFoundException

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

Example 39 with ObjectNotFoundException

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);
}
Also used : Agent(org.cristalise.kernel.entity.Agent) AgentPath(org.cristalise.kernel.lookup.AgentPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) JobArrayList(org.cristalise.kernel.entity.agent.JobArrayList) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 40 with ObjectNotFoundException

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;
}
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

ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)59 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)38 PersistencyException (org.cristalise.kernel.common.PersistencyException)27 DomainPath (org.cristalise.kernel.lookup.DomainPath)12 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)12 ItemPath (org.cristalise.kernel.lookup.ItemPath)12 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)11 AgentPath (org.cristalise.kernel.lookup.AgentPath)11 CannotManageException (org.cristalise.kernel.common.CannotManageException)9 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)8 IOException (java.io.IOException)7 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)7 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)6 ObjectCannotBeUpdated (org.cristalise.kernel.common.ObjectCannotBeUpdated)6 InvalidTransitionException (org.cristalise.kernel.common.InvalidTransitionException)5 ItemProxy (org.cristalise.kernel.entity.proxy.ItemProxy)5 InvalidAgentPathException (org.cristalise.kernel.lookup.InvalidAgentPathException)5 Property (org.cristalise.kernel.property.Property)5 MappingException (org.exolab.castor.mapping.MappingException)5 MarshalException (org.exolab.castor.xml.MarshalException)5