Search in sources :

Example 21 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException 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 22 with ObjectNotFoundException

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

the class CorbaServer method getItem.

/**
 * Returns a CORBA servant for a pre-existing entity
 *
 * @param itemPath the ItemPath representing the Item
 * @return the servant
 * @throws ObjectNotFoundException itemPath was not found
 */
public TraceableEntity getItem(ItemPath itemPath) throws ObjectNotFoundException {
    Servant item = null;
    if (!itemPath.exists())
        throw new ObjectNotFoundException(itemPath + " does not exist");
    synchronized (mItemCache) {
        item = mItemCache.get(itemPath);
        if (item == null) {
            Logger.msg(7, "Creating new servant for " + itemPath);
            item = new TraceableEntity(itemPath, mItemPOA);
            mItemCache.put(itemPath, item);
        }
    }
    return (TraceableEntity) item;
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Servant(org.omg.PortableServer.Servant)

Example 23 with ObjectNotFoundException

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

the class ItemImplementation method queryLifeCycle.

/**
 */
@Override
public String queryLifeCycle(SystemKey agentId, boolean filter) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
    Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - agent: " + agentId);
    try {
        AgentPath agent;
        try {
            agent = new AgentPath(agentId);
        } catch (InvalidItemPathException e) {
            throw new AccessRightsException("Agent " + agentId + " doesn't exist");
        }
        Workflow wf = (Workflow) mStorage.get(mItemPath, ClusterType.LIFECYCLE + "/workflow", null);
        JobArrayList jobBag = new JobArrayList();
        CompositeActivity domainWf = (CompositeActivity) wf.search("workflow/domain");
        jobBag.list = filter ? domainWf.calculateJobs(agent, mItemPath, true) : domainWf.calculateAllJobs(agent, mItemPath, true);
        Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - Returning " + jobBag.list.size() + " jobs.");
        try {
            return Gateway.getMarshaller().marshall(jobBag);
        } catch (Exception e) {
            Logger.error(e);
            throw new PersistencyException("Error marshalling job bag");
        }
    } catch (AccessRightsException | ObjectNotFoundException | PersistencyException e) {
        Logger.error(e);
        throw e;
    } catch (Throwable ex) {
        Logger.error("ItemImplementation::queryLifeCycle(" + mItemPath + ") - Unknown error");
        Logger.error(ex);
        throw new PersistencyException("Unknown error querying jobs. Please see server log.");
    }
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) AgentPath(org.cristalise.kernel.lookup.AgentPath) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Workflow(org.cristalise.kernel.lifecycle.instance.Workflow) 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) 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)

Example 24 with ObjectNotFoundException

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

the class TraceableLocator method preinvoke.

/**
 ************************************************************************
 *
 *************************************************************************
 */
@Override
public org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA poa, String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie) {
    ByteBuffer bb = ByteBuffer.wrap(oid);
    long msb = bb.getLong();
    long lsb = bb.getLong();
    ItemPath syskey = new ItemPath(new SystemKey(msb, lsb));
    Logger.msg(1, "===========================================================");
    Logger.msg(1, "Item called at " + new Timestamp(System.currentTimeMillis()) + ": " + operation + "(" + syskey + ").");
    try {
        return Gateway.getCorbaServer().getItem(syskey);
    } catch (ObjectNotFoundException ex) {
        Logger.error("ObjectNotFoundException::TraceableLocator::preinvoke() " + ex.toString());
        throw new org.omg.CORBA.OBJECT_NOT_EXIST();
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ByteBuffer(java.nio.ByteBuffer) Timestamp(java.sql.Timestamp) SystemKey(org.cristalise.kernel.common.SystemKey) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 25 with ObjectNotFoundException

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

the class ActiveLocator method preinvoke.

/**
 ************************************************************************
 *
 *************************************************************************
 */
@Override
public org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA poa, String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie) {
    try {
        ByteBuffer bb = ByteBuffer.wrap(oid);
        long msb = bb.getLong();
        long lsb = bb.getLong();
        AgentPath syskey = new AgentPath(new SystemKey(msb, lsb));
        Logger.msg(1, "===========================================================");
        Logger.msg(1, "Agent called at " + new Timestamp(System.currentTimeMillis()) + ": " + operation + "(" + syskey + ").");
        return Gateway.getCorbaServer().getAgent(syskey);
    } catch (ObjectNotFoundException ex) {
        Logger.error("ObjectNotFoundException::ActiveLocator::preinvoke() " + ex.toString());
        throw new org.omg.CORBA.OBJECT_NOT_EXIST();
    } catch (InvalidItemPathException ex) {
        Logger.error("InvalidItemPathException::ActiveLocator::preinvoke() " + ex.toString());
        throw new org.omg.CORBA.INV_OBJREF();
    }
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) AgentPath(org.cristalise.kernel.lookup.AgentPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ByteBuffer(java.nio.ByteBuffer) Timestamp(java.sql.Timestamp) SystemKey(org.cristalise.kernel.common.SystemKey)

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