gets all messages from given Folder that match given criteria

@param qry
@param folder
@param uIds
@param messageNumbers
@param all
@param startrow
@param maxrows
@return
@return matching Messages
@throws MessagingException
347636
private Map<String, Message> getMessages(Query qry, Folder folder, String[] uids, String[] messageNumbers, int startRow, int maxRow, boolean all) throws MessagingException {

	Message[] messages = folder.getMessages();
	Map<String, Message> map = qry == null ? new HashMap<String, Message>() : null;
	int k = 0;
	if (uids != null || messageNumbers != null) {
	    startRow = 0;
	    maxRow = -1;
	}
	Message message;
	for (int l = startRow; l < messages.length; l++) {
	    if (maxRow != -1 && k == maxRow) {
		break;
	    }
	    message = messages[l];
	    int messageNumber = message.getMessageNumber();
	    String id = getId(folder, message);

	    if (uids == null ? messageNumbers == null || contains(messageNumbers, messageNumber) : contains(uids, id)) {
		k++;
		if (qry != null) {
		    toQuery(qry, message, id, all);
		}
		else map.put(id, message);
	    }
	}
	return map;
    }
782795
public Iterator<BaseMessageFilter> getFilterList(BaseMessageHeader messageHeader)
    {
        if (messageHeader == null)
            return super.getFilterList(messageHeader);  // ALL The filters
        return this.getRegistry().getFilterList(messageHeader);
    }
418007
public synchronized Message[] getByIds(final long start, final long end/* final Folder folder*/) {
        checkExists();
        final List<MockMessage> sms = new ArrayList<MockMessage>();
        int num = 0;

        MockMessage lastMsg = null;

        for (final MockMessage mockMessage : new TreeSet<MockMessage>(messages.values())) {

            lastMsg = mockMessage;

            if (end == UIDFolder.LASTUID) {
                if (getMessageCount() != 1 && mockMessage.getMockid() < start) { // TODO
                                                                                 // check?
                    continue;
                }
            } else {
                if (mockMessage.getMockid() < start || mockMessage.getMockid() > end) {
                    continue;
                }
            }

            mockMessage.setMessageNumber(++num);
            // mockMessage.setFolder(folder);
            sms.add(mockMessage);
        }

        if (end == UIDFolder.LASTUID && sms.size() == 0) {
            lastMsg.setMessageNumber(++num);
            // lastMsg.setFolder(folder);
            sms.add(lastMsg);
        }

        logger.debug("getByIds(" + start + "," + end + " for " + getFullName() + " returns " + sms.size());
        return sms.toArray(new Message[sms.size()]);
    }
1049125
private void getContent(Query query, Message message, int row) throws MessagingException, IOException {
	StringBuffer body = new StringBuffer();
	Struct cids = new StructImpl();
	query.setAtEL(CIDS, row, cids);
	if (message.isMimeType("text/plain")) {
	    String content = getConent(message);
	    query.setAtEL(TEXT_BODY, row, content);
	    body.append(content);
	}
	else if (message.isMimeType("text/html")) {
	    String content = getConent(message);
	    query.setAtEL(HTML_BODY, row, content);
	    body.append(content);
	}
	else {
	    Object content = message.getContent();
	    if (content instanceof MimeMultipart) {
		Array attachments = new ArrayImpl();
		Array attachmentFiles = new ArrayImpl();
		getMultiPart(query, row, attachments, attachmentFiles, cids, (MimeMultipart) content, body);

		if (attachments.size() > 0) {
		    try {
			query.setAtEL(ATTACHMENTS, row, ListUtil.arrayToList(attachments, "\t"));
		    }
		    catch (PageException pageexception) {}
		}
		if (attachmentFiles.size() > 0) {
		    try {
			query.setAtEL(ATTACHMENT_FILES, row, ListUtil.arrayToList(attachmentFiles, "\t"));
		    }
		    catch (PageException pageexception1) {}
		}

	    }
	}
	query.setAtEL(BODY, row, body.toString());
    }
