Search in sources :

Example 16 with DomainPath

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

the class RemoveDomainPath method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
    String[] params = getDataList(requestData);
    if (Logger.doLog(3))
        Logger.msg(3, "RemoveDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
    if (params.length != 1)
        throw new InvalidDataException("RemoveDomainPath: Invalid parameters " + Arrays.toString(params));
    DomainPath domainPath = new DomainPath(params[0]);
    if (!domainPath.exists()) {
        throw new ObjectNotFoundException("RemoveDomainPath: Domain path " + domainPath + " does not exist.");
    }
    if (!domainPath.getItemPath().equals(item)) {
        throw new InvalidDataException("RemoveDomainPath: Domain path " + domainPath + " is not an alias of the current Item " + item);
    }
    Gateway.getLookupManager().delete(domainPath);
    return requestData;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 17 with DomainPath

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

the class AddDomainContext method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
    String[] params = getDataList(requestData);
    Logger.msg(3, "AddDomainContext: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
    if (params.length != 1)
        throw new InvalidDataException("AddDomainContext: Invalid parameters " + Arrays.toString(params));
    DomainPath pathToAdd = new DomainPath(params[0]);
    if (pathToAdd.exists())
        throw new ObjectAlreadyExistsException("Context " + pathToAdd + " already exists");
    // collect parent paths if they don't exist
    Stack<DomainPath> pathsToAdd = new Stack<DomainPath>();
    while (pathToAdd != null && !pathToAdd.exists()) {
        pathsToAdd.push(pathToAdd);
        pathToAdd = pathToAdd.getParent();
    }
    while (!pathsToAdd.empty()) {
        pathToAdd = pathsToAdd.pop();
        Gateway.getLookupManager().add(pathToAdd);
    }
    return requestData;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) Stack(java.util.Stack)

Example 18 with DomainPath

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

the class AddDomainPath method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
    String[] params = getDataList(requestData);
    if (Logger.doLog(3))
        Logger.msg(3, "AddDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
    if (params.length != 1)
        throw new InvalidDataException("AddDomainPath: Invalid parameters: " + Arrays.toString(params));
    Gateway.getLookupManager().add(new DomainPath(params[0], item));
    return requestData;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) InvalidDataException(org.cristalise.kernel.common.InvalidDataException)

Example 19 with DomainPath

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

the class ProxyManager method informTreeSubscribers.

private void informTreeSubscribers(boolean state, String path) {
    DomainPath last = new DomainPath(path);
    DomainPath parent;
    boolean first = true;
    synchronized (treeSubscribers) {
        while ((parent = last.getParent()) != null) {
            ArrayList<DomainPathSubscriber> currentKeys = new ArrayList<DomainPathSubscriber>();
            currentKeys.addAll(treeSubscribers.keySet());
            for (DomainPathSubscriber sub : currentKeys) {
                DomainPath interest = treeSubscribers.get(sub);
                if (interest != null && interest.equals(parent)) {
                    if (state == ProxyMessage.ADDED)
                        sub.pathAdded(last);
                    else if (first)
                        sub.pathRemoved(last);
                }
            }
            last = parent;
            first = false;
        }
    }
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) ArrayList(java.util.ArrayList)

Example 20 with DomainPath

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

the class Bootstrap method createServerItem.

public static void createServerItem() throws Exception {
    LookupManager lookupManager = Gateway.getLookupManager();
    String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
    thisServerPath = new DomainPath("/servers/" + serverName);
    ItemPath serverItem;
    try {
        serverItem = thisServerPath.getItemPath();
    } catch (ObjectNotFoundException ex) {
        Logger.msg("Creating server item " + thisServerPath);
        serverItem = new ItemPath();
        Gateway.getCorbaServer().createItem(serverItem);
        lookupManager.add(serverItem);
        thisServerPath.setItemPath(serverItem);
        lookupManager.add(thisServerPath);
    }
    int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
    Gateway.getStorage().put(serverItem, new Property(NAME, serverName, false), null);
    Gateway.getStorage().put(serverItem, new Property(TYPE, "Server", false), null);
    Gateway.getStorage().put(serverItem, new Property(KERNEL_VERSION, Gateway.getKernelVersion(), true), null);
    Gateway.getStorage().put(serverItem, new Property("ProxyPort", String.valueOf(proxyPort), false), null);
    Gateway.getStorage().put(serverItem, new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
    Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Property(org.cristalise.kernel.property.Property) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

DomainPath (org.cristalise.kernel.lookup.DomainPath)26 ItemPath (org.cristalise.kernel.lookup.ItemPath)15 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)12 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)11 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)8 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)5 PersistencyException (org.cristalise.kernel.common.PersistencyException)5 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)4 Property (org.cristalise.kernel.property.Property)4 PropertyArrayList (org.cristalise.kernel.property.PropertyArrayList)4 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)4 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)4 Aggregation (org.cristalise.kernel.collection.Aggregation)3 TraceableEntity (org.cristalise.kernel.entity.TraceableEntity)3 ItemProxy (org.cristalise.kernel.entity.proxy.ItemProxy)3 AgentPath (org.cristalise.kernel.lookup.AgentPath)3 Path (org.cristalise.kernel.lookup.Path)3 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)3 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)3 Test (org.junit.Test)3