Search in sources :

Example 1 with Path

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);
}
Also used : ItemPath(org.cristalise.kernel.lookup.ItemPath) RolePath(org.cristalise.kernel.lookup.RolePath) DomainPath(org.cristalise.kernel.lookup.DomainPath) AgentPath(org.cristalise.kernel.lookup.AgentPath) Path(org.cristalise.kernel.lookup.Path) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 2 with Path

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;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) AgentPath(org.cristalise.kernel.lookup.AgentPath) ItemPath(org.cristalise.kernel.lookup.ItemPath) Path(org.cristalise.kernel.lookup.Path) DomainPath(org.cristalise.kernel.lookup.DomainPath)

Example 3 with Path

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)));
        }
    }
}
Also used : RolePath(org.cristalise.kernel.lookup.RolePath) DomainPath(org.cristalise.kernel.lookup.DomainPath) Path(org.cristalise.kernel.lookup.Path) AgentPath(org.cristalise.kernel.lookup.AgentPath) AgentPath(org.cristalise.kernel.lookup.AgentPath) RolePath(org.cristalise.kernel.lookup.RolePath)

Example 4 with Path

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())));
        }
    }
}
Also used : RolePath(org.cristalise.kernel.lookup.RolePath) DomainPath(org.cristalise.kernel.lookup.DomainPath) Path(org.cristalise.kernel.lookup.Path) AgentPath(org.cristalise.kernel.lookup.AgentPath) DomainPath(org.cristalise.kernel.lookup.DomainPath)

Example 5 with Path

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);
    }
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemPath(org.cristalise.kernel.lookup.ItemPath) Path(org.cristalise.kernel.lookup.Path) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Property(org.cristalise.kernel.property.Property) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

DomainPath (org.cristalise.kernel.lookup.DomainPath)5 Path (org.cristalise.kernel.lookup.Path)5 AgentPath (org.cristalise.kernel.lookup.AgentPath)4 ItemPath (org.cristalise.kernel.lookup.ItemPath)3 RolePath (org.cristalise.kernel.lookup.RolePath)3 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)2 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)1 Property (org.cristalise.kernel.property.Property)1