Search in sources :

Example 46 with ObjectNotFoundException

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

the class Activity method pushJobsToAgents.

/**
 * Collects all Role names which are associated with this Activity and the Transitions of the current State,
 * and ....
 *
 * @param itemPath
 */
protected void pushJobsToAgents(ItemPath itemPath) {
    // Shall contain a set of unique role names
    Set<String> roleNames = new TreeSet<String>();
    String role = getCurrentAgentRole();
    if (StringUtils.isNotBlank(role)) {
        for (String r : role.split(",")) roleNames.add(r);
    }
    try {
        for (Transition trans : getStateMachine().getState(getState()).getPossibleTransitions().values()) {
            role = trans.getRoleOverride(getProperties());
            if (StringUtils.isNotBlank(role))
                roleNames.add(role);
        }
        Logger.msg(7, "Activity.pushJobsToAgents() - Pushing jobs to " + roleNames.size() + " roles");
        for (String roleName : roleNames) {
            pushJobsToAgents(itemPath, Gateway.getLookup().getRolePath(roleName));
        }
    } catch (InvalidDataException ex) {
        Logger.warning("Activity.pushJobsToAgents() - " + ex.getMessage());
    } catch (ObjectNotFoundException e) {
        Logger.warning("Activity.pushJobsToAgents() - Activity role '" + role + "' not found.");
    }
}
Also used : TreeSet(java.util.TreeSet) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Transition(org.cristalise.kernel.lifecycle.instance.stateMachine.Transition) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 47 with ObjectNotFoundException

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

the class Workflow method requestAction.

public String requestAction(AgentPath agent, AgentPath delegator, String stepPath, ItemPath itemPath, int transitionID, String requestData) throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectCannotBeUpdated, CannotManageException, InvalidCollectionModification {
    Logger.msg(3, "Workflow::requestAction() - transition:" + transitionID + " step:" + stepPath + " agent:" + agent);
    GraphableVertex vert = search(stepPath);
    if (vert != null && vert instanceof Activity)
        return ((Activity) vert).request(agent, delegator, itemPath, transitionID, requestData, this);
    else
        throw new ObjectNotFoundException(stepPath + " not found");
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex)

Example 48 with ObjectNotFoundException

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

the class Outcome method setMetaDataFromPath.

/**
 * Retrieves the SchemaName, Version, EevetnId triplet from the path. Check getClusterPath() implementation
 *
 * @param path the ClusterPath to work with
 * @throws PersistencyException path was incorrect
 * @throws InvalidDataException Schema was not found or the Path has incorrect data
 */
protected void setMetaDataFromPath(String path) throws PersistencyException, InvalidDataException {
    StringTokenizer tok = new StringTokenizer(path, "/");
    if (tok.countTokens() != 3 && !(tok.nextToken().equals(OUTCOME.getName())))
        throw new PersistencyException("Outcome() - Outcome path must have three components:" + path);
    String schemaName = tok.nextToken();
    String verString = tok.nextToken();
    String objId = tok.nextToken();
    try {
        Integer schemaVersion = Integer.valueOf(verString);
        mSchema = LocalObjectLoader.getSchema(schemaName, schemaVersion);
        mID = Integer.valueOf(objId);
    } catch (NumberFormatException ex) {
        throw new InvalidDataException("Outcome() - Version or EventID was an invalid number version:" + verString + " eventID:" + objId);
    } catch (ObjectNotFoundException e) {
        Logger.error(e);
        throw new InvalidDataException("Outcome() - problem loading schema:" + schemaName + " version:" + verString);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 49 with ObjectNotFoundException

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

the class QueryOutcomeInitiator method initOutcomeInstance.

@Override
public Outcome initOutcomeInstance(Job job) throws InvalidDataException {
    if (job.hasQuery()) {
        try {
            Outcome o = new Outcome(-1, job.getItemProxy().executeQuery(job.getQuery()), job.getSchema());
            o.validateAndCheck();
            return o;
        } catch (PersistencyException | ObjectNotFoundException | InvalidItemPathException e) {
            throw new InvalidDataException("Error executing Query:" + e.getMessage());
        }
    } else
        throw new InvalidDataException("No Query was defined for job:" + job);
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 50 with ObjectNotFoundException

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

the class Resource method getTextResource.

@Override
public String getTextResource(String ns, String resName) throws ObjectNotFoundException {
    Logger.msg(8, "Resource::getTextResource() - Getting resource from namespacce " + ns + ": " + resName);
    if (txtCache.containsKey(ns + '/' + resName)) {
        return txtCache.get(ns + '/' + resName);
    }
    try {
        String newRes = null;
        URL loc;
        if (// kernel
        ns == null)
            loc = getKernelResourceURL(resName);
        else
            loc = getModuleResourceURL(ns, resName);
        Logger.msg(5, "Loading resource: " + loc.toString());
        newRes = FileStringUtility.url2String(loc);
        txtCache.put(ns + '/' + resName, newRes);
        return newRes;
    } catch (Exception e) {
        Logger.error(e);
        throw new ObjectNotFoundException(e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

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