use of cern.laser.client.LaserException in project ACS by ACS-Community.
the class CategoryDefinitionHandlerImplTest method testUploadReader.
//
// -- TEST METHODS --------------------------------------------------
//
/*
* Class to test for void upload(Reader)
*/
public void testUploadReader() {
InputStream is = getClass().getResourceAsStream("create-category-definitions.xml");
InputStreamReader reader = new InputStreamReader(new BufferedInputStream(is));
try {
handler.upload(reader);
} catch (LaserDefinitionException e) {
fail(e.getMessage());
}
try {
assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS"));
} catch (LaserException e1) {
fail(e1.getMessage());
}
try {
assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST1"));
} catch (LaserException e2) {
fail(e2.getMessage());
}
try {
assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST2"));
} catch (LaserException e3) {
fail(e3.getMessage());
}
try {
assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST3"));
} catch (LaserException e4) {
fail(e4.getMessage());
}
is = getClass().getResourceAsStream("remove-category-definitions.xml");
reader = new InputStreamReader(new BufferedInputStream(is));
try {
handler.upload(reader);
} catch (LaserDefinitionException e5) {
fail(e5.getMessage());
}
try {
assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS"));
} catch (LaserException e6) {
}
try {
assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST1"));
} catch (LaserException e7) {
}
try {
assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST2"));
} catch (LaserException e8) {
}
try {
assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST3"));
} catch (LaserException e9) {
}
}
use of cern.laser.client.LaserException in project ACS by ACS-Community.
the class AlarmSelectionHandlerImpl method select.
/**
* DOCUMENT ME!
*
* @param selection DOCUMENT ME!
* @param listener DOCUMENT ME!
*
* @return DOCUMENT ME!
* @throws LaserConnectionException
* @throws LaserException DOCUMENT ME!
* @throws LaserException
* @throws LaserTimeOutException
* @throws LaserConnectionException
* @throws IllegalArgumentException DOCUMENT ME!
*/
public Map select(Selection selection, AlarmSelectionListener selectionListener) throws LaserException, LaserTimeOutException {
if (selection == null) {
throw new IllegalArgumentException("selection parameter is null");
}
if (selection.getCategorySelection() == null) {
throw new IllegalArgumentException("no categories selected");
}
try {
resetSelection();
// setup the heartbeat reception and start checking
startHeartbeatSubscription(selectionListener);
// perform the subscriptions
if (selection.getCategorySelection().list().length != 0) {
return subscribe(selection, selectionListener);
} else {
return Collections.EMPTY_MAP;
}
} catch (LaserConnectionException e) {
resetSelection();
throw new LaserException("unable to connect to perform the selection", e);
}
}
use of cern.laser.client.LaserException in project ACS by ACS-Community.
the class HeartbeatHelper method initHeartbeatCheck.
//
// -- PRIVATE METHODS ---------------------------------------------
//
/**
* @throws LaserException
* @throws LaserConnectionException
*/
private void initHeartbeatCheck() throws LaserException, LaserConnectionException {
if (selectionListener != null) {
try {
setHeartbeatReceived(true);
resetHeartbeatReceptionTime();
getSubscriber().subscribe(heartbeatTopic, getHeartbeatListener(), SQL_FILTER);
} catch (Exception e1) {
new LaserException("unable to subscribe to topic " + heartbeatTopic, e1);
}
}
}
use of cern.laser.client.LaserException in project ACS by ACS-Community.
the class HeartbeatHelper method getSubscriber.
private Subscriber getSubscriber() throws LaserException {
try {
if (cmwSubscriber == null) {
cmwSubscriber = PubSubFactory.subscriber();
cmwSubscriber.setExceptionListener(this);
}
} catch (Exception e) {
throw new LaserException("unable to create the CMW subscriber", e);
}
return cmwSubscriber;
}
use of cern.laser.client.LaserException in project ACS by ACS-Community.
the class AlarmSelectionHelper method setupCategorySubscriptions.
private Collection setupCategorySubscriptions(Selection selection, String sql_filter) throws LaserConnectionException, LaserException {
Category[] categories = selection.getCategorySelection().list();
Collection category_ids = new ArrayList(categories.length);
for (int i = 0; i < categories.length; i++) {
Category category = categories[i];
String topic = getCategoryRootTopic() + "." + category.getPath();
if (selectionListener != null) {
try {
getSubscriber().subscribe(topic, this, sql_filter);
} catch (Exception e1) {
new LaserException("unable to subscribe to topic " + topic, e1);
}
}
category_ids.add(category.getCategoryId());
}
return category_ids;
}
Aggregations