Search in sources :

Example 41 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.

the class MemberSubscription method loadChildren.

private void loadChildren() {
    C newMember;
    ProxyObserver<C> observer = getObserver();
    // reaped
    if (observer == null)
        return;
    try {
        // fetch contents of path
        String children = subject.queryData(interest + "/all");
        StringTokenizer tok = new StringTokenizer(children, ",");
        ArrayList<String> newContents = new ArrayList<String>();
        while (tok.hasMoreTokens()) newContents.add(tok.nextToken());
        // look to see what's new
        for (String newChild : newContents) {
            // load child object
            try {
                newMember = (C) subject.getObject(interest + "/" + newChild);
                contents.remove(newChild);
                observer.add(newMember);
            } catch (ObjectNotFoundException ex) {
                observer.control(ERROR, "Listed member " + newChild + " was not found.");
            } catch (ClassCastException ex) {
                Logger.error(ex);
                observer.control(ERROR, "Listed member " + newChild + " was the wrong type.");
            }
        }
        // report what's left in old contents as deleted
        for (String oldChild : contents) {
            observer.remove(interest + "/" + oldChild);
        }
        // replace contents arraylist
        contents = newContents;
        // report that we're done
        observer.control(END, null);
    } catch (Exception ex) {
        observer.control(ERROR, "Query on " + interest + " failed with " + ex.getMessage());
    }
    Logger.msg(5, "MemberSubscription.loadChildren() -  DONE interest:" + interest);
}
Also used : StringTokenizer(java.util.StringTokenizer) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ArrayList(java.util.ArrayList) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 42 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException 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)

Example 43 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.

the class Bootstrap method checkAgent.

/**
 * Checks for the existence of a agents so it can be used
 *
 * @param name
 * @param pass
 * @param rolePath
 * @param uuid
 * @return the Proxy representing the Agent
 * @throws Exception
 */
private static AgentProxy checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
    Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '" + name + "' agent.");
    LookupManager lookup = Gateway.getLookupManager();
    try {
        AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name));
        systemAgents.put(name, agentProxy);
        Logger.msg(3, "Bootstrap.checkAgent() - Agent '" + name + "' found.");
        return agentProxy;
    } catch (ObjectNotFoundException ex) {
    }
    Logger.msg("Bootstrap.checkAgent() - Agent '" + name + "' not found. Creating.");
    try {
        AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
        Gateway.getCorbaServer().createAgent(agentPath);
        lookup.add(agentPath);
        if (StringUtils.isNotBlank(pass))
            lookup.setAgentPassword(agentPath, pass);
        // assign admin role
        Logger.msg("Bootstrap.checkAgent() - Assigning role '" + rolePath.getName() + "'");
        Gateway.getLookupManager().addRole(agentPath, rolePath);
        Gateway.getStorage().put(agentPath, new Property(NAME, name, true), null);
        Gateway.getStorage().put(agentPath, new Property(TYPE, "Agent", false), null);
        AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(agentPath);
        // TODO: properly init agent here with wf, props and colls
        // agentProxy.initialise(agentId, itemProps, workflow, colls);
        systemAgents.put(name, agentProxy);
        return agentProxy;
    } catch (Exception ex) {
        Logger.error("Unable to create '" + name + "' Agent.");
        throw ex;
    }
}
Also used : AgentPath(org.cristalise.kernel.lookup.AgentPath) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) AgentProxy(org.cristalise.kernel.entity.proxy.AgentProxy) Property(org.cristalise.kernel.property.Property) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 44 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.

the class CreateItemFromDescription method initialiseItem.

/**
 * @param agent
 * @param descItemPath
 * @param locker
 * @param input
 * @param newName
 * @param descVer
 * @param context
 * @param newItemPath
 * @param newItem
 * @throws ObjectCannotBeUpdated
 * @throws CannotManageException
 * @throws InvalidDataException
 * @throws ObjectAlreadyExistsException
 * @throws PersistencyException
 * @throws ObjectNotFoundException
 */
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
    // initialise it with its properties and workflow
    Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
    try {
        PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
        CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
        CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
        newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
    } catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
        Logger.error(e);
        Gateway.getLookupManager().delete(newItemPath);
        throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
    } catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
        Logger.error(e);
        Gateway.getLookupManager().delete(newItemPath);
        throw e;
    }
    // add its domain path
    Logger.msg(3, "CreateItemFromDescription - Creating " + context);
    context.setItemPath(newItemPath);
    Gateway.getLookupManager().add(context);
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) ValidationException(org.exolab.castor.xml.ValidationException) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) IOException(java.io.IOException) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) MappingException(org.exolab.castor.mapping.MappingException) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 45 with ObjectNotFoundException

use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.

the class BulkImport method importAgentPath.

public AgentPath importAgentPath(ItemPath item, Object locker) throws PersistencyException {
    try {
        AgentPath agentPath = (AgentPath) importCluster.get(item, PATH + "/Item");
        Gateway.getLookupManager().add(agentPath);
        Gateway.getLookupManager().setAgentPassword(agentPath, "aaa");
        return agentPath;
    } catch (ObjectCannotBeUpdated | ObjectAlreadyExistsException | CannotManageException | ObjectNotFoundException | NoSuchAlgorithmException e) {
        Logger.error(e);
        throw new PersistencyException(e.getMessage());
    }
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) AgentPath(org.cristalise.kernel.lookup.AgentPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ObjectCannotBeUpdated(org.cristalise.kernel.common.ObjectCannotBeUpdated) PersistencyException(org.cristalise.kernel.common.PersistencyException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException)

Aggregations

ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)59 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)38 PersistencyException (org.cristalise.kernel.common.PersistencyException)27 DomainPath (org.cristalise.kernel.lookup.DomainPath)12 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)12 ItemPath (org.cristalise.kernel.lookup.ItemPath)12 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)11 AgentPath (org.cristalise.kernel.lookup.AgentPath)11 CannotManageException (org.cristalise.kernel.common.CannotManageException)9 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)8 IOException (java.io.IOException)7 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)7 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)6 ObjectCannotBeUpdated (org.cristalise.kernel.common.ObjectCannotBeUpdated)6 InvalidTransitionException (org.cristalise.kernel.common.InvalidTransitionException)5 ItemProxy (org.cristalise.kernel.entity.proxy.ItemProxy)5 InvalidAgentPathException (org.cristalise.kernel.lookup.InvalidAgentPathException)5 Property (org.cristalise.kernel.property.Property)5 MappingException (org.exolab.castor.mapping.MappingException)5 MarshalException (org.exolab.castor.xml.MarshalException)5