List of usage examples for org.dom4j Element getText
String getText();
From source file:com.buddycloud.pusher.handler.internal.UserFollowedQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element followerJidElement = queryElement.element("followerJid"); Element channelElement = queryElement.element("channel"); Element ownerJidElement = queryElement.element("ownerJid"); if (followerJidElement == null || channelElement == null || ownerJidElement == null) { return XMPPUtils.error(iq, "You must provide the userJid, the channel and the channelOwner"); }//from w ww .j ava 2 s . com String followerJid = followerJidElement.getText(); String ownerJid = ownerJidElement.getText(); String channelJid = channelElement.getText(); List<NotificationSettings> allNotificationSettings = NotificationUtils.getNotificationSettings(ownerJid, getDataSource()); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("FOLLOWER_JID", followerJid); tokens.put("OWNER_JID", ownerJid); tokens.put("CHANNEL_JID", channelJid); for (NotificationSettings notificationSettings : allNotificationSettings) { if (!notificationSettings.getFollowedMyChannel()) { getLogger().warn("User " + ownerJid + " won't receive follow notifications."); continue; } if (notificationSettings.getTarget() == null) { getLogger().warn("User " + ownerJid + " has no target registered."); continue; } Pusher pusher = Pushers.getInstance(getProperties()).get(notificationSettings.getType()); pusher.push(notificationSettings.getTarget(), Event.FOLLOW, tokens); } return createResponse(iq, "User [" + followerJid + "] has followed channel [" + channelJid + "]."); }
From source file:com.buddycloud.pusher.handler.internal.UserPostedAfterMyPostQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element authorElement = queryElement.element("authorJid"); Element referencedElement = queryElement.element("referencedJid"); Element channelElement = queryElement.element("channel"); Element postContentElement = queryElement.element("postContent"); if (authorElement == null || channelElement == null || referencedElement == null) { return XMPPUtils.error(iq, "You must provide the authorJid, the channel and the referencedJid"); }//from ww w. ja v a 2 s. c o m String authorJid = authorElement.getText(); String referencedJid = referencedElement.getText(); String channelJid = channelElement.getText(); String postContent = postContentElement.getText(); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("AUTHOR_JID", authorJid); tokens.put("REFERENCED_JID", referencedJid); tokens.put("CHANNEL_JID", channelJid); tokens.put("CONTENT", postContent); List<NotificationSettings> allNotificationSettings = NotificationUtils .getNotificationSettings(referencedJid, getDataSource()); for (NotificationSettings notificationSettings : allNotificationSettings) { if (!notificationSettings.getPostAfterMe()) { getLogger().warn("User " + referencedJid + " won't receive comment notifications."); continue; } if (notificationSettings.getTarget() == null) { getLogger().warn("User " + referencedJid + " has no target registered."); continue; } Pusher pusher = Pushers.getInstance(getProperties()).get(notificationSettings.getType()); pusher.push(notificationSettings.getTarget(), Event.POST_AFTER_MY_POST, tokens); } return createResponse(iq, "User [" + authorJid + "] has posted on channel [" + channelJid + "] after [" + referencedJid + "] post."); }
From source file:com.buddycloud.pusher.handler.internal.UserPostedMentionQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element authorJidElement = queryElement.element("authorJid"); Element channelElement = queryElement.element("channel"); Element mentionedJidElement = queryElement.element("mentionedJid"); Element postContentElement = queryElement.element("postContent"); if (authorJidElement == null || channelElement == null || mentionedJidElement == null) { return XMPPUtils.error(iq, "You must provide the userJid, the channel and the channelOwner", getLogger());/*from w ww . ja va 2s . c o m*/ } String authorJid = authorJidElement.getText(); String mentionedJid = mentionedJidElement.getText(); String channelJid = channelElement.getText(); String postContent = postContentElement.getText(); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("AUTHOR_JID", authorJid); tokens.put("MENTIONED_JID", mentionedJid); tokens.put("CHANNEL_JID", channelJid); tokens.put("CONTENT", postContent); List<NotificationSettings> allNotificationSettings = NotificationUtils.getNotificationSettings(mentionedJid, getDataSource()); for (NotificationSettings notificationSettings : allNotificationSettings) { if (!notificationSettings.getPostMentionedMe()) { getLogger().warn("User " + mentionedJid + " won't receive mention notifications."); continue; } if (notificationSettings.getTarget() == null) { getLogger().warn("User " + mentionedJid + " has no target registered."); continue; } Pusher pusher = Pushers.getInstance(getProperties()).get(notificationSettings.getType()); pusher.push(notificationSettings.getTarget(), Event.MENTION, tokens); } return createResponse(iq, "User [" + authorJid + "] mentioned [" + mentionedJidElement + "] " + "on channel [" + channelJid + "]."); }
From source file:com.buddycloud.pusher.handler.internal.UserPostedOnMyChannelQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element authorJidElement = queryElement.element("authorJid"); Element ownerJidElement = queryElement.element("ownerJid"); Element channelElement = queryElement.element("channel"); Element postContentElement = queryElement.element("postContent"); if (authorJidElement == null || channelElement == null || ownerJidElement == null) { return XMPPUtils.error(iq, "You must provide the userJid, the channel and the channelOwner", getLogger());/*from w w w . j av a2s . c o m*/ } String authorJid = authorJidElement.getText(); String ownerJid = ownerJidElement.getText(); String channelJid = channelElement.getText(); String postContent = postContentElement.getText(); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("AUTHOR_JID", authorJid); tokens.put("OWNER_JID", ownerJid); tokens.put("CHANNEL_JID", channelJid); tokens.put("CONTENT", postContent); List<NotificationSettings> allNotificationSettings = NotificationUtils.getNotificationSettings(ownerJid, getDataSource()); for (NotificationSettings notificationSettings : allNotificationSettings) { if (!notificationSettings.getPostOnMyChannel()) { getLogger() .warn("User " + ownerJid + " won't receive notifications for posts on his own channels."); continue; } if (notificationSettings.getTarget() == null) { getLogger().warn("User " + ownerJid + " has no target registered."); continue; } Pusher pusher = Pushers.getInstance(getProperties()).get(notificationSettings.getType()); pusher.push(notificationSettings.getTarget(), Event.POST_ON_MY_CHANNEL, tokens); } return createResponse(iq, "User [" + authorJid + "] has posted on channel [" + channelJid + "]."); }
From source file:com.buddycloud.pusher.handler.internal.UserPostedOnSubscribedChannelQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element authorJidElement = queryElement.element("authorJid"); Element channelElement = queryElement.element("channel"); Element followerJidElement = queryElement.element("followerJid"); Element postContentElement = queryElement.element("postContent"); if (authorJidElement == null || channelElement == null || followerJidElement == null) { return XMPPUtils.error(iq, "You must provide the userJid, the channel and the channelOwner", getLogger());//from w ww .ja v a 2s . com } String authorJid = authorJidElement.getText(); String followerJid = followerJidElement.getText(); String channelJid = channelElement.getText(); String postContent = postContentElement.getText(); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("AUTHOR_JID", authorJid); tokens.put("FOLLOWER_JID", followerJid); tokens.put("CHANNEL_JID", channelJid); tokens.put("CONTENT", postContent); List<NotificationSettings> allNotificationSettings = NotificationUtils.getNotificationSettings(followerJid, getDataSource()); for (NotificationSettings notificationSettings : allNotificationSettings) { if (!notificationSettings.getPostOnSubscribedChannel()) { getLogger() .warn("User " + followerJid + " won't receive post on following channels notifications."); continue; } if (notificationSettings.getTarget() == null) { getLogger().warn("User " + followerJid + " has no target registered."); continue; } Pusher pusher = Pushers.getInstance(getProperties()).get(notificationSettings.getType()); pusher.push(notificationSettings.getTarget(), Event.POST_ON_SUBSCRIBED_CHANNEL, tokens); } return createResponse(iq, "User [" + authorJid + "] has posted on channel [" + channelJid + "]."); }
From source file:com.buddycloud.pusher.handler.SignupQueryHandler.java
License:Apache License
@Override protected IQ handleQuery(IQ iq) { Element queryElement = iq.getElement().element("query"); Element emailElement = queryElement.element("email"); if (emailElement == null) { return XMPPUtils.error(iq, "You must provide an email address", getLogger()); }/*from w w w . ja va 2s . com*/ String jid = iq.getFrom().toBareJID(); String emailAddress = emailElement.getText(); insertSubscriber(jid, emailAddress); Map<String, String> tokens = new HashMap<String, String>(); tokens.put("NEW_USER_JID", jid); tokens.put("EMAIL", emailAddress); Pushers.getInstance(getProperties()).get(EmailPusher.TYPE).push(emailAddress, Event.SIGNUP, tokens); return createResponse(iq, "User [" + jid + "] signed up."); }
From source file:com.buddycloud.pusher.utils.NotificationUtils.java
License:Apache License
private static Boolean getBoolean(Element settingsEl, String key) { Element el = settingsEl.element(key); if (el == null) { return null; }// w w w . j a v a 2 s .c o m return Boolean.valueOf(el.getText()); }
From source file:com.buddycloud.pusher.utils.NotificationUtils.java
License:Apache License
private static String getString(Element settingsEl, String key) { Element el = settingsEl.element(key); if (el == null) { return null; }/*from w w w. j ava 2s . co m*/ return el.getText(); }
From source file:com.chingo247.structureapi.plan.util.PlanDocumentUtil.java
License:Open Source License
public void checkHasNumber(Element e) { checkLocated(e);//from w w w .ja v a 2 s . co m if (!NumberUtils.isNumber(e.getText())) { LocatedElement le = (LocatedElement) e; throw new IllegalArgumentException( "Value of element <" + e.getName() + "> on line " + le.getLine() + " is not a number"); } }
From source file:com.cloopen.rest.sdk.CCPRestSDK.java
License:Open Source License
/** * @description xml??map/*www . j av a2 s. com*/ * @param xml * @return Map */ private HashMap<String, Object> xmlToMap(String xml) { HashMap<String, Object> map = new HashMap<String, Object>(); Document doc = null; try { doc = DocumentHelper.parseText(xml); // XML Element rootElt = doc.getRootElement(); // ? HashMap<String, Object> hashMap2 = new HashMap<String, Object>(); ArrayList<HashMap<String, Object>> arrayList = new ArrayList<HashMap<String, Object>>(); for (Iterator i = rootElt.elementIterator(); i.hasNext();) { Element e = (Element) i.next(); if ("statusCode".equals(e.getName()) || "statusMsg".equals(e.getName())) map.put(e.getName(), e.getText()); else { if ("SubAccount".equals(e.getName()) || "TemplateSMS".equals(e.getName()) || "totalCount".equals(e.getName()) || "token".equals(e.getName()) || "callSid".equals(e.getName()) || "state".equals(e.getName()) || "downUrl".equals(e.getName())) { if (!"SubAccount".equals(e.getName()) && !"TemplateSMS".equals(e.getName())) { hashMap2.put(e.getName(), e.getText()); } else if ("SubAccount".equals(e.getName())) { HashMap<String, Object> hashMap3 = new HashMap<String, Object>(); for (Iterator i2 = e.elementIterator(); i2.hasNext();) { Element e2 = (Element) i2.next(); hashMap3.put(e2.getName(), e2.getText()); } arrayList.add(hashMap3); hashMap2.put("SubAccount", arrayList); } else if ("TemplateSMS".equals(e.getName())) { HashMap<String, Object> hashMap3 = new HashMap<String, Object>(); for (Iterator i2 = e.elementIterator(); i2.hasNext();) { Element e2 = (Element) i2.next(); hashMap3.put(e2.getName(), e2.getText()); } arrayList.add(hashMap3); hashMap2.put("TemplateSMS", arrayList); } map.put("data", hashMap2); } else { HashMap<String, Object> hashMap3 = new HashMap<String, Object>(); for (Iterator i2 = e.elementIterator(); i2.hasNext();) { Element e2 = (Element) i2.next(); // hashMap2.put(e2.getName(),e2.getText()); hashMap3.put(e2.getName(), e2.getText()); } if (hashMap3.size() != 0) { hashMap2.put(e.getName(), hashMap3); } else { hashMap2.put(e.getName(), e.getText()); } map.put("data", hashMap2); } } } } catch (DocumentException e) { e.printStackTrace(); LoggerUtil.error(e.getMessage()); } catch (Exception e) { LoggerUtil.error(e.getMessage()); e.printStackTrace(); } return map; }