/** * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map) */ public String launch(CmsObject cms, Map parameters) throws Exception { CmsNotificationCandidates candidates = new CmsNotificationCandidates(cms); return candidates.notifyResponsibles(); } }
/** * Returns true if the Object equals to the corresponding CmsNotificationCause, that means a notification cause * with the same resource and cause. * * @return true if the resource info is equal to a notification cause or resource info with the same resource and cause * * @param o the object to check for equality * * @see org.opencms.notification.CmsExtendedNotificationCause#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (!((o instanceof CmsExtendedNotificationCause) || (o instanceof CmsNotificationCause))) { return false; } return hashCode() == o.hashCode(); }
/** * Sends all notifications to the responsible users.<p> * * @return a string listing all responsibles that a notification was sent to * * @throws CmsException if something goes wrong */ public String notifyResponsibles() throws CmsException { Iterator notifications = filterConfirmedResources(getContentNotifications()).iterator(); if (notifications.hasNext()) { StringBuffer result = new StringBuffer(Messages.get().getBundle().key(Messages.LOG_NOTIFICATIONS_SENT_TO_0)); result.append(' '); while (notifications.hasNext()) { CmsContentNotification contentNotification = (CmsContentNotification)notifications.next(); result.append(contentNotification.getResponsible().getName()); if (notifications.hasNext()) { result.append(", "); } try { contentNotification.send(); } catch (EmailException e) { LOG.error(e.getLocalizedMessage(), e); } } return result.toString(); } else { return Messages.get().getBundle().key(Messages.LOG_NO_NOTIFICATIONS_SENT_0); } }
m_messages = Messages.get().getBundle(getLocale()); while (notificationCauses.hasNext()) { CmsExtendedNotificationCause notificationCause = (CmsExtendedNotificationCause)notificationCauses.next(); if (notificationCause.getCause() == CmsExtendedNotificationCause.RESOURCE_OUTDATED) { outdatedResources.add(notificationCause); } else if (notificationCause.getDate().before(tomorrow.getTime())) { resourcesNextDay.add(notificationCause); } else { Collections.sort(resourcesNextWeek); Collections.sort(outdatedResources); appendResourceList(htmlMsg, resourcesNextDay, m_messages.key(Messages.GUI_WITHIN_NEXT_DAY_0)); appendResourceList(htmlMsg, resourcesNextWeek, m_messages.key(Messages.GUI_WITHIN_NEXT_WEEK_0)); appendResourceList(htmlMsg, outdatedResources, m_messages.key( Messages.GUI_FILES_NOT_UPDATED_1, String.valueOf(OpenCms.getSystemInfo().getNotificationTime())));
if (existsEditor(notificationCause.getResource())) { try { String resourcePath = notificationCause.getResource().getRootPath(); String siteRoot = OpenCms.getSiteManager().getSiteRoot(resourcePath); resourcePath = resourcePath.substring(siteRoot.length()); Map params = new HashMap(); CmsUUID projectId = getCmsObject().readProject(OpenCms.getSystemInfo().getNotificationProject()).getUuid(); params.put(CmsWorkplace.PARAM_WP_PROJECT, String.valueOf(projectId)); params.put(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE, CmsResource.getParentFolder(resourcePath));
/** * @see org.opencms.notification.A_CmsNotification#generateHtmlMsg() */ @Override protected String generateHtmlMsg() { StringBuffer buffer = new StringBuffer(); CmsMessages messages = Messages.get().getBundle(getLocale()); // add warnings to the notification if (m_report.hasWarning()) { buffer.append("<b>"); buffer.append(messages.key(Messages.GUI_PUBLISH_WARNING_HEADER_0)); buffer.append("</b><br/>\n"); appendList(buffer, m_report.getWarnings()); buffer.append("<br/>\n"); } // add errors to the notification if (m_report.hasError()) { buffer.append("<b>"); buffer.append(messages.key(Messages.GUI_PUBLISH_ERROR_HEADER_0)); buffer.append("</b><br/>\n"); appendList(buffer, m_report.getErrors()); buffer.append("<br/>\n"); } return buffer.toString(); }
try { buf.append("[<a href=\""); String resourcePath = notificationCause.getResource().getRootPath(); String siteRoot = OpenCms.getSiteManager().getSiteRoot(resourcePath); resourcePath = resourcePath.substring(siteRoot.length()); params.put(CmsFrameset.PARAM_WP_START, wpStartUri.toString()); params.put(CmsWorkplace.PARAM_WP_SITE, siteRoot); CmsUUID projectId = getCmsObject().readProject(OpenCms.getSystemInfo().getNotificationProject()).getUuid(); params.put(CmsWorkplace.PARAM_WP_PROJECT, String.valueOf(projectId)); buf.append(CmsRequestUtil.appendParameters(m_uriWorkplaceJsp, params, true));
/** * @see org.opencms.notification.A_CmsNotification#generateHtmlMsg() */ @Override protected String generateHtmlMsg() { StringBuffer buffer = new StringBuffer(); // add warnings to the notification if (m_report.hasWarning()) { buffer.append("<b>"); buffer.append(Messages.get().getBundle().key(Messages.GUI_PUBLISH_WARNING_HEADER_0)); buffer.append("</b><br/>\n"); appendList(buffer, m_report.getWarnings()); buffer.append("<br/>\n"); } // add errors to the notification if (m_report.hasError()) { buffer.append("<b>"); buffer.append(Messages.get().getBundle().key(Messages.GUI_PUBLISH_ERROR_HEADER_0)); buffer.append("</b><br/>\n"); appendList(buffer, m_report.getErrors()); buffer.append("<br/>\n"); } return buffer.toString(); }
/** * Returns true if the Object equals to the corresponding CmsResourceInfo, that means a resource info * with the same resource and cause. * * @return true if the resource info is equal to a notification cause or resource info with the same resource and cause * * @param o the object to check for equality * * @see org.opencms.notification.CmsNotificationCause#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (!(o instanceof CmsExtendedNotificationCause) && !(o instanceof CmsNotificationCause)) { return false; } return hashCode() == o.hashCode(); }
/** * Appends a table showing a set of resources, and the cause of the notification.<p> * * @param htmlMsg html the StringBuffer to append the html code to * @param notificationCauseList the list of notification causes * @param header the title of the resource list */ private void appendResourceList(StringBuffer htmlMsg, List notificationCauseList, String header) { if (!notificationCauseList.isEmpty()) { htmlMsg.append("<tr><td colspan=\"5\"><br/><p style=\"margin-top:20px;margin-bottom:10px;\"><b>"); htmlMsg.append(header); htmlMsg.append("</b></p></td></tr><tr class=\"trow1\"><td><div style=\"padding-top:2px;padding-bottom:2px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_RESOURCE_0)); htmlMsg.append("</div></td><td><div style=\"padding-top:2px;padding-bottom:2px;padding-left:10px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_SITE_0)); htmlMsg.append("</div></td><td><div style=\"padding-top:2px;padding-bottom:2px;padding-left:10px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_ISSUE_0)); htmlMsg.append("</div></td><td colspan=\"2\"/></tr>"); Iterator notificationCauses = notificationCauseList.iterator(); for (int i = 0; notificationCauses.hasNext(); i++) { CmsExtendedNotificationCause notificationCause = (CmsExtendedNotificationCause)notificationCauses.next(); htmlMsg.append(buildNotificationListItem(notificationCause, (i % 2) + 2)); } } }
/** * Sends all notifications to the responsible users.<p> * * @return a string listing all responsibles that a notification was sent to * * @throws CmsException if something goes wrong */ public String notifyResponsibles() throws CmsException { Iterator<CmsContentNotification> notifications = filterConfirmedResources(getContentNotifications()).iterator(); if (notifications.hasNext()) { StringBuffer result = new StringBuffer( Messages.get().getBundle().key(Messages.LOG_NOTIFICATIONS_SENT_TO_0)); result.append(' '); while (notifications.hasNext()) { CmsContentNotification contentNotification = notifications.next(); result.append(contentNotification.getResponsible().getName()); if (notifications.hasNext()) { result.append(", "); } try { contentNotification.send(); } catch (EmailException e) { LOG.error(e.getLocalizedMessage(), e); } } return result.toString(); } else { return Messages.get().getBundle().key(Messages.LOG_NO_NOTIFICATIONS_SENT_0); } }
m_messages = Messages.get().getBundle(getLocale()); while (notificationCauses.hasNext()) { CmsExtendedNotificationCause notificationCause = notificationCauses.next(); if (notificationCause.getCause() == CmsExtendedNotificationCause.RESOURCE_OUTDATED) { outdatedResources.add(notificationCause); } else if (notificationCause.getDate().before(tomorrow.getTime())) { resourcesNextDay.add(notificationCause); } else { Collections.sort(resourcesNextWeek); Collections.sort(outdatedResources); appendResourceList(htmlMsg, resourcesNextDay, m_messages.key(Messages.GUI_WITHIN_NEXT_DAY_0)); appendResourceList(htmlMsg, resourcesNextWeek, m_messages.key(Messages.GUI_WITHIN_NEXT_WEEK_0)); appendResourceList( htmlMsg, outdatedResources,
if (existsEditor(notificationCause.getResource())) { try { String resourcePath = notificationCause.getResource().getRootPath(); String siteRoot = OpenCms.getSiteManager().getSiteRoot(resourcePath); resourcePath = resourcePath.substring(siteRoot.length()); Map<String, String[]> params = new HashMap<String, String[]>(); CmsUUID projectId = getCmsObject().readProject( OpenCms.getSystemInfo().getNotificationProject()).getUuid(); params.put(CmsWorkplace.PARAM_WP_PROJECT, new String[] {String.valueOf(projectId)});
/** * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map) */ public String launch(CmsObject cms, Map<String, String> parameters) throws Exception { CmsNotificationCandidates candidates = new CmsNotificationCandidates(cms); return candidates.notifyResponsibles(); } }
try { buf.append("[<a href=\""); String resourcePath = notificationCause.getResource().getRootPath(); String siteRoot = OpenCms.getSiteManager().getSiteRoot(resourcePath); resourcePath = resourcePath.substring(siteRoot.length()); params.put(CmsWorkplace.PARAM_WP_START, new String[] {wpStartUri.toString()}); params.put(CmsWorkplace.PARAM_WP_SITE, new String[] {siteRoot}); CmsUUID projectId = getCmsObject().readProject(OpenCms.getSystemInfo().getNotificationProject()).getUuid(); params.put(CmsWorkplace.PARAM_WP_PROJECT, new String[] {String.valueOf(projectId)}); buf.append(CmsRequestUtil.appendParameters(m_uriWorkplaceJsp, params, true));
/** * Returns true if the Object equals to the corresponding CmsNotificationCause, that means a notification cause * with the same resource and cause. * * @return true if the resource info is equal to a notification cause or resource info with the same resource and cause * * @param o the object to check for equality * * @see org.opencms.notification.CmsExtendedNotificationCause#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (!(o instanceof CmsExtendedNotificationCause) || !(o instanceof CmsNotificationCause)) { return false; } return hashCode() == o.hashCode(); }
/** * Returns true if the Object equals to the corresponding CmsResourceInfo, that means a resource info * with the same resource and cause. * * @return true if the resource info is equal to a notification cause or resource info with the same resource and cause * * @param o the object to check for equality * * @see org.opencms.notification.CmsNotificationCause#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (!(o instanceof CmsExtendedNotificationCause) && !(o instanceof CmsNotificationCause)) { return false; } return hashCode() == o.hashCode(); }
/** * Appends a table showing a set of resources, and the cause of the notification.<p> * * @param htmlMsg html the StringBuffer to append the html code to * @param notificationCauseList the list of notification causes * @param header the title of the resource list */ private void appendResourceList( StringBuffer htmlMsg, List<CmsExtendedNotificationCause> notificationCauseList, String header) { if (!notificationCauseList.isEmpty()) { htmlMsg.append("<tr><td colspan=\"5\"><br/><p style=\"margin-top:20px;margin-bottom:10px;\"><b>"); htmlMsg.append(header); htmlMsg.append( "</b></p></td></tr><tr class=\"trow1\"><td><div style=\"padding-top:2px;padding-bottom:2px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_RESOURCE_0)); htmlMsg.append("</div></td><td><div style=\"padding-top:2px;padding-bottom:2px;padding-left:10px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_SITE_0)); htmlMsg.append("</div></td><td><div style=\"padding-top:2px;padding-bottom:2px;padding-left:10px;\">"); htmlMsg.append(m_messages.key(Messages.GUI_ISSUE_0)); htmlMsg.append("</div></td><td colspan=\"2\"/></tr>"); Iterator<CmsExtendedNotificationCause> notificationCauses = notificationCauseList.iterator(); for (int i = 0; notificationCauses.hasNext(); i++) { CmsExtendedNotificationCause notificationCause = notificationCauses.next(); htmlMsg.append(buildNotificationListItem(notificationCause, (i % 2) + 2)); } } }