Search in sources :

Example 26 with Object

use of org.omg.CORBA.Object 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 Object

use of org.omg.CORBA.Object in project ACS by ACS-Community.

the class AlarmServiceUtils method getAlarmService.

/**
	 * Get a reference to the {@link AlarmService}.
	 * 
	 * @return The {@link AlarmService} 
	 */
public AlarmService getAlarmService() throws Exception {
    String name = alma.alarmsystem.AlarmServiceName.value;
    try {
        // try naming service first
        NamingContext ns = getNamingContext();
        NameComponent[] nameComponent = new NameComponent[1];
        nameComponent[0] = new NameComponent(name, "");
        Object alarmObj = ns.resolve(nameComponent);
        return AlarmServiceHelper.narrow(alarmObj);
    } catch (Throwable th) {
        logger.info("Failed to obtain alarm service reference from naming service, trying corbaloc...");
    }
    String corbaloc = "corbaloc::" + ACSPorts.getIP() + ":" + ACSPorts.getAlarmServicePort() + "/" + name;
    Object alarmObj = orb.string_to_object(corbaloc);
    return AlarmServiceHelper.narrow(alarmObj);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) Object(org.omg.CORBA.Object) NamingContext(org.omg.CosNaming.NamingContext)

Example 28 with Object

use of org.omg.CORBA.Object in project alliance by codice.

the class LibraryImpl method getCatalogMgrObject.

private Object getCatalogMgrObject(String managerId) {
    Object obj;
    CatalogMgrImpl catalogMgr = new CatalogMgrImpl(poa, filterBuilder, querySources);
    catalogMgr.setCatalogFramework(catalogFramework);
    catalogMgr.setOutgoingValidationEnabled(outgoingValidationEnabled);
    catalogMgr.setRemoveSourceLibrary(removeSourceLibrary);
    if (!CorbaUtils.isIdActive(poa, managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)))) {
        try {
            poa.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), catalogMgr);
        } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
            LOGGER.info("Error activating CatalogMgr: ", e);
        }
    }
    obj = poa.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), CatalogMgrHelper.id());
    return obj;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) Object(org.omg.CORBA.Object) CatalogMgrImpl(org.codice.alliance.nsili.endpoint.managers.CatalogMgrImpl) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Example 29 with Object

use of org.omg.CORBA.Object in project alliance by codice.

the class LibraryImpl method getProductObject.

private Object getProductObject(String managerId) {
    Object obj;
    ProductMgrImpl productMgr = new ProductMgrImpl(querySources);
    productMgr.setCatalogFramework(catalogFramework);
    productMgr.setFilterBuilder(filterBuilder);
    productMgr.setOutgoingValidationEnabled(outgoingValidationEnabled);
    if (!CorbaUtils.isIdActive(poa, managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)))) {
        try {
            poa.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), productMgr);
        } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
            LOGGER.info("Error activating ProductMgr: ", e);
        }
    }
    obj = poa.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), ProductMgrHelper.id());
    return obj;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) ProductMgrImpl(org.codice.alliance.nsili.endpoint.managers.ProductMgrImpl) Object(org.omg.CORBA.Object) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Aggregations

Object (org.omg.CORBA.Object)29 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)9 BadParametersException (com.cosylab.acs.maci.BadParametersException)8 CoreException (com.cosylab.acs.maci.CoreException)8 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)8 BAD_PARAM (org.omg.CORBA.BAD_PARAM)8 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)8 UNKNOWN (org.omg.CORBA.UNKNOWN)8 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)6 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)6 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)6 Component (com.cosylab.acs.maci.Component)5 URI (java.net.URI)5 URISyntaxException (java.net.URISyntaxException)5 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 AcsJComponentNotAlreadyActivatedEx (alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx)2 AcsJComponentSpecIncompatibleWithActiveComponentEx (alma.maciErrType.wrappers.AcsJComponentSpecIncompatibleWithActiveComponentEx)2 AcsJIncompleteComponentSpecEx (alma.maciErrType.wrappers.AcsJIncompleteComponentSpecEx)2