Search in sources :

Example 1 with ObjectNotFoundException

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

the class ItemImplementation method queryData.

/**
 */
@Override
public String queryData(String path) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
    String result = "";
    Logger.msg(1, "ItemImplementation::queryData(" + mItemPath + ") - " + path);
    try {
        // check for cluster contents query
        if (path.endsWith("/all")) {
            int allPos = path.lastIndexOf("all");
            String query = path.substring(0, allPos);
            String[] ids = mStorage.getClusterContents(mItemPath, query);
            for (int i = 0; i < ids.length; i++) {
                result += ids[i];
                if (i != ids.length - 1)
                    result += ",";
            }
        } else // ****************************************************************
        {
            // retrieve the object instead marshall it, or in the case of an outcome get the data.
            result = Gateway.getMarshaller().marshall(mStorage.get(mItemPath, path, null));
        }
    } catch (ObjectNotFoundException ex) {
        throw ex;
    } catch (Throwable ex) {
        Logger.warning("ItemImplementation::queryData(" + mItemPath + ") - " + path + " Failed: " + ex.getClass().getName());
        throw new PersistencyException("Server exception: " + ex.getClass().getName());
    }
    if (Logger.doLog(9))
        Logger.msg(9, "ItemImplementation::queryData(" + mItemPath + ") - result:" + result);
    return result;
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint)

Example 2 with ObjectNotFoundException

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

the class ItemImplementation method delegatedAction.

