Class AndesAdminService

java.lang.Object
org.wso2.carbon.core.AbstractAdmin
org.wso2.carbon.andes.admin.AndesAdminService

public class AndesAdminService extends org.wso2.carbon.core.AbstractAdmin
Provides all the andes admin services that is available through the UI(JSP).
  • Constructor Details

    • AndesAdminService

      public AndesAdminService()
  • Method Details

    • getQueueByName

      public Queue getQueueByName(String queueName) throws BrokerManagerAdminException
      Retrieve an Queue with the number of messages remaining in the database by passing a queue name
      Parameters:
      queueName - name of the queue
      Returns:
      org.wso2.carbon.andes.admin.internal.Queue if the queue exists, null if it doesn't exists
      Throws:
      BrokerManagerAdminException
    • getDLCQueue

      public Queue getDLCQueue() throws BrokerManagerAdminException
      Retrieve the DLC queue for the domain
      Returns:
      Queue with the number of messages in the dlc
      Throws:
      BrokerManagerAdminException
    • getAllQueues

      public Queue[] getAllQueues() throws BrokerManagerAdminException
      Gets all queues. Suppressing 'MismatchedQueryAndUpdateOfCollection' as 'allQueues' is used to sort and to convert to an array.
      Returns:
      An array of queues.
      Throws:
      BrokerManagerAdminException
    • getNamesOfAllDurableQueues

      public Set<String> getNamesOfAllDurableQueues() throws BrokerManagerAdminException
      Get a list of names of durable queues created in the broker
      Returns:
      a set of queue names
      Throws:
      BrokerManagerAdminException - on error while retrieving information
    • getMessageCount

      public long getMessageCount(String destinationName, String msgPattern) throws BrokerManagerAdminException
      Gets the message count for a queue Suppressing 'UnusedDeclaration' as it is called by webservice
      Parameters:
      destinationName - Destination name.
      msgPattern - Value should be either 'queue' or 'topic'.
      Returns:
      Message count.
      Throws:
      BrokerManagerAdminException
    • deleteQueue

      public void deleteQueue(String queueName) throws BrokerManagerAdminException
      Deletes a queue.
      Parameters:
      queueName - Queue name.
      Throws:
      BrokerManagerAdminException
    • deleteTopicFromRegistry

      public void deleteTopicFromRegistry(String topicName, String subscriptionId) throws BrokerManagerAdminException
      Delete topic related resources from registry
      Parameters:
      topicName - Topic Name
      subscriptionId - Subscription ID
      Throws:
      BrokerManagerAdminException
    • restoreSelectedMessagesFromDeadLetterChannel

      public long restoreSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String destinationQueueName) throws BrokerManagerAdminException
      Restore messages from the Dead Letter Queue to their original queues.
      Parameters:
      messageIDs - Browser Message Id / External Message Id list.
      destinationQueueName - Dead Letter Queue name for the respective tenant.
      Returns:
      unavailable message count
      Throws:
      BrokerManagerAdminException
    • rerouteSelectedMessagesFromDeadLetterChannel

      public long rerouteSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String newDestinationQueueName, String destinationQueueName) throws BrokerManagerAdminException
      Restore messages from the Dead Letter Queue to another queue in the same tenant.
      Parameters:
      messageIDs - Browser Message Id / External Message Id list.
      newDestinationQueueName - The new destination queue for the messages in the same tenant.
      destinationQueueName - Dead Letter Queue name for the respective tenant.
      Returns:
      unavailable message count
      Throws:
      BrokerManagerAdminException
    • deleteMessagesFromDeadLetterQueue

      public void deleteMessagesFromDeadLetterQueue(long[] messageIDs, String destinationQueueName) throws BrokerManagerAdminException
      Delete messages from the Dead Letter Queue and delete their content.
      Parameters:
      messageIDs - Browser Message Id / External Message Id list to be deleted.
      destinationQueueName - Dead Letter Queue name for the respective tenant.
      Throws:
      BrokerManagerAdminException
    • purgeMessagesOfQueue

      public void purgeMessagesOfQueue(String queueName) throws BrokerManagerAdminException
      Deletes all messages from a queue.
      Parameters:
      queueName - Queue name.
      Throws:
      BrokerManagerAdminException
    • closeSubscription

      public void closeSubscription(boolean isDurable, String subscriptionID, String subscribedQueueOrTopicName, String protocolType, String destinationType, String subscriberQueueName) throws BrokerManagerAdminException
      Close subscription defined by subscription ID forcibly
      Parameters:
      isDurable - is subscriber durable or not
      subscriptionID - ID of the subscription
      subscribedQueueOrTopicName - queue / topic name of the subscribed destination
      protocolType - The protocol type of the subscriptions to close
      destinationType - The destination type of the subscriptions to close
      subscriberQueueName - The bind queue of the subscriber
      Throws:
      BrokerManagerAdminException
    • getAllSubscriptions

      public Subscription[] getAllSubscriptions() throws BrokerManagerAdminException
      Gets all subscriptions. Suppressing 'MismatchedQueryAndUpdateOfCollection' as 'allSubscriptions' is used to convert to an array.
      Returns:
      An array of Subscription.
      Throws:
      BrokerManagerAdminException
    • getSubscriptions

      public Subscription[] getSubscriptions(String isDurable, String isActive, String protocolType, String destinationType) throws BrokerManagerAdminException
      Retrieve subscriptions matching the given criteria.
      Parameters:
      isDurable - Are the subscriptions to be retrieved durable (true/false)
      isActive - Are the subscriptions to be retrieved active (true/false/*, * meaning any)
      protocolType - The protocol type of the subscriptions to be retrieved
      destinationType - The destination type of the subscriptions to be retrieved
      Returns:
      The list of subscriptions matching the given criteria
      Throws:
      BrokerManagerAdminException
    • getFilteredSubscriptions

      public Subscription[] getFilteredSubscriptions(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId, int pageNumber, int subscriptionCountPerPage) throws BrokerManagerAdminException
      Retrieve subscriptions matching to the given search criteria.
      Parameters:
      isDurable - are the subscriptions to be retrieve durable (true/ false)
      isActive - are the subscriptions to be retrieved active (true/false)
      protocolType - the protocol type of the subscriptions to be retrieved
      destinationType - the destination type of the subscriptions to be retrieved
      filteredNamePattern - queue or topic name pattern to search the subscriptions ("" for all)
      isFilteredNameByExactMatch - exactly match the name or not
      identifierPattern - identifier pattern to search the subscriptions ("" for all)
      isIdentifierPatternByExactMatch - exactly match the identifier or not
      ownNodeId - node Id of the node which own the subscriptions
      pageNumber - page number in the pagination table
      subscriptionCountPerPage - number of subscriptions to be shown in the UI per page
      Returns:
      a list of subscriptions which match to the search criteria
      Throws:
      BrokerManagerAdminException - throws when an error occurs
    • getTotalSubscriptionCountForSearchResult

      public int getTotalSubscriptionCountForSearchResult(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId) throws BrokerManagerAdminException
      Returns the total subscription count relevant to a particular search criteria.
      Parameters:
      isDurable - are the subscriptions to be retrieve durable (true/ false)
      isActive - are the subscriptions to be retrieved active (true/false)
      protocolType - the protocol type of the subscriptions to be retrieved
      destinationType - the destination type of the subscriptions to be retrieved
      filteredNamePattern - queue or topic name pattern to search the subscriptions ("" for all)
      isFilteredNameByExactMatch - exactly match the name or not
      identifierPattern - identifier pattern to search the subscriptions ("" for all)
      isIdentifierPatternByExactMatch - exactly match the identifier or not
      ownNodeId - node Id of the node which own the subscriptions
      Returns:
      total subscription count matching to the given criteria
      Throws:
      BrokerManagerAdminException - hrows when an error occurs
    • getNumberOfMessagesInDLCForQueue

      public long getNumberOfMessagesInDLCForQueue(String queueName) throws BrokerManagerAdminException
      Gets the number of messages in DLC belonging to a specific queue.
      Parameters:
      queueName - The name of the queue.
      Returns:
      The number of messages.
      Throws:
      BrokerManagerAdminException
    • getMessagesInDLCForQueue

      public Message[] getMessagesInDLCForQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) throws BrokerManagerAdminException
      Gets the number of messages in DLC fora given queue name by start index and max messages count
      Parameters:
      queueName - Name of the queue
      nextMessageIdToRead - Start point of the queue message id to start reading
      maxMsgCount - Maximum messages from start index
      Returns:
      Array of Message
      Throws:
      BrokerManagerAdminException
    • updatePermission

      public void updatePermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) throws BrokerManagerAdminException
      Update the permission of the given queue name
      Parameters:
      queueName - Name of the queue
      queueRolePermissionsDTO - A QueueRolePermission
      Throws:
      BrokerManagerAdminException
    • addQueueAndAssignPermission

      public void addQueueAndAssignPermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) throws BrokerManagerAdminException
      Add a queue with the given name and assign permissions
      Parameters:
      queueName - Name of the queue
      queueRolePermissionsDTO - A QueueRolePermission
      Throws:
      BrokerManagerAdminException
    • getUserRoles

      public String[] getUserRoles() throws BrokerManagerAdminException
      Get roles of the current logged user If user has admin role, then all available roles will be return
      Returns:
      Array of user roles.
      Throws:
      BrokerManagerAdminException
    • getQueueRolePermission

      public QueueRolePermission[] getQueueRolePermission(String queueName) throws BrokerManagerAdminException
      Get all permission of the given queue name
      Parameters:
      queueName - Name of the queue
      Returns:
      Array of QueueRolePermission
      Throws:
      BrokerManagerAdminException
    • browseQueue

      public Message[] browseQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) throws BrokerManagerAdminException
      Browse the given queue name by start index and max messages count
      Parameters:
      queueName - Name of the queue
      nextMessageIdToRead - Start point of the queue message id to start reading
      maxMsgCount - Maximum messages from start index
      Returns:
      Array of Message
      Throws:
      BrokerManagerAdminException
    • getTotalMessagesInQueue

      public long getTotalMessagesInQueue(String queueName) throws BrokerManagerAdminException
      Total messages in the given queue
      Parameters:
      queueName - Name of the queue
      Returns:
      Total count of the messages
      Throws:
      BrokerManagerAdminException
    • sendMessage

      public boolean sendMessage(String queueName, String jmsType, String jmsCorrelationID, int numberOfMessages, String message, int deliveryMode, int priority, long expireTime) throws BrokerManagerAdminException
      Send messages to given queue
      Parameters:
      queueName - Name of the queue
      jmsType - JMS Type
      jmsCorrelationID - JMS Correlation Id
      numberOfMessages - Number of times
      message - Message content
      deliveryMode - Delivery mode
      priority - Message priority
      expireTime - Message expire time
      Returns:
      true if send message successful and false otherwise
      Throws:
      BrokerManagerAdminException
    • getMessageCountForSubscriber

      public int getMessageCountForSubscriber(String subscriptionID, boolean durable, String protocolType, String destinationType) throws BrokerManagerAdminException
      Gets the number of messages remaining for a subscriber.
      Parameters:
      subscriptionID - The subscription ID.
      durable - Whether the subscription is durable or not.
      protocolType - The protocol type which the subscription belongs to
      destinationType - The destination type which the subscription belongs to
      Returns:
      The number of remaining messages.
      Throws:
      BrokerManagerAdminException
    • getPendingMessageCount

      public long getPendingMessageCount(String queueName) throws BrokerManagerAdminException
      Get the pending message count for the specified subscription
      Parameters:
      queueName - queue name for which the pending message cound need to be calculated
      Returns:
      The pending message count for that subscription
      Throws:
      BrokerManagerAdminException
    • dumpMessageStatus

      public void dumpMessageStatus() throws BrokerManagerAdminException
      Invoke MBean operations and dump status of all messages. The file will be created inside [MB_HOME]/repository/logs
      Throws:
      BrokerManagerAdminException - on an issue creating/writing to file
    • checkCurrentUserHasPublishPermission

      public boolean checkCurrentUserHasPublishPermission(String queueName) throws BrokerManagerAdminException
      Check if current user is has publish permission for a queue. Suppressing "unused" warning as this is an API.
      Parameters:
      queueName - The name of the queue
      Returns:
      true if current user has publishing permissions, false otherwise.
      Throws:
      BrokerManagerAdminException
    • checkUserHasPublishPermission

      public boolean checkUserHasPublishPermission(String queueName, String userName) throws BrokerManagerAdminException
      Check if a user has publishing permission for a queue.
      Parameters:
      queueName - The name of the queue
      userName - The username of the user
      Returns:
      true if current user has publishing permissions, false otherwise.
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasAddQueuePermission

      public boolean checkCurrentUserHasAddQueuePermission() throws BrokerManagerAdminException
      Check if current user has add permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasAddQueuePermission

      public boolean checkUserHasAddQueuePermission(String username) throws BrokerManagerAdminException
      Check if given user has add permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasBrowseQueuePermission

      public boolean checkCurrentUserHasBrowseQueuePermission() throws BrokerManagerAdminException
      Check if current user has browse permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasBrowseQueuePermission

      public boolean checkUserHasBrowseQueuePermission(String username) throws BrokerManagerAdminException
      Check if given user has browse permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasDeleteQueuePermission

      public boolean checkCurrentUserHasDeleteQueuePermission() throws BrokerManagerAdminException
      Check if current user has delete permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasDeleteQueuePermission

      public boolean checkUserHasDeleteQueuePermission(String username) throws BrokerManagerAdminException
      Check if given user has delete permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasPurgeQueuePermission

      public boolean checkCurrentUserHasPurgeQueuePermission() throws BrokerManagerAdminException
      Check if current user has purge permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasPurgeQueuePermission

      public boolean checkUserHasPurgeQueuePermission(String username) throws BrokerManagerAdminException
      Check if given user has purge permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasBrowseMessagesInDLCPermission

      public boolean checkCurrentUserHasBrowseMessagesInDLCPermission() throws BrokerManagerAdminException
      Check if current user has browse messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasBrowseMessagesInDLCPermission

      public boolean checkUserHasBrowseMessagesInDLCPermission(String username) throws BrokerManagerAdminException
      Check if given user has browse messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasDeleteMessagesInDLCPermission

      public boolean checkCurrentUserHasDeleteMessagesInDLCPermission() throws BrokerManagerAdminException
      Check if current user has delete messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasDeleteMessagesInDLCPermission

      public boolean checkUserHasDeleteMessagesInDLCPermission(String username) throws BrokerManagerAdminException
      Check if given user has delete messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasRestoreMessagesInDLCPermission

      public boolean checkCurrentUserHasRestoreMessagesInDLCPermission() throws BrokerManagerAdminException
      Check if current user has restore messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasRestoreMessagesInDLCPermission

      public boolean checkUserHasRestoreMessagesInDLCPermission(String username) throws BrokerManagerAdminException
      Check if given user has restore messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasRerouteMessagesInDLCPermission

      public boolean checkCurrentUserHasRerouteMessagesInDLCPermission() throws BrokerManagerAdminException
      Check if current user has reroute messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkUserHasRerouteMessagesInDLCPermission

      public boolean checkUserHasRerouteMessagesInDLCPermission(String username) throws BrokerManagerAdminException
      Check if given user has reroute messages in dlc permission. This is global level permission. Usage of service is to control UI action.
      Parameters:
      username - username
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasQueueSubscriptionClosePermission

      public boolean checkCurrentUserHasQueueSubscriptionClosePermission() throws BrokerManagerAdminException
      Evaluate current logged in user has close subscription permission for queue subscriptions . This service mainly used to restrict UI control for un-authorize users
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException
    • checkCurrentUserHasTopicSubscriptionClosePermission

      public boolean checkCurrentUserHasTopicSubscriptionClosePermission() throws BrokerManagerAdminException
      Evaluate current logged in user has close subscription permission for topic subscriptions. This service mainly used to restrict UI control for un-authorize users
      Returns:
      true/false based on permission
      Throws:
      BrokerManagerAdminException - on an issue checking permission
    • getMessageMetadataInDeadLetterChannel

      public Message[] getMessageMetadataInDeadLetterChannel(String targetQueue, long startMessageId, int pageLimit) throws BrokerManagerAdminException
      Returns a paginated list of message metadata destined for the inputQueueName but currently living in the Dead Letter Channel.
      Parameters:
      targetQueue - Name of the destination queue
      startMessageId - Start point of the queue message id to start reading
      pageLimit - Maximum messages required in a single response
      Returns:
      Array of Message
      Throws:
      BrokerManagerAdminException - if an error occurs while invoking the MBean to fetch messages.
    • rerouteAllMessagesFromDeadLetterChannelForQueue

      public String rerouteAllMessagesFromDeadLetterChannelForQueue(String sourceQueue, String targetQueue, int internalBatchSize) throws BrokerManagerAdminException
      Move messages destined for the input sourceQueue into a different targetQueue. If the sourceQueue is DLCQueue, all messages in the DLC will be restored to the targetQueue.
      Parameters:
      sourceQueue - Name of the source queue
      targetQueue - Name of the target queue.
      internalBatchSize - even with this method, the MB server will internally read messages in DLC in batches, and simulate each batch as a new message list to the targetQueue. internalBatchSize controls the number of messages processed in a single batch internally.
      Returns:
      String message containing the number of messages that were restored.
      Throws:
      BrokerManagerAdminException