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