54835
public boolean evaluateMessage(
    Selector selectorTree,
    Selector discriminatorTree,
    SIBusMessage msg)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "evaluateMessage", new Object[] { selectorTree, msg });

    boolean ret = false;
    Object result = null;
    boolean discriminatorMatches = true; //assume it does match

    // Use the dummy evaluation cache, we don't need one hear as we're not
    // searching the MatchSpace
    EvalCache cache = EvalCache.DUMMY;

    try
    {
      Evaluator evaluator = Matching.getEvaluator();
      //    See if we need to process a discriminator expression first
      if (discriminatorTree != null)
      {
        discriminatorMatches = false; //can no longer assume it does match
        String discriminator = msg.getDiscriminator();

        MatchSpaceKey msk = new DiscriminatorMatchSpaceKey(discriminator);
        // Evaluate message against selector tree
        result = evaluator.eval(discriminatorTree, msk, cache, null, false);
        if (result != null && ((Boolean) result).booleanValue())
        {
          discriminatorMatches = true;
        }
      }

      // Evaluate message against selector tree
      if (selectorTree != null && discriminatorMatches)
      {
        result =
          evaluator.eval(selectorTree, (MatchSpaceKey) msg, cache, null, false);
      }

    }
    catch (BadMessageFormatMatchingException qex)
    {
      FFDCFilter.processException(
        qex,
        "com.ibm.ws.sib.processor.matching.MessageProcessorMatching.evaluateMessage",
        "1:1824:1.117.1.11",
        this);

      SibTr.exception(tc, qex);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");

      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1834:1.117.1.11",
          qex });

      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1844:1.117.1.11",
            qex },
          null),
        qex);
    }

    // The result of expression evaluation can be either a
    // boolean, or not, which is interpreted as false.
    if (result instanceof Boolean)
    {
      // This turns a BooleanValue into a boolean
      // it will return false for unknown which is what we want.
      ret = ((Boolean) result).booleanValue();
    }
    else if (result == null)
    {
      ret = false;
    }
    else
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");
      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1870:1.117.1.11" });

      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1877:1.117.1.11" },
          null));
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", Boolean.valueOf(ret));
    return ret;
  }
736967
public byte[] querySm(int sequenceNumber, String messageId,
            byte sourceAddrTon, byte sourceAddrNpi, String sourceAddr)
            throws PDUStringException {
        StringValidator.validateString(messageId, StringParameter.MESSAGE_ID);
        StringValidator.validateString(sourceAddr, StringParameter.SOURCE_ADDR);

        PDUByteBuffer buf = new PDUByteBuffer(SMPPConstant.CID_QUERY_SM, 0,
                sequenceNumber);
        buf.append(messageId);
        buf.append(sourceAddrTon);
        buf.append(sourceAddrNpi);
        buf.append(sourceAddr);
        return buf.toBytes();
    }
