private void checkSubscriberNotifications() { if (Logger.getLogger(getClass()).isDebugEnabled()) { Logger.getLogger(getClass()).debug("checking subscriber notifications"); } NodeList invitationList = invitationRoot.getElementsByTagName("invitation"); if (invitationList == null) { return; } int listLength = invitationList.getLength(); for (int i = 0; i < listLength; i++) { Element invitationElem = (Element) invitationList.item(i); Element notifyElem = XmlUtil.getChildByTagName(invitationElem, "notifySubscribers"); if (notifyElem != null) { Element changedElem = XmlUtil.getChildByTagName(notifyElem, "changed"); if (changedElem != null) { long lastChangeTime = 0; try { lastChangeTime = Long.parseLong(XmlUtil.getElementText(changedElem)); } catch (NumberFormatException numEx) { Logger.getLogger(getClass()).error("invalid change time", numEx); } if (System.currentTimeMillis() - lastChangeTime > NOTIFIY_DELAY_AFTER_CHANGE) { // wait some time after blog change until subscribers are notified, in case more entries // will be created soon long lastNotified = 0; String lastNotificationTime = XmlUtil.getChildText(notifyElem, "lastNotified"); if (!CommonUtils.isEmpty(lastNotificationTime)) { try { lastNotified = Long.parseLong(lastNotificationTime); } catch (NumberFormatException numEx) { Logger.getLogger(getClass()) .error("invalid lastNotified time: " + lastNotificationTime); } } if (System.currentTimeMillis() - lastNotified > MIN_SUBSCRIBER_NOTIFICATION_INTERVAL) { Element subscriberListElem = XmlUtil.getChildByTagName(invitationElem, "subscriberList"); if (subscriberListElem != null) { NodeList subscriberList = subscriberListElem.getElementsByTagName("subscriber"); if (subscriberList != null) { String blogPath = XmlUtil.getChildText(invitationElem, "path"); String virtualUser = XmlUtil.getChildText(invitationElem, "virtualUser"); String blogTitle = MetaInfManager.getInstance().getDescription(blogPath, "."); if (CommonUtils.isEmpty(blogTitle)) { blogTitle = virtualUser; } String blogAccessCode = invitationElem.getAttribute("accessCode"); int subscriberListLength = subscriberList.getLength(); for (int k = 0; k < subscriberListLength; k++) { Element subscriberElement = (Element) subscriberList.item(k); String email = XmlUtil.getChildText(subscriberElement, "email"); String code = XmlUtil.getChildText(subscriberElement, "code"); sendSubscriberNotification(email, code, blogTitle, virtualUser, blogAccessCode); } } } notifyElem.removeChild(changedElem); XmlUtil.setChildText( notifyElem, "lastNotified", Long.toString(System.currentTimeMillis())); changed = true; } } } } } }