Search in sources :

Example 6 with AcsJNoPermissionEx

use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.

the class ManagerProxyImpl method get_component_non_sticky.

/**
	 * Get a component, do not activate it and also do not do any reference counting.
	 * The client represented by id (the handle)
	 * must have adequate access rights to access the Component. This is untrue of components:
	 * components always have unlimited access rights to other components.
	 *
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param component_url CURL of the Component whose reference is to be retrieved.
	 * @return Reference to the Component.
	 */
public Object get_component_non_sticky(int id, String component_url) throws NoPermissionEx, CannotGetComponentEx, ComponentNotAlreadyActivatedEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.getComponentNonSticky(id, uri);
        // extract Component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        // @todo
        if (component == null)
            throw new AcsJComponentNotAlreadyActivatedEx();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } catch (AcsJComponentNotAlreadyActivatedEx cnaae) {
        // rethrow CORBA specific
        throw cnaae.toComponentNotAlreadyActivatedEx();
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) AcsJComponentNotAlreadyActivatedEx(alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 7 with AcsJNoPermissionEx

use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.

the class ManagerProxy method releaseComponentAsync.

public void releaseComponentAsync(int id, URI curl, LongCompletionCallback callback) throws AcsJNoPermissionEx, AcsJBadParameterEx {
    try {
        final LongCompletionCallback fcallback = callback;
        CBlongPOA cbo = new CBlongPOA() {

            public boolean negotiate(long time_to_transmit, CBDescOut desc) {
                return false;
            }

            public void working(int value, Completion c, CBDescOut desc) {
            // noop
            }

            public void done(int value, Completion c, CBDescOut desc) {
                if (c.code == 0 && c.type == 0)
                    fcallback.done(value);
                else
                    // TODO maybe convert to specific exceptions
                    fcallback.failed(value, AcsJCompletion.fromCorbaCompletion(c).getAcsJException());
            }
        };
        CBDescIn desc = new CBDescIn(0, 0, 0);
        manager.release_component_async(id, curl.toString(), cbo._this(), desc);
    } catch (NoPermissionEx nop) {
        throw new AcsJNoPermissionEx(nop);
    }
}
Also used : Completion(alma.ACSErr.Completion) AcsJCompletion(alma.acs.exceptions.AcsJCompletion) CBDescOut(alma.ACS.CBDescOut) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CBlongPOA(alma.ACS.CBlongPOA) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CBDescIn(alma.ACS.CBDescIn)

Example 8 with AcsJNoPermissionEx

use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.

the class ManagerProxyImpl method get_container_info.

/**
	 * Get all the information that the Manager has about its known Containers.
	 * To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must be the object whose info it is requesting.
	 * Calling this function does not affect the internal state of the Manager.
	 *
	 * @param id Identification of the caller.
	 * @param h Handles of the containers whose information is requested. If this is an empty sequence, the name_wc parameter is used.
	 * @param name_wc Wildcard that the container's name must match in order for its information to be returned.
	 * @return A sequence of ContainerInfo structures containing the entire Manager's knowledge about the containers.
	 *		  If access is denied to a subset of objects, the handles to those objects are set to 0.
	 */
public ContainerInfo[] get_container_info(int id, int[] h, String name_wc) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // invalid info (replacement for null)
        final ContainerInfo invalidInfo = new ContainerInfo("<invalid>", 0, null, new int[0]);
        // returned value
        ContainerInfo[] retVal = null;
        // transform to CORBA specific
        com.cosylab.acs.maci.ContainerInfo[] infos = manager.getContainerInfo(id, h, name_wc);
        if (infos != null) {
            retVal = new ContainerInfo[infos.length];
            for (int i = 0; i < infos.length; i++) if (infos[i] == null)
                retVal[i] = invalidInfo;
            else
                retVal[i] = new ContainerInfo(infos[i].getName(), infos[i].getHandle(), (Container) ((ContainerProxy) infos[i].getContainer()).getClient(), infos[i].getComponents().toArray());
        } else
            retVal = new ContainerInfo[0];
        return retVal;
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) Container(si.ijs.maci.Container) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) ContainerInfo(si.ijs.maci.ContainerInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 9 with AcsJNoPermissionEx

use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.

the class ManagerProxyImpl method restart_component.

/**
	 * Restarts an component.
	 * @param	id 	identification of the caller. Called has to be an owner of the component.
	 * @param	component_url	CURL of the component to be restarted.
	 * @return	CORBA reference of the restarted component, <code>null</code> if it fails.
	 */
public Object restart_component(int id, String component_url) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.restartComponent(id, uri);
        // extract component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJBadParameterEx bpe) {
        reportException(bpe);
        //throw bpe.toBadParameterEx();
        throw new BAD_PARAM(bpe.getMessage());
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 10 with AcsJNoPermissionEx

use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.

the class ManagerImplTest method internalTestGetHierarchicalComponentPassingComponentHandle.

public void internalTestGetHierarchicalComponentPassingComponentHandle(boolean activateOnActivation) {
    try {
        TestContainer container = new TestContainer("Container");
        Map supportedComponents = new HashMap();
        TestContainer container2 = new TestContainer("Container2");
        Map supportedComponents2 = new HashMap();
        TestHierarchicalComponent mount2HierCOB = new TestHierarchicalComponent("HierarchicalCOB2", manager, new String[] { "MOUNT3" }, true, activateOnActivation);
        TestHierarchicalComponent mount3HierCOB = new TestHierarchicalComponent("HierarchicalCOB3", manager, new String[] { "MOUNT5" }, true, activateOnActivation);
        Component mount4COB = new TestComponent("MOUNT4");
        supportedComponents.put("MOUNT2", mount2HierCOB);
        supportedComponents.put("MOUNT3", mount3HierCOB);
        supportedComponents2.put("MOUNT5", mount4COB);
        container.setSupportedComponents(supportedComponents);
        container2.setSupportedComponents(supportedComponents2);
        // test case when container is unable to activate startup Component - MOUNT1
        ClientInfo containerInfo = manager.login(container);
        ClientInfo containerInfo2 = manager.login(container2);
        TestAdministrator client = new TestAdministrator(administratorName);
        ClientInfo info = manager.login(client);
        // test ordinary activation
        URI mount2URI;
        try {
            mount2URI = new URI("MOUNT2");
            StatusHolder status = new StatusHolder();
            Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
            assertEquals(mount2HierCOB, ref);
            assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
        } catch (Exception ex) {
            fail();
        }
        try {
            Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be all three Components activated
        ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(3, infos.length);
        // container logout and login
        manager.logout(containerInfo.getHandle());
        try {
            Thread.sleep(SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be no Components activated on "Container"
        infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(1, infos.length);
        manager.login(container);
        try {
            Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be all three Components activated
        infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(3, infos.length);
        // test ordinary deactivation
        try {
            mount2URI = new URI("MOUNT2");
            int owners = manager.releaseComponent(info.getHandle(), mount2URI);
            assertEquals(0, owners);
        } catch (Exception ex) {
            fail();
        }
        try {
            Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be no Components activated (hierarchical deactivation)
        infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(0, infos.length);
        // test ordinary activation again
        try {
            mount2URI = new URI("MOUNT2");
            StatusHolder status = new StatusHolder();
            Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
            assertEquals(mount2HierCOB, ref);
            assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
        } catch (Exception ex) {
            fail();
        }
        // logout container2
        manager.logout(containerInfo2.getHandle());
        try {
            Thread.sleep(SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // logout client
        manager.logout(info.getHandle());
        try {
            Thread.sleep(SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
    } catch (AcsJNoPermissionEx e) {
        fail("No permission");
    }
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) RemoteException(com.cosylab.acs.maci.RemoteException) URISyntaxException(java.net.URISyntaxException) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) NoDefaultComponentException(com.cosylab.acs.maci.NoDefaultComponentException) StatusHolder(com.cosylab.acs.maci.StatusHolder) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ClientInfo(com.cosylab.acs.maci.ClientInfo) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) Component(com.cosylab.acs.maci.Component) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)63 ClientInfo (com.cosylab.acs.maci.ClientInfo)39 BadParametersException (com.cosylab.acs.maci.BadParametersException)37 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)33 URI (java.net.URI)25 Component (com.cosylab.acs.maci.Component)24 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)24 URISyntaxException (java.net.URISyntaxException)24 HashMap (java.util.HashMap)21 Map (java.util.Map)21 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)20 RemoteException (com.cosylab.acs.maci.RemoteException)18 StatusHolder (com.cosylab.acs.maci.StatusHolder)18 CoreException (com.cosylab.acs.maci.CoreException)14 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)13 BAD_PARAM (org.omg.CORBA.BAD_PARAM)13 UNKNOWN (org.omg.CORBA.UNKNOWN)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)10 Object (org.omg.CORBA.Object)9