use of alma.maciErrType.wrappers.AcsJCannotGetComponentEx in project ACS by ACS-Community.
the class ManagerProxyImpl method get_service.
/**
* Get a service, activating it if necessary (components).
* The client represented by id (the handle) must have adequate access rights to access the service.
* NOTE: a component is also a service, i.e. a service activated by a container.
*
* @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 service_url CURL of the service whose reference is to be retrieved.
* @param activate True if the component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
* @param status Status of the request. One of COMPONENT_ACTIVATED, COMPONENT_DOES_NO_EXIST and COMPONENT_NOT_ACTIVATED.
* @return Reference to the service. If the service could not be obtained, a nil reference is returned,
* and the status contains an error code detailing the cause of failure (one of the COMPONENT_* constants).
* @see #get_component
*/
public Object get_service(int id, String service_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx {
pendingRequests.incrementAndGet();
try {
// returned value
Object retVal = null;
// returned status
StatusHolder statusHolder = new StatusHolder();
// transform to CORBA specific
URI uri = null;
if (service_url != null)
uri = CURLHelper.createURI(service_url);
Component component = manager.getService(id, uri, activate, statusHolder);
if (component == null || (Object) component.getObject() == null)
throw new AcsJCannotGetComponentEx();
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 (AcsJCannotGetComponentEx cgce) {
// rethrow CORBA specific
throw cgce.toCannotGetComponentEx();
} 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 alma.maciErrType.wrappers.AcsJCannotGetComponentEx 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 alma.maciErrType.wrappers.AcsJCannotGetComponentEx in project ACS by ACS-Community.
the class CategoryClient method connect.
/**
* Connects to the passed categories of the alarm system
*
* @param listener The lister to notify of the alarms received from the categories
* @param categories The categories to connect to
* @throws AcsJCannotGetComponentEx In case the AlarmService is not available
* @throws AlarmClientException In case of failure connecting the client
*/
public void connect(AlarmSelectionListener listener, Category[] categories) throws AlarmClientException, AcsJCannotGetComponentEx {
if (listener == null) {
throw new IllegalArgumentException("The listener can't be null");
}
if (closed) {
throw new IllegalStateException("SourceClient is closed!");
}
try {
CernAlarmServiceUtils alarmUtils = new CernAlarmServiceUtils(orb, logger);
alarm = alarmUtils.getCernAlarmService();
} catch (Throwable t) {
AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx(t);
ex.setReason("Alarm service unavailable");
throw ex;
}
try {
userHandler = new UserHandlerImpl(orb, logger);
logger.log(AcsLogLevel.DEBUG, "UserHandler succesfully built");
testUser = userHandler.getUser("test", orb, logger);
logger.log(AcsLogLevel.DEBUG, "User generated");
defaultConf = testUser.getDefaultConfiguration();
logger.log(AcsLogLevel.DEBUG, "Getting the selection handler");
jms_selectionHandler = AlarmSelectionHandler.get(orb, logger);
addCategories(defaultConf, categories);
// Get the active alarms (they are received by the listener)
java.util.Map<String, Alarm> alreadyActive = jms_selectionHandler.select(defaultConf.getSelection(), listener);
if (alreadyActive != null && alreadyActive.size() > 0) {
Set<String> keys = alreadyActive.keySet();
for (String key : keys) {
listener.onAlarm(alreadyActive.get(key));
}
}
} catch (Throwable t) {
throw new AlarmClientException("Exception connecting the category client", t);
}
}
use of alma.maciErrType.wrappers.AcsJCannotGetComponentEx in project ACS by ACS-Community.
the class CernSysPanel method connect.
/**
* Connect
*/
public void connect() {
if (connecting || closed) {
return;
}
connecting = true;
connectionListener.connecting();
notAvaiPnl.addMessage("Connecting to the alarm service");
notAvaiPnl.addMessage("Instantiating the category client");
try {
categoryClient = new AlarmCategoryClient(orb, logger);
} catch (Throwable t) {
System.err.println("Error instantiating the CategoryClient: " + t.getMessage());
notAvaiPnl.addMessage("Error instantiating the CategoryClient: " + t.getMessage());
t.printStackTrace(System.err);
connectionListener.disconnected();
categoryClient = null;
connecting = false;
return;
}
/**
* Try to connect to the alarm service until it becomes available
*/
categoryClient.addAlarmListener((AlarmSelectionListener) model);
while (true && !closed) {
notAvaiPnl.addMessage("Connecting to the categories");
try {
categoryClient.connect();
notAvaiPnl.addMessage("CategoryClient connected");
// If the connection succeeded then exit the loop
break;
} catch (AcsJCannotGetComponentEx cgc) {
// Wait 30 secs before retrying
// but checks if it is closed every second.
int t = 0;
while (t < 30) {
if (closed) {
return;
}
try {
Thread.sleep(1000);
} catch (Exception e) {
}
t++;
}
cgc.printStackTrace();
// Try again
continue;
} catch (Throwable t) {
System.err.println("Error connecting CategoryClient: " + t.getMessage() + ", " + t.getClass().getName());
notAvaiPnl.addMessage("Error connecting CategoryClient: " + t.getMessage() + ", " + t.getClass().getName());
t.printStackTrace(System.err);
connectionListener.disconnected();
connecting = false;
return;
}
}
if (closed) {
model.setCategoryClient(null);
return;
}
notAvaiPnl.addMessage("Connected to the alarm service");
connecting = false;
connectionListener.connected();
statusLine.start();
model.setCategoryClient(categoryClient);
alarmPanel.showPanel(AlarmPanel.cernSysName);
}
Aggregations