Search in sources :

Example 16 with C2KLocalObject

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());
        }
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject)

Example 17 with C2KLocalObject

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);
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject)

Example 18 with C2KLocalObject

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);
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject)

Example 19 with C2KLocalObject

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());
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 20 with C2KLocalObject

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;
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Aggregation(org.cristalise.kernel.collection.Aggregation) PropertyDescription(org.cristalise.kernel.property.PropertyDescription) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) CastorHashMap(org.cristalise.kernel.utils.CastorHashMap) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)20 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)7 PersistencyException (org.cristalise.kernel.common.PersistencyException)6 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)5 DomainPath (org.cristalise.kernel.lookup.DomainPath)4 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)4 ItemPath (org.cristalise.kernel.lookup.ItemPath)4 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 Aggregation (org.cristalise.kernel.collection.Aggregation)2 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)2 Job (org.cristalise.kernel.entity.agent.Job)2 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 AggregationMember (org.cristalise.kernel.collection.AggregationMember)1 Collection (org.cristalise.kernel.collection.Collection)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1