use of org.cristalise.kernel.entity.C2KLocalObject in project kernel by cristal-ise.
the class BulkImport method importCollection.
public void importCollection(ItemPath item, Object locker) throws PersistencyException {
String[] names = importCluster.getClusterContents(item, COLLECTION);
for (String name : names) {
String[] versions = importCluster.getClusterContents(item, COLLECTION + "/" + name);
for (String version : versions) {
C2KLocalObject coll = importCluster.get(item, COLLECTION + "/" + name + "/" + version);
Gateway.getStorage().put(item, coll, locker);
// importCluster.delete(item, path.toString());
}
}
}
use of org.cristalise.kernel.entity.C2KLocalObject in project kernel by cristal-ise.
the class BulkImport method importProperty.
public void importProperty(ItemPath item, Object locker) throws PersistencyException {
String[] contents = importCluster.getClusterContents(item, PROPERTY);
for (String c : contents) {
String path = PROPERTY + "/" + c;
C2KLocalObject prop = importCluster.get(item, path);
Gateway.getStorage().put(item, prop, locker);
// importCluster.delete(item, path);
}
}
use of org.cristalise.kernel.entity.C2KLocalObject in project kernel by cristal-ise.
the class BulkImport method importHistory.
public void importHistory(ItemPath item, Object locker) throws PersistencyException {
String[] contents = importCluster.getClusterContents(item, HISTORY);
for (String c : contents) {
String path = HISTORY + "/" + c;
C2KLocalObject obj = importCluster.get(item, path);
Gateway.getStorage().put(item, obj, locker);
// importCluster.delete(item, path);
}
}
use of org.cristalise.kernel.entity.C2KLocalObject in project kernel by cristal-ise.
the class ClusterStorageManager method dumpCacheContents.
public void dumpCacheContents(int logLevel) {
if (!Logger.doLog(logLevel))
return;
synchronized (memoryCache) {
for (ItemPath itemPath : memoryCache.keySet()) {
Logger.msg(logLevel, "Cached Objects of Item " + itemPath);
Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
try {
synchronized (sysKeyMemCache) {
for (Object name : sysKeyMemCache.keySet()) {
String path = (String) name;
try {
Logger.msg(logLevel, " Path " + path + ": " + sysKeyMemCache.get(path).getClass().getName());
} catch (NullPointerException e) {
Logger.msg(logLevel, " Path " + path + ": reaped");
}
}
}
} catch (ConcurrentModificationException ex) {
Logger.msg(logLevel, "Cache modified - aborting");
}
}
Logger.msg(logLevel, "Total number of cached entities: " + memoryCache.size());
}
}
use of org.cristalise.kernel.entity.C2KLocalObject in project kernel by cristal-ise.
the class AddNewSlot method runActivityLogic.
/**
* Creates a new slot in the given aggregation, that holds instances of the given item description
*
* Params:
* <ol>
* <li>Collection name</li>
* <li>Item Description key (optional)</li>
* <li>Item Description version (optional)</li>
* </ol>
*
* @throws InvalidDataException
* Then the parameters were incorrect
* @throws PersistencyException
* There was a problem loading or saving the collection from persistency
* @throws ObjectNotFoundException
* A required object, such as the collection or a PropertyDescription outcome, wasn't found
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, PersistencyException, ObjectNotFoundException {
String collName;
ItemPath descKey = null;
String descVer = "last";
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddNewSlot: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
// resolve desc item path and version
try {
collName = params[0];
if (params.length > 1 && params[1].length() > 0) {
try {
descKey = new ItemPath(params[1]);
} catch (InvalidItemPathException e) {
descKey = new DomainPath(params[1]).getItemPath();
}
}
if (params.length > 2 && params[2].length() > 0)
descVer = params[2];
} catch (Exception e) {
throw new InvalidDataException("AddNewSlot: Invalid parameters " + Arrays.toString(params));
}
// load collection
C2KLocalObject collObj = Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
if (!(collObj instanceof Aggregation))
throw new InvalidDataException("AddNewSlot operates on Aggregation only.");
Aggregation agg = (Aggregation) collObj;
// get props
CastorHashMap props = new CastorHashMap();
StringBuffer classProps = new StringBuffer();
if (descKey != null) {
PropertyDescriptionList propList;
propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer, locker);
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
}
}
agg.addSlot(props, classProps.toString());
Gateway.getStorage().put(item, agg, locker);
return requestData;
}
Aggregations