use of org.cristalise.kernel.entity.Item in project kernel by cristal-ise.
the class ProxyLoader method get.
/**
* retrieve object by path
*/
@Override
public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException {
try {
Item thisEntity = getIOR(thisItem);
ClusterType type = getClusterType(path);
// fetch the xml from the item
String queryData = thisEntity.queryData(path);
if (Logger.doLog(8))
Logger.msg("ProxyLoader.get() - " + thisItem + " : " + path + " = " + queryData);
if (queryData != null) {
if (type == ClusterType.OUTCOME)
return new Outcome(path, queryData);
else
return (C2KLocalObject) Gateway.getMarshaller().unmarshall(queryData);
}
} catch (ObjectNotFoundException e) {
return null;
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
return null;
}
use of org.cristalise.kernel.entity.Item in project kernel by cristal-ise.
the class ProxyLoader method getClusterContents.
/**
* Directory listing
*/
@Override
public String[] getClusterContents(ItemPath thisItem, String path) throws PersistencyException {
try {
Item thisEntity = getIOR(thisItem);
String contents = thisEntity.queryData(path + "/all");
StringTokenizer tok = new StringTokenizer(contents, ",");
String[] result = new String[tok.countTokens()];
for (int i = 0; i < result.length; i++) result[i] = tok.nextToken();
return result;
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
}
use of org.cristalise.kernel.entity.Item 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