use of org.cristalise.kernel.lookup.DomainPath in project kernel by cristal-ise.
the class DescriptionObjectCache method findItem.
public ItemPath findItem(String name) throws ObjectNotFoundException, InvalidDataException {
if (Gateway.getLookup() == null)
throw new ObjectNotFoundException("Cannot find Items without a Lookup");
// first check for a UUID name
try {
ItemPath resItem = new ItemPath(name);
if (resItem.exists())
return resItem;
} catch (InvalidItemPathException ex) {
}
// then check for a direct path
DomainPath directPath = new DomainPath(name);
if (directPath.exists() && directPath.getItemPath() != null) {
return directPath.getItemPath();
}
// else search for it in the whole tree using property description
Property[] searchProps = new Property[classIdProps.length + 1];
searchProps[0] = new Property(NAME, name);
System.arraycopy(classIdProps, 0, searchProps, 1, classIdProps.length);
Iterator<Path> e = Gateway.getLookup().search(new DomainPath(), searchProps);
if (e.hasNext()) {
Path defPath = e.next();
if (e.hasNext())
throw new ObjectNotFoundException("Too many matches for " + getTypeCode() + " " + name);
if (defPath.getItemPath() == null)
throw new InvalidDataException(getTypeCode() + " " + name + " was found, but was not an Item");
return defPath.getItemPath();
} else {
throw new ObjectNotFoundException("No match for " + getTypeCode() + " " + name);
}
}
Aggregations