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

📄 cmslock.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        html.append("<script type='text/javascript' src='");
        html.append(CmsWorkplace.getSkinUri());
        html.append("admin/javascript/list.js'></script>\n");
        html.append("<script type='text/javascript'><!--\n");
        html.append("function showAjaxOk() {\n");
        html.append("\tdocument.getElementById('ajaxreport-img').src = '");
        html.append(CmsWorkplace.getSkinUri());
        html.append("commons/ok.png';\n");
        html.append("\tdocument.getElementById('ajaxreport-txt').innerHTML = '");
        html.append(key(Messages.GUI_OPERATION_NO_LOCKS_0));
        html.append("';\n");
        html.append("}\n");
        html.append("var ajaxReportContent = '';\n");
        html.append("var ajaxWaitMessage = '");
        html.append(CmsStringUtil.escapeJavaScript(buildAjaxWaitMessage()));
        html.append("';\n");
        html.append("function showAjaxReportContent() {\n");
        html.append("\tif (ajaxReportContent != '') {\n");
        html.append("\t\tdocument.getElementById('ajaxreport').innerHTML = ajaxReportContent;\n");
        html.append("\t}\n");
        html.append("}\n");
        html.append("function doReportUpdate(msg, state) {\n");
        html.append("\tvar img = state + '.png';\n");
        html.append("\tvar txt = '';\n");
        html.append("\tvar locks = -1;\n");
        html.append("\tvar blockinglocks = -1;\n");
        html.append("\tvar elem = document.getElementById('ajaxreport');\n");
        html.append("\tif (state != 'ok') {\n");
        html.append("\t\tif (state != 'wait') {\n");
        html.append("\t\t\tdocument.getElementById('lock-body-id').className = '';\n");
        html.append("\t\t}\n");
        html.append("\t\tvar img = state + '.png';\n");
        html.append("\t\tvar txt = msg;\n");
        html.append("\t\tif (state == 'fatal') {\n");
        html.append("\t\t\timg = 'error.png';\n");
        html.append("\t\t\ttxt = '");
        html.append(key(org.opencms.workplace.Messages.GUI_AJAX_REPORT_GIVEUP_0));
        html.append("';\n");
        html.append("\t\t} else if (state == 'wait') {\n");
        html.append("\t\t\timg = 'wait.gif';\n");
        html.append("\t\t\ttxt = '");
        html.append(key(org.opencms.workplace.Messages.GUI_AJAX_REPORT_WAIT_0));
        html.append("'\n");
        html.append("\t\t} else if (state == 'error') {\n");
        html.append("\t\t\ttxt = '");
        html.append(key(org.opencms.workplace.Messages.GUI_AJAX_REPORT_ERROR_0));
        html.append("' + msg;\n");
        html.append("\t\t}\n");
        html.append("\t\tdocument.getElementById('ajaxreport-img').src = '");
        html.append(CmsWorkplace.getSkinUri());
        html.append("commons/' + img;\n");
        html.append("\t\tdocument.getElementById('ajaxreport-txt').innerHTML = txt;\n");
        html.append("\t} else {\n");
        html.append("\t\telem.innerHTML = elem.innerHTML + msg.substring(0, 120);\n");
        html.append("\t\tajaxReportContent = msg;\n");
        html.append("\t}\n");
        html.append("\tif (txt != '') {\n");
        html.append("\t}\n");
        html.append("\tif (state == 'ok') {\n");
        html.append("\t\tlocks = document.forms['main'].locks.value;\n");
        html.append("\t\tblockinglocks = document.forms['main'].blockinglocks.value;\n");
        html.append("\t}\n");
        html.append("\tsetConfirmationMessage(locks, blockinglocks);\n");
        html.append("}\n");
        html.append("// -->\n");
        html.append("</script>\n");
        return html.toString();
    }

    /**
     * Returns the html code to build the lock request.<p>
     * 
     * @return html code
     */
    public String buildLockRequest() {

        return buildLockRequest(0, false);
    }

    /**
     * Returns the html code to build the lock request.<p>
     * 
     * @param hiddenTimeout the maximal number of millis the dialog will be hidden
     * @param includeRelated indicates if the report should include related resources
     * 
     * @return html code
     */
    public String buildLockRequest(int hiddenTimeout, boolean includeRelated) {

        StringBuffer html = new StringBuffer(512);
        html.append("<script type='text/javascript'><!--\n");
        html.append("makeRequest('");
        html.append(getJsp().link("/system/workplace/commons/report-locks.jsp"));
        html.append("', '");
        html.append(CmsMultiDialog.PARAM_RESOURCELIST);
        html.append("=");
        html.append(getParamResourcelist());
        html.append("&");
        html.append(CmsDialog.PARAM_RESOURCE);
        html.append("=");
        html.append(getParamResource());
        html.append("&");
        html.append(CmsLock.PARAM_INCLUDERELATED);
        html.append("=");
        html.append(includeRelated);
        html.append("', 'doReportUpdate');\n");
        html.append("function showLockDialog() {\n");
        html.append("\tdocument.getElementById('lock-body-id').className = '';\n");
        html.append("}\n");
        html.append("setTimeout('showLockDialog()', " + hiddenTimeout + ");\n");
        html.append("// -->\n");
        html.append("</script>\n");
        return html.toString();
    }

    /**
     * Returns the report of all locked subresources.<p>
     * 
     * @return the report of all locked subresources
     * 
     * @throws JspException if dialog actions fail
     * @throws IOException in case of errros forwarding to the required result page
     * @throws ServletException in case of errros forwarding to the required result page
     */
    public String buildReport() throws JspException, ServletException, IOException {

        List lockedResources;
        if (Boolean.valueOf(getParamShowownlocks()).booleanValue()) {
            lockedResources = getLockedResources();
        } else {
            lockedResources = new ArrayList(getBlockingLockedResources());
        }
        Collections.sort(lockedResources);
        Map lockParams = new HashMap();
        if (getParamResource() != null) {
            lockParams.put(PARAM_RESOURCE, getParamResource());
        }
        if (getParamResourcelist() != null) {
            lockParams.put(PARAM_RESOURCELIST, getParamResourcelist());
        }
        if (getParamShowownlocks() != null) {
            lockParams.put(PARAM_SHOWOWNLOCKS, getParamShowownlocks());
        }
        if (getParamIncluderelated() != null) {
            lockParams.put(PARAM_INCLUDERELATED, getParamIncluderelated());
        }

        CmsLockedResourcesList list = new CmsLockedResourcesList(
            getJsp(),
            lockedResources,
            CmsResource.getParentFolder((String)getResourceList().get(0)),
            lockParams);
        list.actionDialog();
        list.getList().setBoxed(false);

        StringBuffer result = new StringBuffer(512);
        result.append("<input type='hidden' name='locks' value='");
        result.append(getLockedResources().size()).append("'>\n");
        result.append("<input type='hidden' name='blockinglocks' value='");
        result.append(getBlockingLockedResources().size()).append("'>\n");
        result.append(CmsStringUtil.padLeft("", 120 - result.length()));
        result.append(CmsListExplorerColumn.getExplorerStyleDef());
        result.append("<div style='height:150px; overflow: auto;'>\n");
        result.append(list.getList().listHtml());
        result.append("</div>\n");
        return result.toString();
    }

    /**
     * Builds the necessary button row.<p>
     * 
     * @return the button row 
     */
    public String dialogButtons() {

        if (CmsLock.getDialogAction(getCms()) != CmsLock.TYPE_LOCKS) {
            return dialogButtonsOkCancel();
        } else {
            return dialogButtonsClose();
        }
    }

    /**
     * Returns the filter to get all blocking locks.<p>
     *
     * @return the filter to get all blocking locks
     */
    public CmsLockFilter getBlockingFilter() {

        if (m_blockingFilter == null) {
            m_blockingFilter = CmsLockFilter.FILTER_ALL;
            m_blockingFilter = m_blockingFilter.filterNotLockableByUser(getCms().getRequestContext().currentUser());
        }
        return m_blockingFilter;
    }

    /**
     * Returns locked resources that do not belong to the current user.<p>
     * 
     * @return the locked Resources
     */
    public Set getBlockingLockedResources() {

        Set blockingResources = new HashSet();
        Iterator i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = (String)i.next();
            try {
                blockingResources.addAll(getCms().getLockedResources(resName, getBlockingFilter()));
            } catch (CmsException e) {
                // error reading a resource, should usually never happen
                if (LOG.isErrorEnabled()) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            if (Boolean.valueOf(getParamIncluderelated()).booleanValue()) {
                addLockedRelatedResources(resName, getBlockingFilter(), blockingResources);
            }
        }
        m_blockingLocks = blockingResources.size();
        return blockingResources;
    }

    /**
     * Returns the number of blocking locks.<p>
     *
     * @return the number of  blocking locks
     */
    public int getBlockingLocks() {

        if (m_blockingLocks == -1) {
            // to initialize the blocking locks flag
            getLockedResources();
        }
        return m_blockingLocks;
    }

    /**
     * Returns the confirmation message.<p>
     * 
     * @param state if <code>true</code> everything is ok
     * 
     * @return the confirmation message
     */
    public String getConfirmationMessage(boolean state) {

        if (getDialogAction(getCms()) == TYPE_LOCKS) {
            return "";
        }
        if (state) {
            if (isMultiOperation()) {
                return key(Messages.GUI_LOCK_MULTI_LOCK_CONFIRMATION_0);
            } else {
                return key(Messages.GUI_LOCK_CONFIRMATION_0);
            }
        }
        switch (getDialogAction(getCms())) {
            case TYPE_LOCK:
                if (isMultiOperation()) {
                    return key(Messages.GUI_LOCK_MULTI_INFO_LOCKEDSUBRESOURCES_0);
                } else {
                    return key(Messages.GUI_LOCK_INFO_LOCKEDSUBRESOURCES_0);
                }
            case TYPE_LOCKCHANGE:
                return key(Messages.GUI_LOCK_CHANGE_CONFIRMATION_0);
            case TYPE_UNLOCK:
                if (isMultiOperation()) {
                    return key(Messages.GUI_LOCK_MULTI_UNLOCK_CONFIRMATION_0);
                } else {
                    return key(Messages.GUI_LOCK_UNLOCK_CONFIRMATION_0);
                }
            case TYPE_LOCKS:
            default:
                return "";
        }
    }

    /**
     * @see org.opencms.workplace.I_CmsDialogHandler#getDialogHandler()
     */
    public String getDialogHandler() {

        return CmsDialogSelector.DIALOG_LOCK;
    }

    /**
     * @see org.opencms.workplace.I_CmsDialogHandler#getDialogUri(java.lang.String, CmsJspActionElement)
     */
    public String getDialogUri(String resource, CmsJspActionElement jsp) {

        switch (getDialogAction(jsp.getCmsObject())) {
            case TYPE_LOCK:
                return URI_LOCK_DIALOG;
            case TYPE_LOCKCHANGE:
                return URI_LOCKCHANGE_DIALOG;
            case TYPE_UNLOCK:
                return URI_UNLOCK_DIALOG;
            case TYPE_LOCKS:
            default:
                return URI_LOCKS_DIALOG;
        }
    }

    /**
     * Returns all the locked Resources.<p>
     *
     * @return all the locked Resources
     */
    public List getLockedResources() {

        if (m_lockedResources == null) {
            // collect my locked resources
            Set lockedResources = new HashSet();
            Iterator i = getResourceList().iterator();
            while (i.hasNext()) {
                String resName = (String)i.next();
                try {
                    lockedResources.addAll(getCms().getLockedResources(resName, getNonBlockingFilter()));

⌨️ 快捷键说明

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