Search in sources :

Example 11 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class LookupPathClusterStorageTest method storeDomainPath.

@Test
public void storeDomainPath() throws Exception {
    DomainPath domain = new DomainPath("/my/path.2", new ItemPath());
    inMemoryCluster.put(storingItem, domain);
    String name = StringUtils.remove(StringUtils.join(domain.getPath(), ""), ".");
    DomainPath domainPrime = (DomainPath) inMemoryCluster.get(storingItem, PATH + "/Domain/" + name);
    assertNotNull(domainPrime);
    assertEquals(domain.getStringPath(), domainPrime.getStringPath());
    assertEquals(domain.getTargetUUID(), domainPrime.getTargetUUID());
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemPath(org.cristalise.kernel.lookup.ItemPath) Test(org.junit.Test)

Example 12 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class DescriptionObjectCache method get.

public D get(String name, int version) throws ObjectNotFoundException, InvalidDataException {
    D thisDef = null;
    synchronized (cache) {
        CacheEntry<D> thisDefEntry = cache.get(name + "_" + version);
        if (thisDefEntry == null) {
            Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " not found in cache. Checking id.");
            try {
                ItemPath defItemPath = findItem(name);
                String defId = defItemPath.getUUID().toString();
                thisDefEntry = cache.get(defId + "_" + version);
                if (thisDefEntry == null) {
                    Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " not found in cache. Loading from database.");
                    ItemProxy defItemProxy = Gateway.getProxyManager().getProxy(defItemPath);
                    if (name.equals(defId)) {
                        String itemName = defItemProxy.getName();
                        if (itemName != null)
                            name = itemName;
                    }
                    thisDef = loadObject(name, version, defItemProxy);
                    cache.put(defId + "_" + version, new CacheEntry<D>(thisDef, defItemProxy, this));
                }
            } catch (ObjectNotFoundException ex) {
                // for bootstrap and testing, try to load built-in kernel objects from resources
                if (version == 0) {
                    try {
                        return loadObjectFromBootstrap(name);
                    } catch (ObjectNotFoundException ex2) {
                    }
                }
                throw ex;
            }
        }
        if (thisDefEntry != null && thisDef == null) {
            Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " found in cache.");
            thisDef = thisDefEntry.def;
        }
    }
    return thisDef;
}
Also used : ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 13 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class CreateItemFromDescription method runActivityLogic.

/**
 * Params:
 * <ol>
 * <li>Item name</li>
 * <li>Domain context</li>
 * <li>Description version to use(optional)</li>
 * <li>Initial properties to set in the new Agent (optional)</li>
 * </ol>
 * @throws ObjectNotFoundException
 * @throws InvalidDataException The input parameters were incorrect
 * @throws ObjectAlreadyExistsException The Agent already exists
 * @throws CannotManageException The Agent could not be created
 * @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed
 * @throws PersistencyException
 */
@Override
protected String runActivityLogic(AgentPath agent, ItemPath descItemPath, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
    String[] input = getDataList(requestData);
    String newName = input[0];
    String domPath = input[1];
    String descVer = input.length > 2 ? input[2] : "last";
    PropertyArrayList initProps = input.length > 3 ? unmarshallInitProperties(input[3]) : new PropertyArrayList();
    Logger.msg(1, "CreateItemFromDescription - name:" + newName);
    // check if the path is already taken
    DomainPath context = new DomainPath(new DomainPath(domPath), newName);
    if (context.exists())
        throw new ObjectAlreadyExistsException("The path " + context + " exists already.");
    // generate new item path with random uuid
    Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
    ItemPath newItemPath = new ItemPath();
    // create the Item object
    Logger.msg(3, "CreateItemFromDescription - Creating Item");
    CorbaServer factory = Gateway.getCorbaServer();
    if (factory == null)
        throw new CannotManageException("This process cannot create new Items");
    TraceableEntity newItem = factory.createItem(newItemPath);
    Gateway.getLookupManager().add(newItemPath);
    initialiseItem(newItem, agent, descItemPath, initProps, newName, descVer, context, newItemPath, locker);
    return requestData;
}
Also used : TraceableEntity(org.cristalise.kernel.entity.TraceableEntity) DomainPath(org.cristalise.kernel.lookup.DomainPath) CannotManageException(org.cristalise.kernel.common.CannotManageException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) CorbaServer(org.cristalise.kernel.entity.CorbaServer) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 14 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class BulkImport method importAllClusters.

public void importAllClusters() throws InvalidDataException, PersistencyException {
    for (ItemPath item : getItemsToImport(root)) {
        Object sublocker = new Object();
        for (ClusterType type : importCluster.getClusters(item)) {
            switch(type) {
                case PATH:
                    importPath(item, sublocker);
                    break;
                case PROPERTY:
                    importProperty(item, sublocker);
                    break;
                case LIFECYCLE:
                    importLifeCycle(item, sublocker);
                    break;
                case HISTORY:
                    importHistory(item, sublocker);
                    break;
                case VIEWPOINT:
                    importViewPoint(item, sublocker);
                    break;
                case OUTCOME:
                    importOutcome(item, sublocker);
                    break;
                case COLLECTION:
                    importCollection(item, sublocker);
                    break;
                case JOB:
                    importJob(item, sublocker);
                    break;
                default:
                    break;
            }
        }
        // importCluster.delete(item, "");
        Gateway.getStorage().commit(sublocker);
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) ClusterType(org.cristalise.kernel.persistency.ClusterType) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 15 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class Activity method getTypeName.

public String getTypeName() {
    if (mType == null)
        return null;
    if (mTypeName == null) {
        try {
            ItemPath actType = new ItemPath(mType);
            Property nameProp = (Property) Gateway.getStorage().get(actType, ClusterType.PROPERTY + "/" + NAME, null);
            mTypeName = nameProp.getValue();
        } catch (Exception e) {
            mTypeName = mType;
        }
    }
    return mTypeName;
}
Also used : Property(org.cristalise.kernel.property.Property) WriteProperty(org.cristalise.kernel.lifecycle.instance.predefined.WriteProperty) XPathExpressionException(javax.xml.xpath.XPathExpressionException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

ItemPath (org.cristalise.kernel.lookup.ItemPath)36 DomainPath (org.cristalise.kernel.lookup.DomainPath)16 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)14 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)10 PersistencyException (org.cristalise.kernel.common.PersistencyException)10 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)10 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)6 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)5 CannotManageException (org.cristalise.kernel.common.CannotManageException)4 AgentPath (org.cristalise.kernel.lookup.AgentPath)4 Test (org.junit.Test)4 Aggregation (org.cristalise.kernel.collection.Aggregation)3 TraceableEntity (org.cristalise.kernel.entity.TraceableEntity)3 Path (org.cristalise.kernel.lookup.Path)3 Property (org.cristalise.kernel.property.Property)3 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)3 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 StringTokenizer (java.util.StringTokenizer)2 Dependency (org.cristalise.kernel.collection.Dependency)2