use of org.cristalise.kernel.common.PersistencyException 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.PersistencyException in project kernel by cristal-ise.
the class ActivityDef method getBuiltInCollectionResource.
protected DescriptionObject[] getBuiltInCollectionResource(BuiltInCollections collection) throws ObjectNotFoundException, InvalidDataException {
ArrayList<DescriptionObject> retArr = new ArrayList<DescriptionObject>();
if (itemPath == null) {
Logger.warning("ActivityDef.getBuiltInCollectionResource(actName:" + getName() + ", collection:" + collection + ") - itemPath is null! CANNOT resolve data in ClusterStorage");
return retArr.toArray(new DescriptionObject[0]);
// throw new InvalidDataException("actName:"+getName()+", collection:"+collection+" - itemPath is null! CANNOT resolve data in ClusterStorage");
}
Logger.msg(5, "ActivityDef.getBuiltInCollectionResource(actName:" + getName() + ") - Loading from collection:" + collection);
Dependency resColl;
try {
String clusterPath = ClusterType.COLLECTION + "/" + collection + "/" + ((mVersion == null || mVersion == -1) ? "last" : String.valueOf(mVersion));
String[] contents = Gateway.getStorage().getClusterContents(itemPath, clusterPath);
if (contents != null && contents.length > 0)
resColl = (Dependency) Gateway.getStorage().get(itemPath, clusterPath, null);
else
return retArr.toArray(new DescriptionObject[retArr.size()]);
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException("Error loading description collection " + collection);
}
for (DependencyMember resMem : resColl.getMembers().list) {
String resUUID = resMem.getChildUUID();
Integer resVer = deriveVersionNumber(resMem.getBuiltInProperty(VERSION));
if (resVer == null) {
throw new InvalidDataException("Version is null for Item:" + itemPath + ", Collection:" + collection + ", DependencyMember:" + resUUID);
}
if (collection != ACTIVITY && retArr.size() > 0) {
throw new InvalidDataException("actName:" + getName() + " has an invalid dependency:" + collection);
}
switch(collection) {
case SCHEMA:
retArr.add(LocalObjectLoader.getSchema(resUUID, resVer));
break;
case SCRIPT:
retArr.add(LocalObjectLoader.getScript(resUUID, resVer));
break;
case QUERY:
retArr.add(LocalObjectLoader.getQuery(resUUID, resVer));
break;
case STATE_MACHINE:
retArr.add(LocalObjectLoader.getStateMachine(resUUID, resVer));
break;
case ACTIVITY:
retArr.add(LocalObjectLoader.getActDef(resUUID, resVer));
break;
default:
throw new InvalidDataException("");
}
}
return retArr.toArray(new DescriptionObject[retArr.size()]);
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class ClusterStorageManager method getClusterContents.
/**
* Retrieves the ids of the next level of a cluster
* Does not look in any currently open transactions.
*
* @param itemPath the current Item
* @param path the cluster path
* @return list of keys found in the cluster
*/
public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException {
ArrayList<String> contents = new ArrayList<String>();
// get all readers
Logger.msg(8, "ClusterStorageManager.getClusterContents() - path:" + path);
ArrayList<ClusterStorage> readers = findStorages(ClusterStorage.getClusterType(path), false);
// try each in turn until we get a result
for (ClusterStorage thisReader : readers) {
try {
String[] thisArr = thisReader.getClusterContents(itemPath, path);
if (thisArr != null) {
for (int j = 0; j < thisArr.length; j++) if (!contents.contains(thisArr[j])) {
Logger.msg(9, "ClusterStorageManager.getClusterContents() - " + thisReader.getName() + " reports " + thisArr[j]);
contents.add(thisArr[j]);
}
}
} catch (PersistencyException e) {
Logger.msg(5, "ClusterStorageManager.getClusterContents() - reader " + thisReader.getName() + " could not retrieve contents of " + itemPath + "/" + path + ": " + e.getMessage());
}
}
Logger.msg(8, "ClusterStorageManager.getClusterContents() - Returning " + contents.size() + " elements of path:" + path);
String[] retArr = new String[0];
retArr = contents.toArray(retArr);
return retArr;
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class ClusterStorageManager method get.
/**
* Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache.
* <br>
* There is a special case for Viewpoint. When path ends with /data it returns referenced Outcome instead of Viewpoint.
*
* @param itemPath current Iten
* @param path the cluster path
* @return the C2KObject located by path
*/
public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException, ObjectNotFoundException {
// check cache first
Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
if (sysKeyMemCache != null) {
synchronized (sysKeyMemCache) {
C2KLocalObject obj = sysKeyMemCache.get(path);
if (obj != null) {
Logger.msg(7, "ClusterStorageManager.get() - found " + itemPath + "/" + path + " in memcache");
return obj;
}
}
}
// special case for Viewpoint- When path ends with /data it returns referenced Outcome instead of Viewpoint
if (path.startsWith(VIEWPOINT.getName()) && path.endsWith("/data")) {
StringTokenizer tok = new StringTokenizer(path, "/");
if (tok.countTokens() == 4) {
// to not catch viewpoints called 'data'
Viewpoint view = (Viewpoint) get(itemPath, path.substring(0, path.lastIndexOf("/")));
if (view != null)
return view.getOutcome();
else
return null;
}
}
C2KLocalObject result = null;
// deal out top level remote maps
if (path.indexOf('/') == -1) {
if (path.equals(HISTORY.getName())) {
result = new History(itemPath, null);
} else if (path.equals(JOB.getName())) {
if (itemPath instanceof AgentPath)
result = new JobList((AgentPath) itemPath, null);
else
throw new ObjectNotFoundException("Items do not have job lists");
}
}
if (result == null) {
// else try each reader in turn until we find it
ArrayList<ClusterStorage> readers = findStorages(ClusterStorage.getClusterType(path), false);
for (ClusterStorage thisReader : readers) {
try {
result = thisReader.get(itemPath, path);
Logger.msg(7, "ClusterStorageManager.get() - reading " + path + " from " + thisReader.getName() + " for item " + itemPath);
// got it!
if (result != null)
break;
} catch (PersistencyException e) {
Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + itemPath + "/" + path + ": " + e.getMessage());
}
}
}
// No result was found after reading the list of ClusterStorages
if (result == null) {
throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath);
}
putInMemoryCache(itemPath, path, result);
return result;
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class DescriptionObjectCache method loadObject.
public D loadObject(String name, int version, ItemProxy proxy) throws ObjectNotFoundException, InvalidDataException {
Viewpoint smView = (Viewpoint) proxy.getObject(ClusterType.VIEWPOINT + "/" + getSchemaName() + "/" + version);
String rawRes;
try {
rawRes = smView.getOutcome().getData();
} catch (PersistencyException ex) {
Logger.error(ex);
throw new ObjectNotFoundException("Problem loading " + getSchemaName() + " " + name + " v" + version + ": " + ex.getMessage());
}
return buildObject(name, version, proxy.getPath(), rawRes);
}
Aggregations