Search in sources :

Example 1 with InvalidPropertyException

use of jakarta.resource.spi.InvalidPropertyException in project openmq by eclipse-ee4j.

the class EndpointConsumer method checkSubscriptionScopeAndClientId.

protected void checkSubscriptionScopeAndClientId() throws NotSupportedException {
    if (aSpec.getSubscriptionScope() != null) {
        if (QUEUE.equals(aSpec.getDestinationType())) {
            NotSupportedException nse = new NotSupportedException("MQRA:EC:Error:Bad parameter");
            nse.initCause(new InvalidPropertyException(_lgrMID_EXC + "subscriptionScope must not be set if destinationType is " + QUEUE));
            throw nse;
        } else if (TOPIC.equals(aSpec.getDestinationType()) && clientId != null) {
            NotSupportedException nse = new NotSupportedException("MQRA:EC:Error:Bad parameter");
            nse.initCause(new InvalidPropertyException(_lgrMID_EXC + "clientId must not be set if subscriptionScope is set"));
            throw nse;
        }
    }
}
Also used : InvalidPropertyException(jakarta.resource.spi.InvalidPropertyException) NotSupportedException(jakarta.resource.NotSupportedException)

Example 2 with InvalidPropertyException

use of jakarta.resource.spi.InvalidPropertyException in project openmq by eclipse-ee4j.

the class CustomTokenizer method getStringDelimiterIndex.

/**
 * This method returns the index of the delimiter. It will factor out the escape and quote characters.
 *
 * @param strToken - string to token
 * @param delimiter - the delimiter to tokenize
 * @param fromIndex - the index to start the tokenize
 * @return index - index of the delimiter in the strToken
 * @throw CommandException if the end quote do not match.
 */
private int getStringDelimiterIndex(String strToken, String delimiter, int fromIndex) throws InvalidPropertyException {
    if (fromIndex > strToken.length() - 1)
        return -1;
    // get index of the delimiter
    final int hasDelimiter = strToken.indexOf(delimiter, fromIndex);
    // get index of the first quote in the string token
    final int quoteBeginIndex = strToken.indexOf(QUOTE_STRING, fromIndex);
    // if there's is a quote and a delimiter, then find the end quote
    if ((quoteBeginIndex != -1) && (hasDelimiter != -1) && (quoteBeginIndex < hasDelimiter)) {
        // get index of the end quote in the string token
        final int quoteEndIndex = strToken.indexOf(QUOTE_STRING, quoteBeginIndex + 1);
        if (quoteEndIndex == -1)
            throw new InvalidPropertyException("UnclosedString");
        if (quoteEndIndex != (strToken.length() - 1)) {
            return getStringDelimiterIndex(strToken, delimiter, quoteEndIndex + 1);
        } else {
            return -1;
        }
    }
    if ((hasDelimiter > 0) && (strToken.charAt(hasDelimiter - 1) == ESCAPE_CHAR)) {
        return getStringDelimiterIndex(strToken, delimiter, hasDelimiter + 1);
    } else {
        return hasDelimiter;
    }
}
Also used : InvalidPropertyException(jakarta.resource.spi.InvalidPropertyException)

Example 3 with InvalidPropertyException

use of jakarta.resource.spi.InvalidPropertyException in project openmq by eclipse-ee4j.

the class CustomTokenizer method populateList.

/**
 * this methos calls the getStringDelimiterIndex to determine the index of the delimiter and use that to populate the
 * tokenIterator.
 *
 * @param strToken - string to tokenize
 * @param delimiter - delimiter to tokenize the string
 * @return ListIterator
 */
