Search in sources :

Example 11 with LaserException

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) {
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) LaserDefinitionException(cern.laser.definition.LaserDefinitionException) LaserException(cern.laser.client.LaserException)

Example 12 with LaserException

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);
    }
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException)

Example 13 with LaserException

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);
        }
    }
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserHeartbeatException(cern.laser.client.services.selection.LaserHeartbeatException) LaserException(cern.laser.client.LaserException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserException(cern.laser.client.LaserException)

Example 14 with LaserException

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;
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserHeartbeatException(cern.laser.client.services.selection.LaserHeartbeatException) LaserException(cern.laser.client.LaserException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserException(cern.laser.client.LaserException)

Example 15 with LaserException

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;
}
Also used : Category(cern.laser.client.data.Category) ArrayList(java.util.ArrayList) Collection(java.util.Collection) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserTimeOutException(cern.laser.client.LaserTimeOutException) LaserException(cern.laser.client.LaserException)

Aggregations

LaserException (cern.laser.client.LaserException)15 LaserConnectionException (cern.laser.client.LaserConnectionException)13 MOMException (cern.cmw.mom.pubsub.MOMException)9 LaserTimeOutException (cern.laser.client.LaserTimeOutException)8 UnknownHostException (java.net.UnknownHostException)7 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)6 JMSException (javax.jms.JMSException)4 LaserSearchException (cern.laser.client.services.selection.LaserSearchException)3 AlarmImpl (cern.laser.client.impl.data.AlarmImpl)2 LaserHeartbeatException (cern.laser.client.services.selection.LaserHeartbeatException)2 Collection (java.util.Collection)2 Subscriber (cern.cmw.mom.pubsub.Subscriber)1 Category (cern.laser.client.data.Category)1 LaserDefinitionException (cern.laser.definition.LaserDefinitionException)1 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1