use of org.cristalise.kernel.lookup.Path in project kernel by cristal-ise.
the class AgentProxy method searchItem.
/**
* Let scripts resolve items
*/
public ItemProxy searchItem(Path root, String name) throws ObjectNotFoundException {
Iterator<Path> results = Gateway.getLookup().search(root, name);
Path returnPath = null;
if (!results.hasNext()) {
throw new ObjectNotFoundException(name);
} else {
while (results.hasNext()) {
Path nextMatch = results.next();
if (returnPath != null) {
// found already one but search if there are another, which is an error
if (isItemPathAndNotNull(nextMatch)) {
// test if another itemPath with same name
if (!returnPath.getItemPath().getUUID().equals(nextMatch.getItemPath().getUUID())) {
throw new ObjectNotFoundException("Too many different items with name:" + name);
} else {
returnPath = nextMatch;
}
}
} else {
if (isItemPathAndNotNull(nextMatch)) {
returnPath = nextMatch;
// found one but continue search
Logger.msg(5, "AgentProxy.searchItem() - found for " + name + " UUID = " + returnPath.getItemPath().getUUID());
}
}
}
}
// test if nothing found in the results
if (returnPath == null) {
throw new ObjectNotFoundException(name);
}
return Gateway.getProxyManager().getProxy(returnPath);
}
use of org.cristalise.kernel.lookup.Path in project kernel by cristal-ise.
the class Erase method runActivityLogic.
// requestdata is xmlstring
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, PersistencyException {
Logger.msg(1, "Erase::request() - Starting item:" + item.getUUID());
Iterator<Path> domPaths = Gateway.getLookup().searchAliases(item);
while (domPaths.hasNext()) {
DomainPath path = (DomainPath) domPaths.next();
// delete them
if (path.getItemPath().equals(item))
Gateway.getLookupManager().delete(path);
}
// clear out all storages
Gateway.getStorage().removeCluster(item, "", locker);
Logger.msg(1, "Erase::request() - DONE item:" + item.getUUID());
return requestData;
}
use of org.cristalise.kernel.lookup.Path in project kernel by cristal-ise.
the class StandardServer method resetAgentIORs.
public static void resetAgentIORs(RolePath root) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
Logger.msg("StandardServer.resetAgentIORs() - root:" + root);
Iterator<Path> roles = Gateway.getLookup().getChildren(root);
while (roles.hasNext()) {
RolePath role = (RolePath) roles.next();
resetAgentIORs(role);
for (AgentPath agent : Gateway.getLookup().getAgents(role)) {
Logger.msg("StandardServer.resetAgentIORs() - setting IOR for role:" + role + " agent:" + agent.getAgentName() + " " + agent.getItemPath());
Gateway.getLookupManager().setIOR(agent.getItemPath(), Gateway.getORB().object_to_string(Gateway.getCorbaServer().getAgentIOR(agent)));
}
}
}
use of org.cristalise.kernel.lookup.Path in project kernel by cristal-ise.
the class StandardServer method resetItemIORs.
public static void resetItemIORs(DomainPath root) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
Logger.msg("StandardServer.resetItemIORs() - root:" + root);
Iterator<Path> pathes = Gateway.getLookup().getChildren(root);
while (pathes.hasNext()) {
DomainPath domain = (DomainPath) pathes.next();
if (domain.isContext()) {
resetItemIORs(domain);
} else {
Logger.msg("StandardServer.resetItemIORs() - setting IOR for domain:" + domain + " item:" + domain.getItemPath());
Gateway.getLookupManager().setIOR(domain.getItemPath(), Gateway.getORB().object_to_string(Gateway.getCorbaServer().getItemIOR(domain.getItemPath())));
}
}
}
use of org.cristalise.kernel.lookup.Path 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