private ListIterator populateList(String strToken, String delimiter) throws InvalidPropertyException {
    java.util.List tokenList = new java.util.Vector();
    int endIndex = getStringDelimiterIndex(strToken, delimiter, 0);
    if (endIndex == -1)
        tokenList.add(strToken);
    else {
        int beginIndex = 0;
        while (endIndex > -1) {
            // do not want to add to the list if the string is empty
            if (beginIndex != endIndex)
                tokenList.add(strToken.substring(beginIndex, endIndex));
            beginIndex = endIndex + 1;
            endIndex = getStringDelimiterIndex(strToken, delimiter, beginIndex);
        }
        // do not want to add to the list if the begindIndex is the last index
        if (beginIndex != strToken.length())
            tokenList.add(strToken.substring(beginIndex));
    }
    size = tokenList.size();
    try {
        return tokenList.listIterator();
    } catch (java.lang.IndexOutOfBoundsException ioe) {
        throw new InvalidPropertyException(ioe);
    }
}
Also used : InvalidPropertyException(jakarta.resource.spi.InvalidPropertyException)

Example 4 with InvalidPropertyException

use of jakarta.resource.spi.InvalidPropertyException in project openmq by eclipse-ee4j.

the class EndpointConsumer method setDestinationType.

/**
 * Sets destinationType from the ActivationSpec instance passed in and validates related configs
 */
private void setDestinationType() throws ResourceException {
    String destName = aSpec.getDestination();
    String destinationLookup = aSpec.getDestinationLookup();
    Object destObj = null;
    if (destinationLookup != null) {
        try {
            destObj = Util.jndiLookup(destinationLookup);
        } catch (NamingException e) {
            String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB for no JNDI name found";
            throw new ResourceException(errorMessage, e);
        }
        if (destObj != null) {
            if (destObj instanceof com.sun.messaging.Destination) {
                destName = ((com.sun.messaging.Destination) destObj).getName();
            } else {
                String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB, The JNDI object is required to be a Destination";
                throw new NotSupportedException(errorMessage);
            }
        } else {
            String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB for JNDI object is null";
            throw new NotSupportedException(errorMessage);
        }
    }
    try {
        if (destObj != null) {
            if (destObj instanceof com.sun.messaging.Queue) {
                if (aSpec._isDestTypeTopicSet())
                    throw new InvalidPropertyException("MQRA:EC:Inconsistent destinationType is set for destinationLookup " + destinationLookup);
                this.destination = new com.sun.messaging.Queue(destName);
                this.destinationType = ClientConstants.DESTINATION_TYPE_QUEUE;
            } else {
                if (destObj instanceof com.sun.messaging.Topic) {
                    if (aSpec._isDestTypeQueueSet())
                        throw new InvalidPropertyException("MQRA:EC:Inconsistent destinationType is set for destinationLookup " + destinationLookup);
                    this.destination = new com.sun.messaging.Topic(destName);
                    this.destinationType = ClientConstants.DESTINATION_TYPE_TOPIC;
                }
            }
        } else if (aSpec._isDestTypeQueueSet()) {
            this.destination = new com.sun.messaging.Queue(destName);
            this.destinationType = ClientConstants.DESTINATION_TYPE_QUEUE;
        } else {
            // destinationType is TOPIC by default
            this.destination = new com.sun.messaging.Topic(destName);
            this.destinationType = ClientConstants.DESTINATION_TYPE_TOPIC;
        }
    } catch (JMSException jmse) {
        String errorMessage;
        if (destName == null) {
            errorMessage = "MQRA:EC:No destination configured in ActivationSpec of MDB";
        } else {
            errorMessage = "MQRA:EC:Invalid destination " + destName + " configured in ActivationSpec of MDB";
        }
        NotSupportedException nse = new NotSupportedException(errorMessage);
        nse.initCause(jmse);
        throw nse;
    }
// XXX:Does MDB Deployment need physical dest to exist?
// If so need Admin API to check
// XXX:Can MDB depoyment handle destname as resource-ref vs. physical dest name?
// If so, need to handle in ActivationSpec (how will AS handle this?)
}
Also used : InvalidPropertyException(jakarta.resource.spi.InvalidPropertyException) NamingException(javax.naming.NamingException) ResourceException(jakarta.resource.ResourceException) NotSupportedException(jakarta.resource.NotSupportedException)

Aggregations

InvalidPropertyException (jakarta.resource.spi.InvalidPropertyException)4 NotSupportedException (jakarta.resource.NotSupportedException)2 ResourceException (jakarta.resource.ResourceException)1 NamingException (javax.naming.NamingException)1