Search in sources :

Example 6 with ObjectNotFoundException

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

the class ActivityDef method configureInstance.

/**
 */
@Override
public void configureInstance(WfVertex act) throws InvalidDataException, ObjectNotFoundException {
    super.configureInstance(act);
    try {
        for (String collName : Gateway.getStorage().getClusterContents(itemPath, ClusterType.COLLECTION)) {
            Logger.msg(5, "ActivityDef.configureInstance(" + getName() + ") - Processing collection:" + collName);
            String verStr = (mVersion == null || mVersion == -1) ? "last" : String.valueOf(mVersion);
            Dependency dep = null;
            try {
                dep = (Dependency) Gateway.getStorage().get(itemPath, ClusterType.COLLECTION + "/" + collName + "/" + verStr, null);
            } catch (ObjectNotFoundException e) {
                if (Logger.doLog(8))
                    Logger.warning("Unavailable Collection path:" + itemPath + "/" + ClusterType.COLLECTION + "/" + collName + "/" + verStr);
            } catch (PersistencyException e) {
                Logger.error(e);
                throw new InvalidDataException("Collection:" + collName + " error:" + e.getMessage());
            }
            if (dep != null)
                dep.addToVertexProperties(act.getProperties());
        }
    } catch (PersistencyException e) {
        Logger.error(e);
        throw new InvalidDataException(e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) Dependency(org.cristalise.kernel.collection.Dependency)

Example 7 with ObjectNotFoundException

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

the class ActivityDef method export.

@Override
public void export(Writer imports, File dir) throws InvalidDataException, ObjectNotFoundException, IOException {
    String actXML;
    String tc = ELEM_ACT_DESC_RESOURCE.getTypeCode();
    exportCollections(imports, dir);
    try {
        actXML = Gateway.getMarshaller().marshall(this);
    } catch (Exception e) {
        Logger.error(e);
        throw new InvalidDataException("Couldn't marshall activity def " + getActName());
    }
    FileStringUtility.string2File(new File(new File(dir, tc), getActName() + (getVersion() == null ? "" : "_" + getVersion()) + ".xml"), actXML);
    if (imports != null) {
        imports.write("<Activity " + getExportAttributes(tc) + ">" + getExportCollections() + "</Activity>\n");
    }
}
Also used : 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) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 8 with ObjectNotFoundException

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

the class TransferItem method exportItem.

public void exportItem(File dir, String path) throws Exception {
    Logger.msg("Path " + path + " in " + itemPath);
    String[] contents = Gateway.getStorage().getClusterContents(itemPath, path);
    if (contents.length > 0) {
        FileStringUtility.createNewDir(dir.getCanonicalPath());
        for (String content : contents) {
            exportItem(new File(dir, content), path + "/" + content);
        }
    } else {
        // no children, try to dump object
        try {
            C2KLocalObject obj = Gateway.getStorage().get(itemPath, path, null);
            Logger.msg("Dumping object " + path + " in " + itemPath);
            File dumpPath = new File(dir.getCanonicalPath() + ".xml");
            FileStringUtility.string2File(dumpPath, Gateway.getMarshaller().marshall(obj));
            return;
        }// not an object
         catch (ObjectNotFoundException ex) {
        }
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) File(java.io.File)

Example 9 with ObjectNotFoundException

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

the class Bootstrap method verifyPathAndModuleProperty.

/**
 * Verify module property and location
 *
 * @param ns
 * @param itemType
 * @param itemName
 * @param itemPath
 * @param modDomPath
 * @param path
 * @return the ItemProxy either create or initialised for existing
 * @throws Exception
 */
private static ItemProxy verifyPathAndModuleProperty(String ns, String itemType, String itemName, ItemPath itemPath, DomainPath modDomPath, DomainPath path) throws Exception {
    LookupManager lookupManager = Gateway.getLookupManager();
    ItemProxy thisProxy = Gateway.getProxyManager().getProxy(path);
    if (itemPath != null && !path.getItemPath().equals(itemPath)) {
        Logger.warning("Resource " + itemType + "/" + itemName + " should have path " + itemPath + " but was found with path " + path.getItemPath());
        itemPath = path.getItemPath();
    }
    if (itemPath == null)
        itemPath = path.getItemPath();
    String moduleName = (ns == null ? "kernel" : ns);
    String itemModule;
    try {
        itemModule = thisProxy.getProperty("Module");
        if (itemModule != null && !itemModule.equals("") && !itemModule.equals("null") && !moduleName.equals(itemModule)) {
            String error = "Module clash! Resource '" + itemName + "' included in module " + moduleName + " but is assigned to '" + itemModule + "'.";
            Logger.error(error);
            throw new InvalidDataException(error);
        }
    } catch (ObjectNotFoundException ex) {
        itemModule = "";
    }
    if (!modDomPath.equals(path)) {
        // move item to module subtree
        Logger.msg("Module item " + itemName + " found with path " + path.toString() + ". Moving to " + modDomPath.toString());
        modDomPath.setItemPath(itemPath);
        if (!modDomPath.exists())
            lookupManager.add(modDomPath);
        lookupManager.delete(path);
    }
    return thisProxy;
}
Also used : ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 10 with ObjectNotFoundException

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

the class Bootstrap method createResourceItem.

/**
 * @param impHandler
 * @param itemName
 * @param ns
 * @param itemPath
 * @return the ItemProxy representing the newly create Item
 * @throws Exception
 */
private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns, ItemPath itemPath) throws Exception {
    // create props
    PropertyDescriptionList pdList = impHandler.getPropDesc();
    PropertyArrayList props = new PropertyArrayList();
    LookupManager lookupManager = Gateway.getLookupManager();
    for (int i = 0; i < pdList.list.size(); i++) {
        PropertyDescription pd = pdList.list.get(i);
        String propName = pd.getName();
        String propVal = pd.getDefaultValue();
        if (propName.equals(NAME.toString()))
            propVal = itemName;
        else if (propName.equals(MODULE.toString()))
            propVal = (ns == null) ? "kernel" : ns;
        props.list.add(new Property(propName, propVal, pd.getIsMutable()));
    }
    CompositeActivity ca = new CompositeActivity();
    try {
        ca = (CompositeActivity) ((CompositeActivityDef) LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate();
    } catch (ObjectNotFoundException ex) {
        Logger.error(ex);
        Logger.error("Module resource workflow " + impHandler.getWorkflowName() + " not found. Using empty.");
    }
    Gateway.getCorbaServer().createItem(itemPath);
    lookupManager.add(itemPath);
    DomainPath newDomPath = impHandler.getPath(itemName, ns);
    newDomPath.setItemPath(itemPath);
    lookupManager.add(newDomPath);
    ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(itemPath);
    newItemProxy.initialise(systemAgents.get("system").getPath(), props, ca, null);
    return newItemProxy;
}
Also used : PropertyDescription(org.cristalise.kernel.property.PropertyDescription) DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) Property(org.cristalise.kernel.property.Property) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint)

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