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;
}
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;
}
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;
}
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.");
}
}
}
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;
}
Aggregations