use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class ManagerProxyImpl method get_component_info.
/**
* Get all the information that the Manager has about components.
* To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must have adequate privileges to access the Component (the same as with the get_component method).
* Information about all components is returned, unless the active_only parameter is set to true,
* in which case only information about those components that are currently registered with the Manager
* and activated is returned.
* Calling this function does not affect the internal state of the Manager.
*
* @param id Identification of the caller.
* @param h Handles of the components whose information is requested. If this is an empty sequence, the name_wc and type_wc parameters are used.
* @param name_wc Wildcard that the Component's name must match in order for its information to be returned.
* @param type_wc Wildcard that the Component's type must match in order for its information to be returned.
* @param active_only
* @return A sequence of ComponentInfo structures containing the entire Manager's knowledge about the components.
* If access is denied to a subset of objects, the handles to those objects are set to 0.
*/
public ComponentInfo[] get_component_info(int id, int[] h, String name_wc, String type_wc, boolean active_only) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// invalid info (replacement for null)
final ComponentInfo invalidInfo = new ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
// returned value
ComponentInfo[] retVal = null;
// transform to CORBA specific
com.cosylab.acs.maci.ComponentInfo[] infos = manager.getComponentInfo(id, h, name_wc, type_wc, active_only);
if (infos != null) {
retVal = new ComponentInfo[infos.length];
for (int i = 0; i < infos.length; i++) if (infos[i] == null)
retVal[i] = invalidInfo;
else {
Object obj = null;
if (infos[i].getComponent() != null)
obj = (Object) infos[i].getComponent().getObject();
String[] interfaces;
if (infos[i].getInterfaces() != null)
interfaces = infos[i].getInterfaces();
else
interfaces = new String[0];
retVal[i] = new ComponentInfo(infos[i].getType(), infos[i].getCode(), obj, infos[i].getName(), infos[i].getClients().toArray(), infos[i].getContainer(), infos[i].getContainerName(), infos[i].getHandle(), mapAccessRights(infos[i].getAccessRights()), interfaces);
}
} else
retVal = new ComponentInfo[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();
}
}
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();
}
}
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);
}
Aggregations