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