Search in sources :

Example 86 with InvalidDataException

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

the class ModuleActivity method create.

@Override
public Path create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException, InvalidDataException {
    try {
        domainPath = Bootstrap.verifyResource(ns, name, version, type.getTypeCode(), itemPath, getResourceLocation(), reset);
        itemPath = domainPath.getItemPath();
    } catch (Exception e) {
        Logger.error(e);
        throw new CannotManageException("Exception verifying module resource " + ns + "/" + name);
    }
    actDef = LocalObjectLoader.getActDef(name, version);
    populateActivityDef();
    CollectionArrayList colls;
    try {
        colls = actDef.makeDescCollections();
    } catch (InvalidDataException e) {
        Logger.error(e);
        throw new CannotManageException("Could not create description collections for " + getName() + ".");
    }
    for (Collection<?> coll : colls.list) {
        try {
            Gateway.getStorage().put(itemPath, coll, null);
            // create last collection
            coll.setVersion(null);
            Gateway.getStorage().put(itemPath, coll, null);
        } catch (PersistencyException e) {
            Logger.error(e);
            throw new CannotManageException("Persistency exception storing description collections for " + getName() + ".");
        }
    }
    return domainPath;
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException)

Example 87 with InvalidDataException

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

the class Script method makeDescCollections.

/**
 */
@Override
public CollectionArrayList makeDescCollections() throws InvalidDataException, ObjectNotFoundException {
    CollectionArrayList retArr = new CollectionArrayList();
    Dependency includeColl = new Dependency(INCLUDE);
    for (Script script : mIncludes) {
        try {
            includeColl.addMember(script.getItemPath());
        } catch (InvalidCollectionModification e) {
            throw new InvalidDataException("Could not add " + script.getName() + " to description collection. " + e.getMessage());
        } catch (ObjectAlreadyExistsException e) {
            throw new InvalidDataException("Script " + script.getName() + " included more than once.");
        }
    // 
    }
    retArr.put(includeColl);
    return retArr;
}
Also used : CompiledScript(javax.script.CompiledScript) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) Dependency(org.cristalise.kernel.collection.Dependency) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException)

Example 88 with InvalidDataException

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

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

use of org.cristalise.kernel.common.InvalidDataException 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

InvalidDataException (org.cristalise.kernel.common.InvalidDataException)91 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)40 PersistencyException (org.cristalise.kernel.common.PersistencyException)33 IOException (java.io.IOException)14 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)11 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)11 DomainPath (org.cristalise.kernel.lookup.DomainPath)10 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)9 CannotManageException (org.cristalise.kernel.common.CannotManageException)8 AgentPath (org.cristalise.kernel.lookup.AgentPath)8 Schema (org.cristalise.kernel.persistency.outcome.Schema)8 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)7 ItemPath (org.cristalise.kernel.lookup.ItemPath)7 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)6 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)6 MappingException (org.exolab.castor.mapping.MappingException)6 MarshalException (org.exolab.castor.xml.MarshalException)6 ValidationException (org.exolab.castor.xml.ValidationException)6 ArrayList (java.util.ArrayList)5 XPathExpressionException (javax.xml.xpath.XPathExpressionException)5