93332
@Override
    public List<MessageHistory> getKeyHistory(String key, Long startTime, Long endTime, int count) throws MessageQueueException {
        List<MessageHistory> list = Lists.newArrayList();
        ColumnList<UUID> columns;
        try {
            columns = keyspace.prepareQuery(historyColumnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getRow(key)
                    .execute()
                    .getResult();
        } catch (ConnectionException e) {
            throw new MessageQueueException("Failed to load history for " + key, e);
        }

        for (Column<UUID> column : columns) {
            try {
                list.add(deserializeString(column.getStringValue(), MessageHistory.class));
            } catch (Exception e) {
                LOG.info("Error deserializing history entry", e);
            }
        }
        return list;
    }
1092813
public GetServiceStatusResult withMessages(Message... values) {
        List<Message> list = getMessages();
        for (Message value : values) {
            list.add(value);
        }
        return this;
    }
268309
public static void checkMessageId(int messageId, AisMessageType... messageTypes) {
		boolean found = false;
		for (AisMessageType messageType : messageTypes) {
			if (messageType.getId() == messageId)
				found = true;
		}
		if (!found) {
			StringBuffer s = new StringBuffer();
			for (AisMessageType messageType : messageTypes) {
				if (s.length() > 0)
					s.append(",");
				s.append(messageType.getId() + "");
			}
			checkArgument(found, "messageId must be in [" + s + "]  but was " + messageId);
		}
	}
1257512
void fetchAndStoreMessages(final boolean isMessageCenterForeground, final boolean showToast, @Nullable final MessageFetchListener listener) {
		checkConversationQueue();

		try {
			String lastMessageId = messageStore.getLastReceivedMessageId();
			fetchMessages(lastMessageId, new MessageFetchListener() {
				@Override
				public void onFetchFinish(MessageManager messageManager, List<ApptentiveMessage> messages) {
					try {
						if (messages == null || messages.size() == 0) return;

						CompoundMessage messageOnToast = null;
						ApptentiveLog.d(MESSAGES,"Messages retrieved: %d", messages.size());

						// Also get the count of incoming unread messages.
						int incomingUnreadMessages = 0;
						// Mark messages from server where sender is the app user as read.
						for (final ApptentiveMessage apptentiveMessage : messages) {
							if (apptentiveMessage.isOutgoingMessage()) {
								apptentiveMessage.setRead(true);
							} else {
								if (messageOnToast == null) {
									if (apptentiveMessage.getMessageType() == ApptentiveMessage.Type.CompoundMessage) {
										messageOnToast = (CompoundMessage) apptentiveMessage;
									}
								}
								incomingUnreadMessages++;

								// for every new message received, notify Message Center
								notifyInternalNewMessagesListeners((CompoundMessage) apptentiveMessage);
							}
						}
						messageStore.addOrUpdateMessages(messages.toArray(new ApptentiveMessage[messages.size()]));
						if (incomingUnreadMessages > 0) {
							// Show toast notification only if the foreground activity is not already message center activity
							if (!isMessageCenterForeground && showToast) {
								DispatchQueue.mainQueue().dispatchAsyncOnce(toastMessageNotifierTask.setMessage(messageOnToast));
							}
						}

						// Send message to notify host app, such as unread message badge
						conversationQueue().dispatchAsyncOnce(hostMessageNotifierTask.setMessageCount(getUnreadMessageCount()));
					} finally {
						if (listener != null) {
							listener.onFetchFinish(messageManager, messages);
						}
					}
				}
			});
		} catch (Exception e) {
			ApptentiveLog.e(MESSAGES, "Error retrieving last received message id from worker thread");
			logException(e);
		}
	}
1168744
public List<MessageDestinationType<WebAppType<T>>> getAllMessageDestination()
   {
      List<MessageDestinationType<WebAppType<T>>> list = new ArrayList<MessageDestinationType<WebAppType<T>>>();
      List<Node> nodeList = childNode.get("message-destination");
      for(Node node: nodeList)
      {
         MessageDestinationType<WebAppType<T>>  type = new MessageDestinationTypeImpl<WebAppType<T>>(this, "message-destination", childNode, node);
         list.add(type);
      }
      return list;
   }
614796
def get_messages(self, folderid="", stack=1, cursor=""):

        

        if self.standard_grant_type is not "authorization_code":
            raise DeviantartError("Authentication through Authorization Code (Grant Type) is required in order to connect to this endpoint.")

        response = self._req('/messages/feed', {
            'folderid' : folderid,
            'stack' : stack,
            'cursor' : cursor
        })

        messages = []

        for item in response['results']:

            m = Message()
            m.from_dict(item)

            messages.append(m)

        return {
            "results" : messages,
            "has_more" : response['has_more'],
            "cursor" : response['cursor']
        }
429353
@Override
    public IQueueMessage<ID, DATA> take() throws QueueException.EphemeralIsFull {
        if (!isEphemeralDisabled()) {
            int ephemeralMaxSize = getEphemeralMaxSize();
            if (ephemeralMaxSize > 0 && ephemeralStorage.size() >= ephemeralMaxSize) {
                throw new QueueException.EphemeralIsFull(ephemeralMaxSize);
            }
        }
        IQueueMessage<ID, DATA> msg = takeFromRingBuffer();
        if (msg != null && !isEphemeralDisabled()) {
            ephemeralStorage.putIfAbsent(msg.getId(), msg);
        }
        return msg;
    }
655728
public AbstractMessage browse( LocalQueueBrowserCursor cursor , MessageSelector selector ) throws JMSException
    {
    	// Reset cursor to last known position
    	cursor.reset();
    	
    	// Search in volatile store first
        if (volatileStore != null)
        {
            AbstractMessage msg = browseStore(volatileStore, cursor, selector);
            if (msg != null)
            {
            	cursor.move();
                return msg;
            }
        }
        
        // Then in persistent store
        if (persistentStore != null)
        {
        	AbstractMessage msg = browseStore(persistentStore, cursor, selector);
        	if (msg != null)
            {
            	cursor.move();
                return msg;
            }
        }
        
        // Nothing found, set EOQ flag on cursor 
        cursor.setEndOfQueueReached();
        
        return null;
    }
1005054
public SolrDocumentList runQuery(String q, List<String> fieldList,
			int results) throws SolrServerException {
		SolrQuery query = new SolrQuery();
		query.setQuery(escapeQuery(q));
		query.setRows(results);
		query.setFields(fieldList.toArray(new String[1]));
		QueryResponse rsp = server.query(query, METHOD.POST);
		return rsp.getResults();
	}
616887
public function get_message($uid, $folder = null)
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }

        // decode combined UID-folder identifier
        if (preg_match('/^\d+-.+/', $uid)) {
            list($uid, $folder) = explode('-', $uid, 2);
        }

        // Check internal cache
        if (!empty($this->icache['message'])) {
            if (($headers = $this->icache['message']) && $headers->uid == $uid) {
                return $headers;
            }
        }

        $headers = $this->get_message_headers($uid, $folder);

        // message doesn't exist?
        if (empty($headers)) {
            return null;
        }

        // structure might be cached
        if (!empty($headers->structure)) {
            return $headers;
        }

        $this->msg_uid = $uid;

        if (!$this->check_connection()) {
            return $headers;
        }

        if (empty($headers->bodystructure)) {
            $headers->bodystructure = $this->conn->getStructure($folder, $uid, true);
        }

        $structure = $headers->bodystructure;

        if (empty($structure)) {
            return $headers;
        }

        // set message charset from message headers
        if ($headers->charset) {
            $this->struct_charset = $headers->charset;
        }
        else {
            $this->struct_charset = $this->structure_charset($structure);
        }

        $headers->ctype = @strtolower($headers->ctype);

        // Here we can recognize malformed BODYSTRUCTURE and
        // 1. [@TODO] parse the message in other way to create our own message structure
        // 2. or just show the raw message body.
        // Example of structure for malformed MIME message:
        // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
        if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
            && strtolower($structure[0].'/'.$structure[1]) == 'text/plain'
        ) {
            // A special known case "Content-type: text" (#1488968)
            if ($headers->ctype == 'text') {
                $structure[1]   = 'plain';
                $headers->ctype = 'text/plain';
            }
            // we can handle single-part messages, by simple fix in structure (#1486898)
            else if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
                $structure[0] = $m[1];
                $structure[1] = $m[2];
            }
            else {
                // Try to parse the message using rcube_mime_decode.
                // We need a better solution, it parses message
                // in memory, which wouldn't work for very big messages,
                // (it uses up to 10x more memory than the message size)
                // it's also buggy and not actively developed
                if ($headers->size && rcube_utils::mem_check($headers->size * 10)) {
                    $raw_msg = $this->get_raw_body($uid);
                    $struct = rcube_mime::parse_message($raw_msg);
                }
                else {
                    return $headers;
                }
            }
        }

        if (empty($struct)) {
            $struct = $this->structure_part($structure, 0, '', $headers);
        }

        // some workarounds on simple messages...
        if (empty($struct->parts)) {
            // ...don't trust given content-type
            if (!empty($headers->ctype)) {
                $struct->mime_id  = '1';
                $struct->mimetype = strtolower($headers->ctype);
                list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
            }

            // ...and charset (there's a case described in #1488968 where invalid content-type
            // results in invalid charset in BODYSTRUCTURE)
            if (!empty($headers->charset) && $headers->charset != $struct->ctype_parameters['charset']) {
                $struct->charset                     = $headers->charset;
                $struct->ctype_parameters['charset'] = $headers->charset;
            }
        }

        $headers->structure = $struct;

        return $this->icache['message'] = $headers;
    }
353327
public static ResourceList<Message> list(final BandwidthClient client, final int page, final int size) throws Exception {
    	
        final String messageUri = client.getUserResourceUri(BandwidthConstants.MESSAGES_URI_PATH);

        final ResourceList<Message> messages = 
        			new ResourceList<Message>(page, size, messageUri, Message.class);

        messages.setClient(client);
        messages.initialize();
        
        return messages;
    }