Search in sources :

Example 1 with LaserException

use of cern.laser.client.LaserException in project ACS by ACS-Community.

the class AlarmSelectionHelper method subscribe.

//
// -- PUBLIC METHODS ----------------------------------------------
//
public Map subscribe(Selection selection) throws LaserConnectionException, LaserException, LaserTimeOutException {
    String sql_filter = buildSQLFilter(selection);
    Collection category_ids = setupCategorySubscriptions(selection, sql_filter);
    // start init subscription
    setInitialized(false);
    String console_id = "";
    String host_name = "";
    try {
        console_id = UUIDGenerator.getInstance().getUUID().toString();
        host_name = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        throw new LaserException("unable to get a unique id for the console", e);
    }
    String init_topic = getClientRootTopic() + "." + console_id;
    String init_sql_filter = buildInitSQLFilter(sql_filter);
    long init_subscription;
    try {
        init_subscription = getSubscriber().subscribe(init_topic, getInitialSelectionListener(), init_sql_filter);
    } catch (Exception e) {
        LOGGER.error("unable to subscribe to topic " + init_topic, e);
        throw new LaserException("unable to subscribe to topic " + init_topic, e);
    }
    try {
        if (m_laser != null) {
            int[] cis = new int[category_ids.size()];
            int pos = 0;
            for (Iterator iter = category_ids.iterator(); iter.hasNext(); ) {
                cis[pos++] = ((Integer) iter.next()).intValue();
            }
            m_laser.select(cis, console_id);
        } else {
            throw new NullPointerException("AlarmSystem component is null");
        }
    } catch (alma.alarmsystem.LaserProcessingException lpe) {
        try {
            getSubscriber().unSubscribe(init_subscription);
        } catch (JMSException e1) {
        // Intentionally left blank
        } catch (LaserException e1) {
        // Intentionally left blank
        }
        LOGGER.error("server is initializing");
        throw new LaserConnectionException("server is initializing", lpe);
    } catch (Exception e3) {
        throw new LaserException("unable to perform initial selection at host " + host_name, e3);
    }
    resetInitWaitTime();
    waitForInit();
    try {
        // stop init subscription
        getSubscriber().unSubscribe(init_subscription);
    } catch (Exception e) {
        LOGGER.info("exception when unsubscribing", e);
    }
    if (isInitialized()) {
        return getInitialSelection();
    } else {
    //throw new LaserTimeOutException("initial selection timed out");
    }
    return getInitialSelection();
}
Also used : UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) LaserConnectionException(cern.laser.client.LaserConnectionException) 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) Iterator(java.util.Iterator) Collection(java.util.Collection) LaserException(cern.laser.client.LaserException)

Example 2 with LaserException

use of cern.laser.client.LaserException in project ACS by ACS-Community.

the class AlarmSelectionHelper method resetSelection.

public void resetSelection() throws LaserException {
    try {
        Subscriber subscriber = getSubscriber();
        subscriber.unSubscribeAll();
    } catch (Exception e) {
        throw new LaserException("unable to unsubscribe all");
    }
    if (cmwSubscriber != null) {
        cmwSubscriber.close();
    //      cmwSubscriber = null;
    }
}
Also used : Subscriber(cern.cmw.mom.pubsub.Subscriber) 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)

Example 3 with LaserException

use of cern.laser.client.LaserException in project ACS by ACS-Community.

the class AlarmSelectionHelper 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) 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)

Example 4 with LaserException

use of cern.laser.client.LaserException in project ACS by ACS-Community.

the class FilterImpl method validate.

public void validate() throws LaserException {
    if (property == null) {
        throw new LaserException("property is null");
    }
    if (operator == null) {
        throw new LaserException("operator is null");
    }
    if (value == null) {
        throw new LaserException("value is null");
    }
    if (!(Arrays.asList(privateOperators).contains(operator))) {
        throw new LaserException("operator expected, found : " + operator);
    }
    if (isNumeric()) {
        if (!(Arrays.asList(numericOperators).contains(operator))) {
            throw new LaserException("numeric operator expected, found : " + operator);
        }
        if (isInteger()) {
            try {
                Integer.valueOf(value);
            } catch (Exception e) {
                throw new LaserException("integer value expected, found : " + value);
            }
        }
        if (isLong()) {
            try {
                Long.valueOf(value);
            } catch (Exception e) {
                throw new LaserException("long value expected, found : " + value);
            }
        }
        if (isFloat()) {
            try {
                Float.valueOf(value);
            } catch (Exception e) {
                throw new LaserException("float value expected, found : " + value);
            }
        }
        if (isDouble()) {
            try {
                Double.valueOf(value);
            } catch (Exception e) {
                throw new LaserException("double value expected, found : " + value);
            }
        }
        if (isShort()) {
            try {
                Short.valueOf(value);
            } catch (Exception e) {
                throw new LaserException("short value expected, found : " + value);
            }
        }
    } else if (isBoolean()) {
        if ((!value.equalsIgnoreCase("TRUE")) && (!value.equalsIgnoreCase("FALSE"))) {
            throw new LaserException("boolean value expected, found : " + value);
        }
    } else if (isByte()) {
        if (!(Arrays.asList(byteOperators).contains(operator))) {
            throw new LaserException("byte operator expected, found : " + operator);
        }
        try {
            Byte.valueOf(value);
        } catch (Exception e) {
            throw new LaserException("byte value expected, found : " + value);
        }
    } else if (!(Arrays.asList(literalOperators).contains(operator))) {
        throw new LaserException("literal operator expected, found : " + operator);
    }
    if (operator.equals(LIKE_OPERATOR)) {
        int index = value.indexOf("%");
        if (index == -1) {
            throw new LaserException("% expected");
        }
        int last_index = value.lastIndexOf("%");
        if (!multiplePercentAllowed && index != last_index) {
            throw new LaserException("only one occourence of % allowed");
        }
    }
}
Also used : LaserException(cern.laser.client.LaserException) LaserException(cern.laser.client.LaserException)

Example 5 with LaserException

use of cern.laser.client.LaserException in project ACS by ACS-Community.

the class AlarmSearchHelper method resetSelection.

public void resetSelection() throws LaserException {
    try {
        getSubscriber().unSubscribeAll();
    } catch (Exception e) {
        throw new LaserException("unable to unsubscribe all");
    }
    if (cmwSubscriber != null) {
        cmwSubscriber.close();
        cmwSubscriber = null;
    }
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserSearchException(cern.laser.client.services.selection.LaserSearchException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) MOMException(cern.cmw.mom.pubsub.MOMException) 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