Search in sources :

Example 26 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class ManagerProxyImpl method get_dynamic_component.

/**
	 * Activation of an dynamic component.
	 * @param	id 	identification of the caller.
	 * @param	c	component to be obtained.
	 * @param	mark_as_default	mark component as default component of its type.
	 * @return	<code>ComponentInfo</code> of requested component.
	 */
public ComponentInfo get_dynamic_component(int id, si.ijs.maci.ComponentSpec c, boolean mark_as_default) throws NoPermissionEx, IncompleteComponentSpecEx, InvalidComponentSpecEx, ComponentSpecIncompatibleWithActiveComponentEx, CannotGetComponentEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        ComponentInfo retVal = null;
        /*
			URI uri = null;
			if (c.component_name != null)
				uri = CURLHelper.createURI(c.component_name);
			ComponentSpec componentSpec = new ComponentSpec(uri, c.component_type, c.component_code, c.container_name);
			*/
        // @todo si.ijs.maci.COMPONENT_SPEC_ANY -> ComponentSpec.COMPSPEC_ANY
        ComponentSpec componentSpec = new ComponentSpec(c.component_name, c.component_type, c.component_code, c.container_name);
        com.cosylab.acs.maci.ComponentInfo info = manager.getDynamicComponent(id, componentSpec, mark_as_default);
        // transform to CORBA specific
        if (info == null || info.getComponent() == null)
            throw new AcsJCannotGetComponentEx();
        Object obj = null;
        obj = (Object) info.getComponent().getObject();
        String[] interfaces;
        if (info.getInterfaces() != null)
            interfaces = info.getInterfaces();
        else
            interfaces = new String[0];
        retVal = new ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), mapAccessRights(info.getAccessRights()), interfaces);
        return retVal;
    }/*
		catch (URISyntaxException usi)
		{
			BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
			hbpe.caughtIn(this, "get_dynamic_component");
			hbpe.putValue("c.component_name", c.component_name);
			// exception service will handle this
			reportException(hbpe);
	
			// rethrow CORBA specific
			throw new BAD_PARAM(usi.getMessage());
		}*/
     catch (AcsJInvalidComponentSpecEx ics) {
        // rethrow CORBA specific
        throw ics.toInvalidComponentSpecEx();
    } catch (AcsJIncompleteComponentSpecEx ics) {
        // rethrow CORBA specific
        throw ics.toIncompleteComponentSpecEx();
    } catch (AcsJComponentSpecIncompatibleWithActiveComponentEx cpiwac) {
        // rethrow CORBA specific
        throw cpiwac.toComponentSpecIncompatibleWithActiveComponentEx();
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } 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) {
        reportException(cgce);
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } 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 : AcsJComponentSpecIncompatibleWithActiveComponentEx(alma.maciErrType.wrappers.AcsJComponentSpecIncompatibleWithActiveComponentEx) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ComponentSpec(com.cosylab.acs.maci.ComponentSpec) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) AcsJIncompleteComponentSpecEx(alma.maciErrType.wrappers.AcsJIncompleteComponentSpecEx) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJInvalidComponentSpecEx(alma.maciErrType.wrappers.AcsJInvalidComponentSpecEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) ComponentInfo(si.ijs.maci.ComponentInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 27 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class ManagerDynComponentTest method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            try {
                /* ------------------------------------------------- */
                manager.restart_component(clientInfo.h, "invalid");
                manager.get_component(clientInfo.h, "MOUNT1", true);
                manager.restart_component(clientInfo.h, "MOUNT1");
                try {
                    manager.get_default_component(clientInfo.h, "invalid");
                    System.err.println("NoDefaultComponent exception expected.");
                } catch (NoDefaultComponentEx nde) {
                // this is OK
                }
                try {
                    manager.get_dynamic_component(clientInfo.h, new ComponentSpec("*", "invalidType", "*", "*"), true);
                    System.err.println("InvalidComponentSpec exception expected.");
                } catch (InvalidComponentSpecEx ics) {
                // this is OK
                }
                /* ------------------------------------------------- */
                ComponentInfo componentInfo = manager.get_dynamic_component(clientInfo.h, new ComponentSpec("FULL_DYNAMIC", "IDL:alma/PS/PowerSupply:1.0", "acsexmplPS", "Container"), true);
                System.out.println(componentInfo.h);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : InvalidComponentSpecEx(alma.maciErrType.InvalidComponentSpecEx) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) ComponentSpec(si.ijs.maci.ComponentSpec) NoDefaultComponentEx(alma.maciErrType.NoDefaultComponentEx)

Aggregations

ComponentInfo (si.ijs.maci.ComponentInfo)27 ClientInfo (si.ijs.maci.ClientInfo)9 ContainerInfo (si.ijs.maci.ContainerInfo)8 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)6 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)5 ArrayList (java.util.ArrayList)5 ComponentDescriptor (alma.acs.component.ComponentDescriptor)4 BadParametersException (com.cosylab.acs.maci.BadParametersException)4 CoreException (com.cosylab.acs.maci.CoreException)4 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)4 BAD_PARAM (org.omg.CORBA.BAD_PARAM)4 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)4 Object (org.omg.CORBA.Object)4 UNKNOWN (org.omg.CORBA.UNKNOWN)4 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)3 AcsJException (alma.acs.exceptions.AcsJException)3 NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)2 ComponentDeactivationFailedEx (alma.maciErrType.ComponentDeactivationFailedEx)2 ComponentDeactivationUncleanEx (alma.maciErrType.ComponentDeactivationUncleanEx)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2