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;
}
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;
}
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());
}
}
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);
}
}
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");
}
Aggregations