@Override
public String delegatedAction(SystemKey agentId, SystemKey delegateId, String stepPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, ObjectNotFoundException, InvalidDataException, PersistencyException, ObjectAlreadyExistsException, InvalidCollectionModification {
    Workflow lifeCycle = null;
    try {
        AgentPath agent = new AgentPath(agentId);
        AgentPath delegate = delegateId == null ? null : new AgentPath(delegateId);
        Logger.msg(1, "ItemImplementation::request(" + mItemPath + ") - Transition " + transitionID + " on " + stepPath + " by " + (delegate == null ? "" : delegate + " on behalf of ") + agent);
        // TODO: check if delegate is allowed valid for agent
        lifeCycle = (Workflow) mStorage.get(mItemPath, ClusterType.LIFECYCLE + "/workflow", null);
        String finalOutcome = lifeCycle.requestAction(agent, delegate, stepPath, mItemPath, transitionID, requestData);
        // store the workflow if we've changed the state of the domain wf
        if (!(stepPath.startsWith("workflow/predefined")))
            mStorage.put(mItemPath, lifeCycle, lifeCycle);
        // remove entity path if transaction was successful
        if (stepPath.equals("workflow/predefined/Erase")) {
            Logger.msg("Erasing item path " + mItemPath.toString());
            Gateway.getLookupManager().delete(mItemPath);
        }
        mStorage.commit(lifeCycle);
        return finalOutcome;
    } catch (AccessRightsException | InvalidTransitionException | ObjectNotFoundException | PersistencyException | InvalidDataException | ObjectAlreadyExistsException | InvalidCollectionModification ex) {
        if (Logger.doLog(8))
            Logger.error(ex);
        String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
        if (StringUtils.isBlank(errorOutcome)) {
            mStorage.abort(lifeCycle);
            throw ex;
        } else {
            mStorage.commit(lifeCycle);
            return errorOutcome;
        }
    } catch (InvalidAgentPathException | ObjectCannotBeUpdated | CannotManageException ex) {
        if (Logger.doLog(8))
            Logger.error(ex);
        String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
        if (StringUtils.isBlank(errorOutcome)) {
            mStorage.abort(lifeCycle);
            throw new InvalidDataException(ex.getClass().getName() + " - " + ex.getMessage());
        } else {
            mStorage.commit(lifeCycle);
            return errorOutcome;
        }
    } catch (Exception ex) {
        // non-CORBA exception hasn't been caught!
        Logger.error("Unknown Error: requestAction on " + mItemPath + " by " + agentId + " executing " + stepPath);
        Logger.error(ex);
        String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
        if (StringUtils.isBlank(errorOutcome)) {
            mStorage.abort(lifeCycle);
            throw new InvalidDataException("Extraordinary Exception during execution:" + ex.getClass().getName() + " - " + ex.getMessage());
        } else {
            mStorage.commit(lifeCycle);
            return errorOutcome;
        }
    }
}
Also used : InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) CannotManageException(org.cristalise.kernel.common.CannotManageException) AgentPath(org.cristalise.kernel.lookup.AgentPath) Workflow(org.cristalise.kernel.lifecycle.instance.Workflow) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) MappingException(org.exolab.castor.mapping.MappingException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ValidationException(org.exolab.castor.xml.ValidationException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) MarshalException(org.exolab.castor.xml.MarshalException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectCannotBeUpdated(org.cristalise.kernel.common.ObjectCannotBeUpdated) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException)

Example 3 with ObjectNotFoundException

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

the class Job method setActPropsAndEvaluateValues.

/**
 * @param act
 * @throws InvalidDataException
 */
private void setActPropsAndEvaluateValues(Activity act) throws InvalidDataException {
    setActProps(act.getProperties());
    List<String> errors = new ArrayList<String>();
    for (Map.Entry<String, Object> entry : act.getProperties().entrySet()) {
        try {
            Object newVal = act.evaluatePropertyValue(null, entry.getValue(), null);
            if (newVal != null)
                actProps.put(entry.getKey(), newVal);
        } catch (InvalidDataException | PersistencyException | ObjectNotFoundException e) {
            Logger.error(e);
            errors.add(e.getMessage());
        }
    }
    if (errors.size() != 0) {
        StringBuffer buffer = new StringBuffer();
        for (String msg : errors) buffer.append(msg);
        throw new InvalidDataException(buffer.toString());
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ArrayList(java.util.ArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) HashMap(java.util.HashMap) Map(java.util.Map) CastorHashMap(org.cristalise.kernel.utils.CastorHashMap)

Example 4 with ObjectNotFoundException

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

the class AgentProxy method searchItem.

/**
 * Let scripts resolve items
 */
public ItemProxy searchItem(Path root, String name) throws ObjectNotFoundException {
    Iterator<Path> results = Gateway.getLookup().search(root, name);
    Path returnPath = null;
    if (!results.hasNext()) {
        throw new ObjectNotFoundException(name);
    } else {
        while (results.hasNext()) {
            Path nextMatch = results.next();
            if (returnPath != null) {
                // found already one but search if there are another, which is an error
                if (isItemPathAndNotNull(nextMatch)) {
                    // test if another itemPath with same name
                    if (!returnPath.getItemPath().getUUID().equals(nextMatch.getItemPath().getUUID())) {
                        throw new ObjectNotFoundException("Too many different items with name:" + name);
                    } else {
                        returnPath = nextMatch;
                    }
                }
            } else {
                if (isItemPathAndNotNull(nextMatch)) {
                    returnPath = nextMatch;
                    // found one but continue search
                    Logger.msg(5, "AgentProxy.searchItem() - found for " + name + " UUID = " + returnPath.getItemPath().getUUID());
                }
            }
        }
    }
    // test if nothing found in the results
    if (returnPath == null) {
        throw new ObjectNotFoundException(name);
    }
    return Gateway.getProxyManager().getProxy(returnPath);
}
Also used : ItemPath(org.cristalise.kernel.lookup.ItemPath) RolePath(org.cristalise.kernel.lookup.RolePath) DomainPath(org.cristalise.kernel.lookup.DomainPath) AgentPath(org.cristalise.kernel.lookup.AgentPath) Path(org.cristalise.kernel.lookup.Path) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 5 with ObjectNotFoundException

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

the class ItemProxy method getJobList.

/**
 * @param agentPath
 * @param filter
 * @return
 * @throws AccessRightsException
 * @throws ObjectNotFoundException
 * @throws PersistencyException
 */
private ArrayList<Job> getJobList(AgentPath agentPath, boolean filter) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
    JobArrayList thisJobList;
    String jobs = getItem().queryLifeCycle(agentPath.getSystemKey(), filter);
    try {
        thisJobList = (JobArrayList) Gateway.getMarshaller().unmarshall(jobs);
    } catch (Exception e) {
        Logger.error(e);
        throw new PersistencyException("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs");
    }
    return thisJobList.list;
}
Also used : PersistencyException(org.cristalise.kernel.common.PersistencyException) JobArrayList(org.cristalise.kernel.entity.agent.JobArrayList) MappingException(org.exolab.castor.mapping.MappingException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ValidationException(org.exolab.castor.xml.ValidationException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) MarshalException(org.exolab.castor.xml.MarshalException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

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