Examples of InboundMessage


Examples of org.gsm.oneapi.responsebean.mms.InboundMessage

          new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "messageId", messageId),
          new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_JSON, "resFormat", resFormat),
      };

      if (checkRequestParameters(response, rules)) {     
        InboundMessage inboundMessage=new InboundMessage();
        java.util.Date message1DT=makeUTCDateTime(2010, Calendar.NOVEMBER, 19, 12, 0, 0);
        inboundMessage.setDateTimeAsDate(message1DT);
        inboundMessage.setDestinationAddress("6789");
        String messageId1="msg1";
        inboundMessage.setMessageId(messageId1);
        InboundMMSMessage inboundMMSMessage=new InboundMMSMessage();
        inboundMMSMessage.setSubject("Rock Festival 2010");
        inboundMMSMessage.setMessage("Making the somewhat shorter journey from Brighton, homegrown heroes Architects make their first festival appearance in this country in support of new album 'The Here And Now', which was released one week ago today. Never has an album been more aptly titled, with the band currently on the cover of Metal Hammer magazine while their latest single enjoys daytime play on national radio, and the album receives rave reviews across the rock media, earning it a top 75 chart position (57) in its first week. Frontman Sam Carter enthuses:");
        inboundMessage.setInboundMMSMessage(inboundMMSMessage);
       
        String resourceURL1=getRequestHostnameAndContext(request)+request.getServletPath()+"/1/messaging/inbound/registrations/"+urlEncode(registrationId)+"/messages/"+urlEncode(messageId1);
        inboundMessage.setResourceURL(resourceURL1);
        inboundMessage.setSenderAddress("tel:+1234567");

        ObjectMapper mapper=new ObjectMapper();     
        String jsonResponse="{\"inboundMessage\":"+mapper.writeValueAsString(inboundMessage)+"}";
       
        System.out.println("JSON section=\n"+jsonResponse);
View Full Code Here

Examples of org.gsm.oneapi.responsebean.mms.InboundMessage

        inboundMessageList.setResourceURL(resourceURL);
       
        java.util.Date message1DT=makeUTCDateTime(2009, Calendar.NOVEMBER, 19, 12, 0, 0);
        String messageId1="msg1";
        String resourceURL1=getRequestHostnameAndContext(request)+request.getServletPath()+"/1/messaging/inbound/registrations/"+urlEncode(registrationId)+"/messages/"+urlEncode(messageId1);
        InboundMessage message1=new InboundMessage(message1DT, "3456", messageId1, resourceURL1, "+447825123456");
        message1.setInboundMMSMessage(new InboundMMSMessage("Msg 1 subject", null));
       
       
        java.util.Date message2DT=makeUTCDateTime(2009, Calendar.NOVEMBER, 19, 14, 30, 25);
        String messageId2="msg2";
        String resourceURL2=getRequestHostnameAndContext(request)+request.getServletPath()+"/1/messaging/inbound/registrations/"+urlEncode(registrationId)+"/messages/"+urlEncode(messageId2);
        InboundMessage message2=new InboundMessage(message2DT, "3456", messageId2, resourceURL2, "+447825789123");
        message2.setInboundMMSMessage(new InboundMMSMessage("Msg 2 subject", null));
       
        if (maxBatchSize==1) {
          InboundMessage[] messages={message1};
          inboundMessageList.setNumberOfMessagesInThisBatch(1);
          inboundMessageList.setInboundMessage(messages);
View Full Code Here

Examples of org.smslib.InboundMessage

  }

  InboundMessage generateIncomingMessage()
  {
    incInboundMessageCount();
    InboundMessage msg = new InboundMessage(new java.util.Date(), "+1234567890", "Hello World! #" + getInboundMessageCount(), 0, null);
    msg.setGatewayId(this.getGatewayId());
    return msg;
  }
View Full Code Here

Examples of org.smslib.InboundMessage

    int i, j, memIndex;
    int limit = (myLimit < 0 ? 0 : myLimit);
    String response, line, tmpLine, msgText, originator, dateStr, refNo;
    BufferedReader reader;
    StringTokenizer tokens;
    InboundMessage msg;
    Calendar cal1 = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    for (int ml = 0; ml < (getATHandler().getStorageLocations().length() / 2); ml++)
    {
      if (getATHandler().switchStorageLocation(getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2)))
      {
        response = getATHandler().listMessages(msgClass);
        response = response.replaceAll("\\s+OK\\s+", "\nOK");
        reader = new BufferedReader(new StringReader(response));
        for (;;)
        {
          line = reader.readLine();
          if (line == null) break;
          line = line.trim();
          if (line.length() > 0) break;
        }
        while (true)
        {
          if (line == null) break;
          if (line.length() <= 0 || line.equalsIgnoreCase("OK")) break;
          i = line.indexOf(':');
          j = line.indexOf(',');
          memIndex = 0;
          try
          {
            memIndex = Integer.parseInt(line.substring(i + 1, j).trim());
          }
          catch (NumberFormatException e)
          {
            // TODO: What to do here?
            Logger.getInstance().logWarn("Incorrect Memory Index number parsed!", e, getGatewayId());
          }
          tokens = new StringTokenizer(line, ",");
          tokens.nextToken();
          tokens.nextToken();
          tmpLine = "";
          if (Character.isDigit(tokens.nextToken().trim().charAt(0)))
          {
            line = line.replaceAll(",,", ", ,");
            tokens = new StringTokenizer(line, ",");
            tokens.nextToken();
            tokens.nextToken();
            tokens.nextToken();
            refNo = tokens.nextToken();
            tokens.nextToken();
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal1.set(Calendar.YEAR, 2000 + Integer.parseInt(dateStr.substring(0, 2)));
            cal1.set(Calendar.MONTH, Integer.parseInt(dateStr.substring(3, 5)) - 1);
            cal1.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStr.substring(6, 8)));
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal1.set(Calendar.HOUR_OF_DAY, Integer.parseInt(dateStr.substring(0, 2)));
            cal1.set(Calendar.MINUTE, Integer.parseInt(dateStr.substring(3, 5)));
            cal1.set(Calendar.SECOND, Integer.parseInt(dateStr.substring(6, 8)));
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal2.set(Calendar.YEAR, 2000 + Integer.parseInt(dateStr.substring(0, 2)));
            cal2.set(Calendar.MONTH, Integer.parseInt(dateStr.substring(3, 5)) - 1);
            cal2.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStr.substring(6, 8)));
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal2.set(Calendar.HOUR_OF_DAY, Integer.parseInt(dateStr.substring(0, 2)));
            cal2.set(Calendar.MINUTE, Integer.parseInt(dateStr.substring(3, 5)));
            cal2.set(Calendar.SECOND, Integer.parseInt(dateStr.substring(6, 8)));
            msg = new StatusReportMessage(refNo, memIndex, getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2), cal1.getTime(), cal2.getTime());
            msg.setGatewayId(getGatewayId());
            Logger.getInstance().logDebug("IN-DTLS: MI:" + msg.getMemIndex(), null, getGatewayId());
            msgList.add(msg);
            incInboundMessageCount();
          }
          else
          {
            line = line.replaceAll(",,", ", ,");
            tokens = new StringTokenizer(line, ",");
            tokens.nextToken();
            tokens.nextToken();
            originator = tokens.nextToken().replaceAll("\"", "");
            tokens.nextToken();
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal1.set(Calendar.YEAR, 2000 + Integer.parseInt(dateStr.substring(0, 2)));
            cal1.set(Calendar.MONTH, Integer.parseInt(dateStr.substring(3, 5)) - 1);
            cal1.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStr.substring(6, 8)));
            dateStr = tokens.nextToken().replaceAll("\"", "");
            cal1.set(Calendar.HOUR_OF_DAY, Integer.parseInt(dateStr.substring(0, 2)));
            cal1.set(Calendar.MINUTE, Integer.parseInt(dateStr.substring(3, 5)));
            cal1.set(Calendar.SECOND, Integer.parseInt(dateStr.substring(6, 8)));
            msgText = "";
            while (true)
            {
              tmpLine = reader.readLine();
              if (tmpLine == null) break;
              if (tmpLine.startsWith("+CMGL")) break;
              if (tmpLine.startsWith("+CMGR")) break;
              msgText += (msgText.length() == 0 ? "" : "\n") + tmpLine;
            }
            msgText = msgText.trim();
            msg = new InboundMessage(cal1.getTime(), originator, msgText, memIndex, getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2));
            msg.setGatewayId(getGatewayId());
            Logger.getInstance().logDebug("IN-DTLS: MI:" + msg.getMemIndex(), null, getGatewayId());
            msgList.add(msg);
            incInboundMessageCount();
          }
          while (true)
          {
View Full Code Here

Examples of org.smslib.InboundMessage

            //       if the message is invalid, the message should
            //       be ignored and but logged
            if (pdu instanceof SmsDeliveryPdu)
            {
              Logger.getInstance().logDebug(pdu.toString(), null, getGatewayId());
              InboundMessage msg;
              String memLocation = getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2);
              if (pdu.isBinary())
              {
                msg = new InboundBinaryMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
                if (Service.getInstance().getKeyManager().getKey(msg.getOriginator()) != null) msg = new InboundEncryptedMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              else
              {
                msg = new InboundMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              msg.setGatewayId(getGatewayId());
              Logger.getInstance().logDebug("IN-DTLS: MI:" + msg.getMemIndex() + " REF:" + msg.getMpRefNo() + " MAX:" + msg.getMpMaxNo() + " SEQ:" + msg.getMpSeqNo(), null, getGatewayId());
              if (msg.getMpRefNo() == 0)
              {
                // single message
                msgList.add(msg);
                incInboundMessageCount();
              }
              else
              {
                // multi-part message
                int k, l;
                List<InboundMessage> tmpList;
                InboundMessage listMsg;
                boolean found, duplicate;
                found = false;
                for (k = 0; k < this.mpMsgList.size(); k++)
                {
                  // List of List<InboundMessage>
                  tmpList = this.mpMsgList.get(k);
                  listMsg = tmpList.get(0);
                  // check if current message list is for this message
                  if (listMsg.getMpRefNo() == msg.getMpRefNo())
                  {
                    duplicate = false;
                    // check if the message is already in the message list
                    for (l = 0; l < tmpList.size(); l++)
                    {
                      listMsg = tmpList.get(l);
                      if (listMsg.getMpSeqNo() == msg.getMpSeqNo())
                      {
                        duplicate = true;
                        break;
                      }
                    }
View Full Code Here

Examples of org.smslib.InboundMessage

  private void checkMpMsgList(Collection<InboundMessage> msgList) throws TimeoutException, GatewayException, IOException, InterruptedException
  {
    int k, l, m;
    List<InboundMessage> tmpList;
    InboundMessage listMsg, mpMsg;
    boolean found;
    mpMsg = null;
    Logger.getInstance().logDebug("CheckMpMsgList(): MAINLIST: " + this.mpMsgList.size(), null, getGatewayId());
    for (k = 0; k < this.mpMsgList.size(); k++)
    {
      tmpList = this.mpMsgList.get(k);
      Logger.getInstance().logDebug("CheckMpMsgList(): SUBLIST[" + k + "]: " + tmpList.size(), null, getGatewayId());
      listMsg = tmpList.get(0);
      found = false;
      if (listMsg.getMpMaxNo() == tmpList.size())
      {
        found = true;
        for (l = 0; l < tmpList.size(); l++)
          for (m = 0; m < tmpList.size(); m++)
          {
            listMsg = tmpList.get(m);
            if (listMsg.getMpSeqNo() == (l + 1))
            {
              if (listMsg.getMpSeqNo() == 1)
              {
                mpMsg = listMsg;
                mpMsg.setMpMemIndex(mpMsg.getMemIndex());
                if (listMsg.getMpMaxNo() == 1)
                {
                  msgList.add(mpMsg);
                  incInboundMessageCount();
                }
              }
              else
              {
                if (mpMsg != null)
                {
                  if (mpMsg instanceof InboundBinaryMessage)
                  {
                    InboundBinaryMessage mpMsgBinary = (InboundBinaryMessage) mpMsg;
                    InboundBinaryMessage listMsgBinary = (InboundBinaryMessage) listMsg;
                    mpMsgBinary.addDataBytes(listMsgBinary.getDataBytes());
                  }
                  else
                  {
                    // NEW
                    String textToAdd = listMsg.getText();
                    if (mpMsg.getEndsWithMultiChar())
                    {
                      // adjust first char of textToAdd
                      Logger.getInstance().logDebug("Adjusting dangling multi-char: " + textToAdd.charAt(0) + " --> " + PduUtils.getMultiCharFor(textToAdd.charAt(0)), null, getGatewayId());
                      textToAdd = PduUtils.getMultiCharFor(textToAdd.charAt(0)) + textToAdd.substring(1);
                    }
                    mpMsg.setEndsWithMultiChar(listMsg.getEndsWithMultiChar());
                    try
                    {
                      mpMsg.addText(textToAdd);
                    }
                    catch (UnsupportedEncodingException e)
                    {
                      // TODO: What to do with this?
                    }
                  }
                  mpMsg.setMpSeqNo(listMsg.getMpSeqNo());
                  mpMsg.setMpMemIndex(listMsg.getMemIndex());
                  if (listMsg.getMpSeqNo() == listMsg.getMpMaxNo())
                  {
                    mpMsg.setMemIndex(-1);
                    msgList.add(mpMsg);
                    incInboundMessageCount();
                    mpMsg = null;
View Full Code Here

Examples of org.smslib.InboundMessage

         } catch (InvalidDeliveryReceiptException e) {
           Logger.getInstance().logError("Failed getting delivery receipt.", e, getGatewayId());
           
         }
     } else {       
         InboundMessage msg = new InboundMessage(new java.util.Date(), deliverSm.getSourceAddr(), new String(deliverSm.getShortMessage()), 0, null);
     msg.setGatewayId(JSMPPGateway.this.getGatewayId());
     if(Alphabet.ALPHA_DEFAULT.value()==deliverSm.getDataCoding()){
          msg.setEncoding(MessageEncodings.ENC7BIT);
        }else if(Alphabet.ALPHA_8_BIT.value()==deliverSm.getDataCoding()){
          msg.setEncoding(MessageEncodings.ENC8BIT);
        }else if(Alphabet.ALPHA_UCS2.value()==deliverSm.getDataCoding()){
          msg.setEncoding(MessageEncodings.ENCUCS2);
        }else{
          msg.setEncoding(MessageEncodings.ENCCUSTOM);
        }
     incInboundMessageCount();
     Service.getInstance().getNotifyQueueManager().getNotifyQueue().add(new InboundMessageNotification(getMyself(), MessageTypes.INBOUND, msg));
     }
}
View Full Code Here

Examples of org.smslib.InboundMessage

      messages = new JSONObject[messagesQueued];

      for(int i = 0 ; i < inbox.size(); i ++){

        InboundMessage newMessage = (InboundMessage) inbox.get(i);
        messages[i] = new JSONObject();

        logger.trace("MESSAGE: \n" + newMessage);

        try {


          messages[i].put("date", newMessage.getDate());
          messages[i].put("id", newMessage.getId());
          messages[i].put("originator", newMessage.getOriginator());
          messages[i].put("text", newMessage.getText())

          if(deleteMessageOnReceive) service.deleteMessage(newMessage);

          if(!messages[i].get("originator").equals("")) receiver.modemEvent(messages[i]);
View Full Code Here

Examples of org.smslib.InboundMessage

      messagesQueued = service.readMessages( inbox, MessageClasses.ALL);
      message = new JSONObject[inbox.size()];

      for(int i = 0 ; i < inbox.size(); i ++){

        InboundMessage newMessage = (InboundMessage) inbox.get(i);

        logger.trace(newMessage);

        try {

          message[i].put("date", newMessage.getDate());
          message[i].put("id", newMessage.getId());
          message[i].put("originator", newMessage.getOriginator());
          message[i].put("text", newMessage.getText())

          if(deleteMessageOnReceive) service.deleteMessage(newMessage);

        } catch (JSONException e) {
          logger.warn(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.