⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmscontentnotification.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        Collections.sort(resourcesNextDay);
        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())));
        htmlMsg.append("<tr><td colspan=\"5\"><br/>");
        htmlMsg.append(m_mailContent.getStringValue(m_cms, "Footer", m_locale));
        htmlMsg.append("</td></tr></table></span></body></html>");
        String result = htmlMsg.toString();
        return result;
    }

    /**
     * Returns a list of CmsNotificationResourceInfos of the resources that will occur in the notification.<p>
     * 
     * @return a list of CmsNotificationResourceInfos of the resources that will occur in the notification
     */
    protected List getNotificationCauses() {

        return m_notificationCauses;
    }

    /**
     * Sets the resources.<p>
     * 
     * @param resources a list of CmsNotificationResourceInfo's
     */
    protected void setNotificationCauses(List resources) {

        m_notificationCauses = resources;
    }

    /** 
     * Appends a link to confirm a resource, so that the responsible will not be notified any more.<p>
     * 
     * @param html the StringBuffer to append the html code to
     * @param notificationCause the information for specific resource
     */
    private void appendConfirmLink(StringBuffer html, CmsExtendedNotificationCause notificationCause) {

        Map params = new HashMap();
        html.append("<td>");
        try {
            String resourcePath = notificationCause.getResource().getRootPath();
            String siteRoot = CmsSiteManager.getSiteRoot(resourcePath);
            resourcePath = resourcePath.substring(siteRoot.length());
            html.append("[<a href=\"");
            StringBuffer wpStartUri = new StringBuffer(m_uriWorkplace);
            wpStartUri.append("commons/confirm_content_notification.jsp?userId=");
            wpStartUri.append(m_responsible.getId());
            wpStartUri.append("&cause=");
            wpStartUri.append(notificationCause.getCause());
            wpStartUri.append("&resource=");
            wpStartUri.append(resourcePath);
            params.put(CmsFrameset.PARAM_WP_START, wpStartUri.toString());
            params.put(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE, CmsResource.getParentFolder(resourcePath));
            params.put(CmsWorkplace.PARAM_WP_SITE, siteRoot);
            int projectId = m_cms.readProject(OpenCms.getSystemInfo().getNotificationProject()).getId();
            params.put(CmsWorkplace.PARAM_WP_PROJECT, String.valueOf(projectId));
            html.append(CmsRequestUtil.appendParameters(m_uriWorkplaceJsp, params, true));
            html.append("\">");
            html.append(m_messages.key(Messages.GUI_CONFIRM_0));
            html.append("</a>]");
        } catch (CmsException e) {
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
        }
        html.append("</td>");
    }

    /** 
     * Appends a link to edit the resource to a StringBuffer.<p>
     * 
     * @param html the StringBuffer to append the html code to.
     * @param notificationCause the information for specific resource.
     */
    private void appendEditLink(StringBuffer html, CmsExtendedNotificationCause notificationCause) {

        html.append("<td>");
        if (existsEditor(notificationCause.getResource())) {
            try {
                String resourcePath = notificationCause.getResource().getRootPath();
                String siteRoot = CmsSiteManager.getSiteRoot(resourcePath);
                resourcePath = resourcePath.substring(siteRoot.length());
                Map params = new HashMap();
                int projectId = m_cms.readProject(OpenCms.getSystemInfo().getNotificationProject()).getId();
                params.put(CmsWorkplace.PARAM_WP_PROJECT, String.valueOf(projectId));
                params.put(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE, CmsResource.getParentFolder(resourcePath));
                params.put(CmsWorkplace.PARAM_WP_SITE, siteRoot);
                params.put(CmsDialog.PARAM_RESOURCE, resourcePath);
                html.append("[<a href=\"");
                html.append(CmsRequestUtil.appendParameters(m_uriWorkplace + "editors/editor.jsp", params, false));
                html.append("\">");
                html.append(m_messages.key(Messages.GUI_EDIT_0));
                html.append("</a>]");
            } catch (CmsException e) {
                if (LOG.isInfoEnabled()) {
                    LOG.info(e);
                }
            }
        }
        html.append("</td>");
    }

    /** 
     * Appends a link to edit the notification settings of a resource to a StringBuffer.<p>
     * 
     * @param html the StringBuffer to append the html code to.
     * @param notificationCause the information for specific resource.
     */
    private void appendModifyLink(StringBuffer html, CmsExtendedNotificationCause notificationCause) {

        Map params = new HashMap();
        html.append("<td>");
        try {
            html.append("[<a href=\"");
            String resourcePath = notificationCause.getResource().getRootPath();
            String siteRoot = CmsSiteManager.getSiteRoot(resourcePath);
            resourcePath = resourcePath.substring(siteRoot.length());
            StringBuffer wpStartUri = new StringBuffer(m_uriWorkplace);
            wpStartUri.append("commons/availability.jsp?resource=");
            wpStartUri.append(resourcePath);
            params.put(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE, CmsResource.getParentFolder(resourcePath));
            params.put(CmsFrameset.PARAM_WP_START, wpStartUri.toString());
            params.put(CmsWorkplace.PARAM_WP_SITE, siteRoot);
            int projectId = m_cms.readProject(OpenCms.getSystemInfo().getNotificationProject()).getId();
            params.put(CmsWorkplace.PARAM_WP_PROJECT, String.valueOf(projectId));
            html.append(CmsRequestUtil.appendParameters(m_uriWorkplaceJsp, params, true));
            html.append("\">");
            html.append(m_messages.key(Messages.GUI_MODIFY_0));
            html.append("</a>]");
        } catch (CmsException e) {
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
        }
        html.append("</td>");
    }

    /**
     * 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));
            }
        }
    }

    /**
     * Returns a string representation of this resource info.<p>
     * 
     * @return a string representation of this resource info
     */
    private String buildNotificationListItem(CmsExtendedNotificationCause notificationCause, int row) {

        StringBuffer result = new StringBuffer("<tr class=\"trow");
        result.append(row);
        result.append("\"><td width=\"100%\">");
        String resourcePath = notificationCause.getResource().getRootPath();
        String siteRoot = CmsSiteManager.getSiteRoot(resourcePath);
        resourcePath = resourcePath.substring(siteRoot.length());
        // append link, if page is available
        if (notificationCause.getResource().getDateReleased() < System.currentTimeMillis()
            && notificationCause.getResource().getDateExpired() > System.currentTimeMillis()) {

            Map params = new HashMap();
            params.put(CmsWorkplace.PARAM_WP_SITE, siteRoot);
            params.put(CmsDialog.PARAM_RESOURCE, resourcePath);
            result.append("<a href=\"");
            result.append(CmsRequestUtil.appendParameters(m_uriWorkplace + "commons/displayresource.jsp", params, false));
            result.append("\">");
            result.append(resourcePath);
            result.append("</a>");
        } else {
            result.append(resourcePath);
        }
        result.append("</td><td><div style=\"white-space:nowrap;padding-left:10px;padding-right:10px;\">");
        result.append(siteRoot);
        result.append("</td><td><div style=\"white-space:nowrap;padding-left:10px;padding-right:10px;\">");
        if (notificationCause.getCause() == CmsExtendedNotificationCause.RESOURCE_EXPIRES) {
            result.append(m_messages.key(Messages.GUI_EXPIRES_AT_1, new Object[] {notificationCause.getDate()}));
            result.append("</div></td>");
            appendConfirmLink(result, notificationCause);
            appendModifyLink(result, notificationCause);
        } else if (notificationCause.getCause() == CmsExtendedNotificationCause.RESOURCE_RELEASE) {
            result.append(m_messages.key(Messages.GUI_RELEASE_AT_1, new Object[] {notificationCause.getDate()}));
            result.append("</div></td>");
            appendConfirmLink(result, notificationCause);
            appendModifyLink(result, notificationCause);
        } else if (notificationCause.getCause() == CmsExtendedNotificationCause.RESOURCE_UPDATE_REQUIRED) {
            result.append(m_messages.key(Messages.GUI_UPDATE_REQUIRED_1, new Object[] {notificationCause.getDate()}));
            result.append("</div></td>");
            appendConfirmLink(result, notificationCause);
            appendEditLink(result, notificationCause);
        } else {
            result.append(m_messages.key(Messages.GUI_UNCHANGED_SINCE_1, new Object[] {new Integer(
                CmsDateUtil.getDaysPassedSince(notificationCause.getDate()))}));
            result.append("</div></td>");
            appendConfirmLink(result, notificationCause);
            appendEditLink(result, notificationCause);
        }

        result.append("</tr>");

        return result.toString();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -