use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class XMLClusterStorage method get.
@Override
public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException {
try {
ClusterType type = ClusterStorage.getClusterType(path);
String filePath = getFilePath(itemPath, path) + fileExtension;
String objString = FileStringUtility.file2String(filePath);
if (objString.length() == 0)
return null;
Logger.debug(9, "XMLClusterStorage.get() - objString:" + objString);
if (type == ClusterType.OUTCOME)
return new Outcome(path, objString);
else
return (C2KLocalObject) Gateway.getMarshaller().unmarshall(objString);
} catch (Exception e) {
Logger.msg(3, "XMLClusterStorage.get() - The path " + path + " from " + itemPath + " does not exist: " + e.getMessage());
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class XMLClusterStorage method put.
@Override
public void put(ItemPath itemPath, C2KLocalObject obj) throws PersistencyException {
try {
String filePath = getFilePath(itemPath, getPath(obj) + fileExtension);
Logger.msg(7, "XMLClusterStorage.put() - Writing " + filePath);
String data = Gateway.getMarshaller().marshall(obj);
String dir = filePath.substring(0, filePath.lastIndexOf('/'));
if (!FileStringUtility.checkDir(dir)) {
boolean success = FileStringUtility.createNewDir(dir);
if (!success)
throw new PersistencyException("XMLClusterStorage.put() - Could not create dir " + dir + ". Cannot continue.");
}
FileStringUtility.string2File(filePath, data);
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException("XMLClusterStorage.put() - Could not write " + getPath(obj) + " to " + itemPath);
}
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class ProxyLoader method getIOR.
private Item getIOR(ItemPath thisPath) throws PersistencyException {
// check the cache
if (entities.containsKey(thisPath)) {
Logger.msg(8, "ProxyLoader.getIOR() - " + thisPath + " cached.");
return entities.get(thisPath);
}
try {
Logger.msg(8, "ProxyLoader.getIOR() - Resolving " + thisPath + ".");
org.omg.CORBA.Object ior = thisPath.getIOR();
Item thisItem = null;
try {
thisItem = ItemHelper.narrow(ior);
} catch (org.omg.CORBA.BAD_PARAM ex) {
try {
thisItem = AgentHelper.narrow(ior);
} catch (org.omg.CORBA.BAD_PARAM ex2) {
throw new PersistencyException("Could not narrow " + thisItem + " as a known Entity type");
}
}
Logger.msg(8, "ProxyLoader.getIOR() - Found " + thisItem + ".");
entities.put(thisPath, thisItem);
return thisItem;
} catch (Exception e) {
throw new PersistencyException("Error narrowing " + thisPath + ": " + e.getMessage());
}
}
Aggregations