Search in sources :

Example 6 with ItemPath

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

the class ImportDependency method create.

public Dependency create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
    Dependency newDep = isDescription ? new DependencyDescription(name) : new Dependency(name);
    if (version != null)
        newDep.setVersion(version);
    if (itemDescriptionPath != null && itemDescriptionPath.length() > 0) {
        ItemPath itemPath;
        try {
            itemPath = new ItemPath(itemDescriptionPath);
        } catch (InvalidItemPathException ex) {
            itemPath = new DomainPath(itemDescriptionPath).getItemPath();
        }
        String descVer = itemDescriptionVersion == null ? "last" : itemDescriptionVersion;
        PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
        StringBuffer classProps = new StringBuffer();
        for (PropertyDescription pd : propList.list) {
            props.put(pd.getName(), pd.getDefaultValue());
            if (pd.getIsClassIdentifier())
                classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
        }
        newDep.setProperties(props);
        newDep.setClassProps(classProps.toString());
    }
    for (ImportDependencyMember thisMem : dependencyMemberList) {
        ItemPath itemPath;
        try {
            itemPath = new ItemPath(thisMem.itemPath);
        } catch (InvalidItemPathException ex) {
            itemPath = new DomainPath(thisMem.itemPath).getItemPath();
        }
        org.cristalise.kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath);
        newDepMem.getProperties().putAll(thisMem.props);
    }
    return newDep;
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) Dependency(org.cristalise.kernel.collection.Dependency) PropertyDescription(org.cristalise.kernel.property.PropertyDescription) DependencyDescription(org.cristalise.kernel.collection.DependencyDescription) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 7 with ItemPath

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

the class ImportItem method getTraceableEntitiy.

/**
 * @return
 * @throws ObjectNotFoundException
 * @throws CannotManageException
 * @throws ObjectAlreadyExistsException
 * @throws ObjectCannotBeUpdated
 */
private TraceableEntity getTraceableEntitiy() throws ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, ObjectCannotBeUpdated {
    TraceableEntity newItem;
    ItemPath ip = getItemPath();
    if (ip.exists()) {
        Logger.msg(1, "ImportItem.getTraceableEntitiy() - Verifying module item " + domainPath + " at " + ip);
        newItem = Gateway.getCorbaServer().getItem(getItemPath());
        isNewItem = false;
    } else {
        Logger.msg("ImportItem.getTraceableEntitiy() - Creating module item " + ip + " at " + domainPath);
        newItem = Gateway.getCorbaServer().createItem(ip);
        Gateway.getLookupManager().add(ip);
    }
    return newItem;
}
Also used : TraceableEntity(org.cristalise.kernel.entity.TraceableEntity) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 8 with ItemPath

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

the class AggregationMember method setChildUUID.

public void setChildUUID(String uuid) throws InvalidCollectionModification, InvalidItemPathException {
    mItemPath = new ItemPath(uuid);
    mItemName = null;
}
Also used : ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 9 with ItemPath

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

the class Bootstrap method verifyBootDataItems.

/**
 * @param bootList
 * @param ns
 * @param reset
 * @throws InvalidItemPathException
 */
private static void verifyBootDataItems(String bootList, String ns, boolean reset) throws InvalidItemPathException {
    StringTokenizer str = new StringTokenizer(bootList, "\n\r");
    while (str.hasMoreTokens() && !shutdown) {
        String thisItem = str.nextToken();
        String[] idFilename = thisItem.split(",");
        String id = idFilename[0], filename = idFilename[1];
        ItemPath itemPath = new ItemPath(id);
        String[] fileParts = filename.split("/");
        String itemType = fileParts[0], itemName = fileParts[1];
        try {
            String location = "boot/" + filename + (itemType.equals("OD") ? ".xsd" : ".xml");
            verifyResource(ns, itemName, 0, itemType, itemPath, location, reset);
        } catch (Exception e) {
            Logger.error(e);
            Logger.die("Error importing bootstrap items. Unsafe to continue.");
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 10 with ItemPath

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

the class Bootstrap method verifyResource.

/**
 * @param ns
 * @param itemName
 * @param version
 * @param itemType
 * @param itemPath
 * @param outcomes
 * @param dataLocation
 * @param reset
 * @return the Path of the resource either created or initialised from existing data
 * @throws Exception
 */
private static DomainPath verifyResource(String ns, String itemName, int version, String itemType, ItemPath itemPath, Set<Outcome> outcomes, String dataLocation, boolean reset) throws Exception {
    ResourceImportHandler typeImpHandler = Gateway.getResourceImportHandler(BuiltInResources.getValue(itemType));
    Logger.msg(1, "Bootstrap.verifyResource() - Verifying " + typeImpHandler.getName() + " " + itemName + " v" + version);
    // Find or create Item for Resource
    ItemProxy thisProxy;
    DomainPath modDomPath = typeImpHandler.getPath(itemName, ns);
    if (modDomPath.exists()) {
        Logger.msg(3, "Bootstrap.verifyResource() - Found " + typeImpHandler.getName() + " " + itemName + ".");
        thisProxy = verifyPathAndModuleProperty(ns, itemType, itemName, itemPath, modDomPath, modDomPath);
    } else {
        if (itemPath == null)
            itemPath = new ItemPath();
        Logger.msg("Bootstrap.verifyResource() - " + typeImpHandler.getName() + " " + itemName + " not found. Creating new.");
        thisProxy = createResourceItem(typeImpHandler, itemName, ns, itemPath);
    }
    // Verify/Import Outcomes, creating events and views as necessary
    if (outcomes == null || outcomes.size() == 0) {
        outcomes = typeImpHandler.getResourceOutcomes(itemName, ns, dataLocation, version);
    }
    if (outcomes.size() == 0)
        Logger.warning("Bootstrap.verifyResource() - no Outcome found therefore nothing stored!");
    for (Outcome newOutcome : outcomes) {
        if (checkToStoreOutcomeVersion(thisProxy, newOutcome, version, reset)) {
            // validate it, but not for kernel objects (ns == null) because those are to validate the rest
            if (ns != null)
                newOutcome.validateAndCheck();
            storeOutcomeEventAndViews(thisProxy, newOutcome, version);
            CollectionArrayList cols = typeImpHandler.getCollections(itemName, version, newOutcome);
            for (Collection<?> col : cols.list) {
                Gateway.getStorage().put(thisProxy.getPath(), col, thisProxy);
                Gateway.getStorage().clearCache(thisProxy.getPath(), ClusterType.COLLECTION + "/" + col.getName());
                col.setVersion(null);
                Gateway.getStorage().put(thisProxy.getPath(), col, thisProxy);
            }
        }
    }
    Gateway.getStorage().commit(thisProxy);
    return modDomPath;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) ResourceImportHandler(org.cristalise.kernel.process.resource.ResourceImportHandler) Outcome(org.cristalise.kernel.persistency.outcome.Outcome) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) 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