Search in sources :

Example 56 with ObjectNotFoundException

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

the class ModuleManager method registerModules.

public void registerModules() throws ModuleException {
    ItemProxy serverItem;
    try {
        serverItem = Gateway.getProxyManager().getProxy(new DomainPath("/servers/" + Gateway.getProperties().getString("ItemServer.name")));
    } catch (ObjectNotFoundException e) {
        throw new ModuleException("Cannot find local server name.");
    }
    Logger.msg(3, "ModuleManager.registerModules() - Registering modules");
    boolean reset = Gateway.getProperties().getBoolean("Module.reset", false);
    for (Module thisMod : modules) {
        if (Bootstrap.shutdown)
            return;
        Logger.msg("ModuleManager.registerModules() - Registering module " + thisMod.getName());
        try {
            String thisResetKey = "Module." + thisMod.getNamespace() + ".reset";
            boolean thisReset = reset;
            if (Gateway.getProperties().containsKey(thisResetKey)) {
                thisReset = Gateway.getProperties().getBoolean(thisResetKey);
            }
            thisMod.setModuleXML(modulesXML.get(thisMod.getNamespace()));
            thisMod.importAll(serverItem, agent, thisReset);
        } catch (Exception e) {
            Logger.error(e);
            throw new ModuleException("Error importing items for module " + thisMod.getName());
        }
        Logger.msg("ModuleManager.registerModules() - Module " + thisMod.getName() + " registered");
        try {
            thisMod.runScript("startup", agent, true);
        } catch (ScriptingEngineException e) {
            Logger.error(e);
            throw new ModuleException("Error in startup script for module " + thisMod.getName());
        }
    }
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) ScriptingEngineException(org.cristalise.kernel.scripting.ScriptingEngineException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ScriptingEngineException(org.cristalise.kernel.scripting.ScriptingEngineException)

Example 57 with ObjectNotFoundException

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

the class ActDefCache method loadObject.

@Override
public ActivityDef loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFoundException, InvalidDataException {
    String viewName;
    if (isComposite == null) {
        String prop = proxy.getProperty(COMPLEXITY);
        if ("Composite".equals(prop))
            viewName = COMP_ACT_DESC_RESOURCE.getSchemaName();
        else if ("Elementary".equals(prop))
            viewName = ELEM_ACT_DESC_RESOURCE.getSchemaName();
        else
            throw new InvalidDataException("Missing Item property:" + COMPLEXITY);
    } else {
        viewName = isComposite ? COMP_ACT_DESC_RESOURCE.getSchemaName() : ELEM_ACT_DESC_RESOURCE.getSchemaName();
    }
    try {
        Viewpoint actView = (Viewpoint) proxy.getObject(ClusterType.VIEWPOINT + "/" + viewName + "/" + version);
        String marshalledAct = actView.getOutcome().getData();
        return buildObject(name, version, proxy.getPath(), marshalledAct);
    } catch (PersistencyException ex) {
        Logger.error(ex);
        throw new ObjectNotFoundException("Problem loading Activity " + name + " v" + version + ": " + ex.getMessage());
    }
}
Also used : Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 58 with ObjectNotFoundException

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

the class DescriptionObjectCache method findItem.

public ItemPath findItem(String name) throws ObjectNotFoundException, InvalidDataException {
    if (Gateway.getLookup() == null)
        throw new ObjectNotFoundException("Cannot find Items without a Lookup");
    // first check for a UUID name
    try {
        ItemPath resItem = new ItemPath(name);
        if (resItem.exists())
            return resItem;
    } catch (InvalidItemPathException ex) {
    }
    // then check for a direct path
    DomainPath directPath = new DomainPath(name);
    if (directPath.exists() && directPath.getItemPath() != null) {
        return directPath.getItemPath();
    }
    // else search for it in the whole tree using property description
    Property[] searchProps = new Property[classIdProps.length + 1];
    searchProps[0] = new Property(NAME, name);
    System.arraycopy(classIdProps, 0, searchProps, 1, classIdProps.length);
    Iterator<Path> e = Gateway.getLookup().search(new DomainPath(), searchProps);
    if (e.hasNext()) {
        Path defPath = e.next();
        if (e.hasNext())
            throw new ObjectNotFoundException("Too many matches for " + getTypeCode() + " " + name);
        if (defPath.getItemPath() == null)
            throw new InvalidDataException(getTypeCode() + " " + name + " was found, but was not an Item");
        return defPath.getItemPath();
    } else {
        throw new ObjectNotFoundException("No match for " + getTypeCode() + " " + name);
    }
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemPath(org.cristalise.kernel.lookup.ItemPath) Path(org.cristalise.kernel.lookup.Path) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Property(org.cristalise.kernel.property.Property) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 59 with ObjectNotFoundException

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

the class DescriptionObjectCache method loadObjectFromBootstrap.

public D loadObjectFromBootstrap(String name) throws InvalidDataException, ObjectNotFoundException {
    Logger.msg(3, "DescriptionObjectCache.loadObjectFromBootstrap() - name:" + name);
    try {
        String bootItems = FileStringUtility.url2String(Gateway.getResource().getKernelResourceURL("boot/allbootitems.txt"));
        StringTokenizer str = new StringTokenizer(bootItems, "\n\r");
        while (str.hasMoreTokens()) {
            String resLine = str.nextToken();
            String[] resElem = resLine.split(",");
            if (resElem[0].equals(name) || isBootResource(resElem[1], name)) {
                Logger.msg(3, "DescriptionObjectCache.loadObjectFromBootstrap() - Shimming " + getTypeCode() + " " + name + " from bootstrap");
                String resData = Gateway.getResource().getTextResource(null, "boot/" + resElem[1] + (resElem[1].startsWith("OD") ? ".xsd" : ".xml"));
                return buildObject(name, 0, new ItemPath(resElem[0]), resData);
            }
        }
    } catch (Exception e) {
        Logger.error(e);
        throw new InvalidDataException("Error finding bootstrap resources");
    }
    throw new ObjectNotFoundException("Resource " + getSchemaName() + " " + name + " not found in bootstrap resources");
}
Also used : StringTokenizer(java.util.StringTokenizer) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

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