當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityFormatException類代碼示例

本文整理匯總了Java中org.apache.vysper.xmpp.addressing.EntityFormatException的典型用法代碼示例。如果您正苦於以下問題:Java EntityFormatException類的具體用法?Java EntityFormatException怎麽用?Java EntityFormatException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityFormatException類屬於org.apache.vysper.xmpp.addressing包,在下文中一共展示了EntityFormatException類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyCredentials

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
@Override
public boolean verifyCredentials(String username, String passwordCleartext, Object credentials) {
    try {
        Entity jid = EntityImpl.parse(username);
        return verifyCredentials(jid, passwordCleartext, credentials);
    } catch (EntityFormatException e) {
        LOG.error("Parse JID failed", e);
    }
    return false;
}
 
開發者ID:tumakha,項目名稱:xmpp-light,代碼行數:11,代碼來源:DbUserManagement.java

示例2: retrieveRoster

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
@Override public Roster retrieveRoster(Entity jid) {
    Uid uid = new Uid(jid.toString());
    MutableRoster roster = new MutableRoster();
    
    List<TinyUser> users = loadCacheUsers();
    
    if (null == users || users.size() < 1) {
        return roster;
    }
    
    for (TinyUser u : users) {
        // 忽略當前賬戶
        if (u.account.equals(uid.getAccount())) {
            continue;
        }
        
        try {
            Entity ujid = EntityImpl.parse(u.account + "@" + uid.getDomain());
            List<RosterGroup> groups = Lists.newArrayList();
            String groupName = u.getGroupName();
            if (null != groupName) {
                groups.add(new RosterGroup(groupName));
            }
            RosterItem rosterItem = new RosterItem(
                    ujid, 
                    u.name, 
                    SubscriptionType.BOTH,   
                    AskSubscriptionType.NOT_SET, 
                    groups);
            roster.addItem(rosterItem);
        } catch (EntityFormatException e) {
            LOG.error("method:retrieveRoster,jid:" + jid + ",errorMsg:" + e.getMessage(), e);
        }
    }
    
    return roster;
}
 
開發者ID:imtopsales,項目名稱:vysper-demo,代碼行數:38,代碼來源:NeteaseQiyeApi.java

示例3: createAckMessageStanza

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
/**
 * Create Ack Message

 <message id="">
   <gcm xmlns="google:mobile:data">
   {
     "from":"REGID",
     "message_id":"m-1366082849205"
     "message_type":"ack"
   }
   </gcm>
 </message>

 * @param original
 * @param jsonObject
 * @return
 * @throws EntityFormatException
 */
private static Stanza createAckMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
  Map<String, Object> message = new HashMap<>();
  message.put(JSON_MESSAGE_TYPE, JSON_ACK);
  message.put(JSON_FROM, jsonObject.get(JSON_TO));
  message.put(JSON_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
  String payload = JSONValue.toJSONString(message);

  // no from & to
  StanzaBuilder builder = new StanzaBuilder("message");
  builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
  GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
  gcmMessageBuilder.addText(payload);
  builder.addPreparedElement(gcmMessageBuilder.build());
  return builder.build();
}
 
開發者ID:lidennis88,項目名稱:gcmccsmock,代碼行數:34,代碼來源:GCMMessageHandler.java

示例4: createNackBadRegIdMessageStanza

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
/**
 * Create Bad RegId Nack Message Stanza
 *
 <message>
   <gcm xmlns="google:mobile:data">
   {
     "message_type":"nack",
     "message_id":"msgId1",
     "from":"SomeInvalidRegistrationId",
     "error":"BAD_REGISTRATION",
     "error_description":"Invalid token on 'to' field: SomeInvalidRegistrationId"
   }
   </gcm>
 </message>

 * @param original
 * @param jsonObject
 * @return
 * @throws EntityFormatException
 */
