Package plugins.Freetalk

Examples of plugins.Freetalk.Message


       
      // ... and that it is in the correct position
      assertEquals(expectedThreadID, threadRef.getThreadID());
     
      // Verify that the thread Message object exists if it should.
      Message thread;
      try {
        thread = threadRef.getMessage();
        assertTrue(mFetchedStates.get(expectedThreadID));
      } catch(MessageNotFetchedException e) {
        thread = null;
        assertFalse(mFetchedStates.get(expectedThreadID));
      }
     
      // Verify the replies of the thread
     
      LinkedList<String> expectedRepliesList = mReplies.get(threadRef.getThreadID());
      if(expectedRepliesList == null)
        expectedRepliesList = new LinkedList<String>();
      final Iterator<String> expectedReplies = expectedRepliesList.iterator();
     
      for(final BoardMessageLink replyRef : mSubscribedBoard.getAllThreadReplies(threadRef.getThreadID(), true)) {
        assertTrue(expectedReplies.hasNext());
       
        try {
          final String expectedReplyID = expectedReplies.next();
         
          assertEquals(expectedReplyID, replyRef.getMessageID());
          assertEquals(threadRef.getThreadID(), replyRef.getThreadID());
         
          // Verify that the Message object exists if it should
          Message reply;
          try {
            reply = replyRef.getMessage();
            assertTrue(mFetchedStates.get(expectedReplyID));
          } catch(MessageNotFetchedException e) {
            reply = null;
            try {
              Message ignoredRealReply = mMessageManager.get(expectedReplyID);
              // The reply was NOT set on this reply link because it does not belong to this thread...
              try {
                assertFalse(ignoredRealReply.getThreadID().equals(threadRef.getThreadID()));
              } catch(NoSuchMessageException e2) { // is a thread itself
                // BoardReplyLinks should NOT be created if the parent is the thread itself
                assertFalse(ignoredRealReply.getID().equals(threadRef.getThreadID()));
              }
            } catch(NoSuchMessageException e3) {
              assertFalse(mFetchedStates.get(expectedReplyID));
            }
          }
         
          Message replyParent;
         
          if(reply != null) {
            assertFalse(reply.isThread());
            assertEquals(expectedReplyID, reply.getID());
            assertEquals(expectedThreadID, reply.getThreadID());
           
            try {
              assertEquals(thread, reply.getThread());
            } catch(NoSuchMessageException e) {
              assertNull(thread);
            }
         
            final String replyParentID = reply.getParentID();
         
            try {
              replyParent = reply.getParent();
              assertTrue(mFetchedStates.get(replyParentID));
            } catch(NoSuchMessageException e) {
              replyParent = null;
              assertFalse(mFetchedStates.get(replyParentID));
            }
          } else {
            replyParent = null;
          }
         
          // We do not specify the parent message for some test messages, check whether its assigned correctly
         
          if(replyParent != null) {
            assertEquals(reply.getParentID(), replyParent.getID());
            if(reply.getParentID().equals(expectedThreadID)) {
              assertEquals(thread, replyParent);
            }
          }
        } catch(MessageNotFetchedException e) {
View Full Code Here


  public void testDecode() throws Exception {
    System.gc(); db.purge(); System.gc();
   
    ByteArrayInputStream is = new ByteArrayInputStream(mHardcodedEncodedMessage.getBytes("UTF-8"));
    ByteArrayOutputStream decodedAndEncodedMessage = new ByteArrayOutputStream(4096);
    Message decodedMessage = mXML.decode(mFreetalk, is, (WoTMessageList)mMessageManager.getMessageList(mMessageListID), mMessageFreenetURI);
    decodedMessage.initializeTransient(mFreetalk);
    mXML.encode(decodedMessage, decodedAndEncodedMessage);   
   
    assertEquals(mHardcodedEncodedMessage, decodedAndEncodedMessage.toString().replace("\r\n", "\n"));
  }
View Full Code Here

              // Mark as unread first, then display
              if(mMarktThreadAsUnread)
              mThread.markThreadAndRepliesAsUnreadAndCommit();
          
              try {
                Message threadMessage = mThread.getMessage();
               
                if(threadMessage.isThread() == false)
                  addThreadIsNoThreadWarning(threadMessage);
                else if(mBoard.contains(threadMessage) == false) // Do "else", one link to the original thread is enough.
                  addThreadBelongsToDifferentBoardWarning(threadMessage);

                addMessageBox(threadMessage, mThread);
View Full Code Here

   * @param board
   * @param firstMessageInThread The thread itself if it was downloaded already, if not, the first reply
   * @param threadID
   */
  public static void addBreadcrumb(BreadcrumbTrail trail, SubscribedBoard board, BoardThreadLink myThread) {
    Message firstMessage = null;

    try {
      firstMessage = myThread.getMessage();
    }
    catch (MessageNotFetchedException e) { // The thread was not downloaded yet, we use it's first reply for obtaining the information in the breadcrumb
      synchronized(board) {
      for(BoardReplyLink ref : board.getAllThreadReplies(myThread.getThreadID(), true)) {
        try  {
          firstMessage = ref.getMessage();
          break;
        } catch(MessageNotFetchedException e1) { }
      }
      }
    }

    if(firstMessage == null)
      throw new RuntimeException("Thread neither has a thread message nor any replies: " + myThread);

    trail.addBreadcrumbInfo(maxLength(firstMessage.getTitle(), 30), getURI(board, myThread));
  }
View Full Code Here

                public FreetalkNNTPArticle next() {
                    if (!hasNext())
                        throw new NoSuchElementException();
                    else {
                        Message msg = currentMessage;
                        currentMessage = null;
                        return new FreetalkNNTPArticle(msg, currentIndex++);
                    }
                }
View Full Code Here

    synchronized(mMessageManager) {
    try {
      list = (WoTMessageList)mMessageManager.getMessageList(messageListID);
      bucket = result.asBucket();
      inputStream = bucket.getInputStream();
      Message message = mXML.decode(mFreetalk, inputStream, list, state.getURI());
      mMessageManager.onMessageReceived(message);
     
      fetchMoreMessages = true;
    }
    catch (NoSuchMessageListException e) {
View Full Code Here

                sfs.putOverwrite("ID", threadReference.getThreadID());
                sfs.put("ReplyCount", board.threadReplyCount(threadReference.getThreadID()));
                sfs.put("LastReplyDate", threadReference.getLastReplyDate().getTime());
               
                try {
                final Message thread = threadReference.getMessage();
                  sfs.putOverwrite("Title", thread.getTitle());
                  sfs.putOverwrite("Author", thread.getAuthor().getFreetalkAddress());
                  sfs.put("Date", thread.getDate().getTime());
                  sfs.put("FetchDate", thread.getFetchDate().getTime());
                  sfs.put("IsThread", thread.isThread());
                }
                catch(MessageNotFetchedException e) {
                  // The thread was not downloaded yet.
                  // TODO: Add guesses for title and author ID.
                  // Title guess = title of first reply. See BoardPage for how to obtain.
View Full Code Here

        synchronized(board) {

          final BoardThreadLink threadLink = board.getThreadLink(threadID);
            final Iterable<BoardReplyLink> messageRefList;
            final Message thread = mFreetalk.getMessageManager().get(threadID); // throws exception when not found
            {
                // send thread root message
                sendSingleMessage(replysender, thread, threadLink.getIndex(), includeMessageText);
            }

            messageRefList = board.getAllThreadReplies(thread.getID(), sortByMessageDateAscending);

            // send all messages of thread
            for(final BoardMessageLink reference : messageRefList) {
              try {
                final Message msg = reference.getMessage();
                sendSingleMessage(replysender, msg, reference.getIndex(), includeMessageText);
              }
              catch(MessageNotFetchedException e) {
                // Ignore
              }
View Full Code Here

        //throws exception when not found
        final SubscribedBoard board = mFreetalk.getMessageManager().getSubscription(mFreetalk.getIdentityManager().getOwnIdentity(ownIdentityID), boardName);
       
        final BoardMessageLink reference = board.getMessageByIndex(messageIndex); // throws exception when not found
       
        final Message message = reference.getMessage()// throws MessageNotFetchedException

        sendSingleMessage(replysender, message, messageIndex, includeMessageText);
    }
View Full Code Here

              // and you can link replies into multiple threads by replying to them with different thread URIs... so if there is only a parent URI and
              // no thread URI we cannot decide to which thread the message belongs because the parent might belong to multiple threads.
             
                // evaluate parentThread
                final String parentThreadID = params.get("ParentThreadID"); // may be null
                final Message parentThread;
                if(parentThreadID != null) {
                    try {
                        parentThread = mFreetalk.getMessageManager().get(parentThreadID);
                    } catch(final NoSuchMessageException e) {
                        throw new InvalidParameterException("Message specified by ParentThreadID was not found.");
                    }
                } else {
                  parentThread = null;
                }
               
                // evaluate parentMessage
                final String parentMsgId = params.get("ParentID"); // may be null
                final Message parentMessage;
                if (parentMsgId != null) {
                    try {
                        parentMessage = mFreetalk.getMessageManager().get(parentMsgId);
                    } catch(final NoSuchMessageException e) {
                        throw new InvalidParameterException("Message specified by ParentID was not found");
View Full Code Here

TOP

Related Classes of plugins.Freetalk.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.