private static Stanza createNackBadRegIdMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {

  Map<String, Object> message = new HashMap<>();
  message.put(JSON_MESSAGE_TYPE, JSON_NACK);
  message.put(JSON_FROM, jsonObject.get(JSON_TO));
  message.put(JSON_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
  message.put(JSON_ERROR, JSON_ERROR_BAD_REGISTRATION);
  message.put(JSON_ERROR_DESCRIPTION, "Invalid token on 'to' field: "+jsonObject.get(JSON_TO));

  String payload = JSONValue.toJSONString(message);

  StanzaBuilder builder = new StanzaBuilder("message");
  builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
  GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
  gcmMessageBuilder.addText(payload);
  builder.addPreparedElement(gcmMessageBuilder.build());
  return builder.build();
}
 
開發者ID:lidennis88,項目名稱:gcmccsmock,代碼行數:39,代碼來源:GCMMessageHandler.java

示例5: createDeliveryReceiptMessageStanza

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
/**
 * Create Delivery Receipt

 <message id="">
   <gcm xmlns="google:mobile:data">
   {
     "category":"com.example.yourapp", // to know which app sent it
     "data":
     {
       “message_status":"MESSAGE_SENT_TO_DEVICE",
       “original_message_id”:”m-1366082849205”,
       “device_registration_id”: “REGISTRATION_ID”,
       "message_sent_timestamp": "1430277821658"
     },
     "message_id":"dr2:m-1366082849205",
     "message_type":"receipt",
     "time_to_live": 0,
     "from":"gcm.googleapis.com"
   }
   </gcm>
 </message>

 * @param original
 * @param jsonObject
 * @return
 * @throws EntityFormatException
 */
private static Stanza createDeliveryReceiptMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {

  Map<String, Object> message = new HashMap<>();
  message.put(JSON_MESSAGE_TYPE, JSON_RECEIPT);
  message.put(JSON_FROM, "gcm.googleapis.com");
  // TODO made up
  message.put(JSON_CATEGORY, "com.itsoninc.client");
  message.put(JSON_MESSAGE_ID, "dr2:"+jsonObject.get(JSON_MESSAGE_ID));
  Map<String, Object> data = new HashMap<>();
  data.put(JSON_MESSAGE_STATUS, JSON_MESSAGE_STATUS_SENT_TO_DEVICE);
  data.put(JSON_ORIGINAL_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
  data.put(JSON_DEVICE_REG_ID, jsonObject.get(JSON_TO));
  data.put(JSON_SENT_TIMESTAMP, Long.toString(System.currentTimeMillis()));
  message.put("data", data);
  String payload = JSONValue.toJSONString(message);

  StanzaBuilder builder = new StanzaBuilder("message");
  builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
  GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
  gcmMessageBuilder.addText(payload);
  builder.addPreparedElement(gcmMessageBuilder.build());
  return builder.build();
}
 
開發者ID:lidennis88,項目名稱:gcmccsmock,代碼行數:51,代碼來源:GCMMessageHandler.java

示例6: createDrainingMessageStanza

import org.apache.vysper.xmpp.addressing.EntityFormatException; //導入依賴的package包/類
/**
 * Create Draining Control Message

 <message>
   <data:gcm xmlns:data="google:mobile:data">
   {
     "message_type":"control"
     "control_type":"CONNECTION_DRAINING"
   }
   </data:gcm>
 </message>

 * @param original
 * @param jsonObject
 * @return
 * @throws EntityFormatException
 */
private static Stanza createDrainingMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
  Map<String, Object> message = new HashMap<>();
  message.put(JSON_MESSAGE_TYPE, JSON_CONTROL);
  message.put(JSON_CONTROL_TYPE, "CONNECTION_DRAINING");
  String payload = JSONValue.toJSONString(message);

  StanzaBuilder builder = new StanzaBuilder("message");
  builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
  GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
  gcmMessageBuilder.addText(payload);
  builder.addPreparedElement(gcmMessageBuilder.build());
  return builder.build();
}
 
開發者ID:lidennis88,項目名稱:gcmccsmock,代碼行數:31,代碼來源:GCMMessageHandler.java


注:本文中的org.apache.vysper.xmpp.addressing.EntityFormatException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。