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

📄 cmspublishproject.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * 
     * @return the last modification date of the resource
     */
    public String getParamModifieddate() {

        return m_paramModifieddate;
    }

    /**
     * Returns the user who modified the resource which will be published.<p>
     * 
     * @return the user who modified the resource
     */
    public String getParamModifieduser() {

        return m_paramModifieduser;
    }

    /**
     * Returns the value of the project id which will be published.<p>
     * 
     * @return the String value of the project id
     */
    public String getParamProjectid() {

        return m_paramProjectid;
    }

    /**
     * Returns the value of the project name which will be published.<p>
     * 
     * @return the String value of the project name
     */
    public String getParamProjectname() {

        return m_paramProjectname;
    }

    /**
     * Returns if siblings of the resource should be published.<p>
     * 
     * @return <code>"true"</code> (String) if siblings of the resource should be published
     */
    public String getParamPublishsiblings() {

        return m_paramPublishsiblings;
    }

    /**
     * Returns the name of the resource which will be published.<p>
     * 
     * @return the name of the resource
     */
    public String getParamResourcename() {

        return m_paramResourcename;
    }

    /**
     * Returns the value of the subresources parameter.<p>
     * 
     * @return the value of the subresources parameter
     */
    public String getParamSubresources() {
    
        return m_paramSubresources;
    }

    /**
     * Sets if a resource will be directly published.<p>
     * 
     * @param value <code>"true"</code> (String) if a resource will be directly published
     */
    public void setParamDirectpublish(String value) {

        m_paramDirectpublish = value;
    }

    /**
     * Sets the last modification date of the resource which will be published.<p> 
     * 
     * @param value the last modification date of the resource
     */
    public void setParamModifieddate(String value) {

        m_paramModifieddate = value;
    }

    /**
     * Sets the user who modified the resource which will be published.<p> 
     * 
     * @param value the user who modified the resource
     */
    public void setParamModifieduser(String value) {

        m_paramModifieduser = value;
    }

    /**
     * Sets the value of the project id which will be published.<p> 
     * 
     * @param value the String value of the project id
     */
    public void setParamProjectid(String value) {

        m_paramProjectid = value;
    }

    /**
     * Sets the value of the project name which will be published.<p> 
     * 
     * @param value the String value of the project name
     */
    public void setParamProjectname(String value) {

        m_paramProjectname = value;
    }

    /**
     * Sets if siblings of the resource should be published.<p> 
     * 
     * @param value <code>"true"</code> (String) if siblings of the resource should be published
     */
    public void setParamPublishsiblings(String value) {

        m_paramPublishsiblings = value;
    }

    /**
     * Sets the name of the resource which will be published.<p> 
     * 
     * @param value the name of the resource
     */
    public void setParamResourcename(String value) {

        m_paramResourcename = value;
    }

    /**
     * Sets the value of the subresources parameter.<p>
     * 
     * @param paramSubresources the value of the subresources parameter
     */
    public void setParamSubresources(String paramSubresources) {
    
        m_paramSubresources = paramSubresources;
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
     */
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        // fill the parameter values in the get/set methods
        fillParamValues(request);
        // set the dialog type
        setParamDialogtype(DIALOG_TYPE);
        // set the publishing type: publish project or direct publish
       
        if (CmsStringUtil.isNotEmpty(getParamResource()) || isMultiOperation()) {
            setParamDirectpublish(CmsStringUtil.TRUE);
        }
        // set the action for the JSP switch 
        if (DIALOG_CONFIRMED.equals(getParamAction())) {
            if (showUnlockConfirmation()) {
                // show unlock confirmation dialog
                setAction(ACTION_UNLOCK_CONFIRMATION);
            } else {
                // skip unlock confirmation dialog
                setAction(ACTION_CONFIRMED);
            }
        } else if (DIALOG_UNLOCK_CONFIRMED.equals(getParamAction())) {
            setAction(ACTION_CONFIRMED);
        } else if (REPORT_UPDATE.equals(getParamAction())) {
            setAction(ACTION_REPORT_UPDATE);
        } else if (REPORT_BEGIN.equals(getParamAction())) {
            setAction(ACTION_REPORT_BEGIN);
        } else if (REPORT_END.equals(getParamAction())) {
            if (Boolean.valueOf(getParamThreadHasNext()).booleanValue()) {
                // after the link check start the publish thread
                startPublishThread();

                setParamAction(REPORT_UPDATE);
                setAction(ACTION_REPORT_UPDATE);
            } else {
                // ends the publish thread
                setAction(ACTION_REPORT_END);
            }
        } else if (DIALOG_CANCEL.equals(getParamAction())) {
            setAction(ACTION_CANCEL);
        } else {
            setAction(ACTION_DEFAULT);
            // set parameters depending on publishing type
            if (Boolean.valueOf(getParamDirectpublish()).booleanValue()) {
                // check the required permissions to publish the resource directly
                if (!getCms().isManagerOfProject()
                    && !checkResourcePermissions(CmsPermissionSet.ACCESS_DIRECT_PUBLISH, false)) {
                    // no publish permissions for the single resource, set cancel action to close dialog
                    setAction(ACTION_CANCEL);
                    return;
                }
                // determine resource name, last modified date and last modified user of resource
                computePublishResource();
                // add the title for the direct publish dialog 
                setDialogTitle(Messages.GUI_PUBLISH_RESOURCE_1, Messages.GUI_PUBLISH_MULTI_2);
            } else {
                // add the title for the publish project dialog 
                setParamTitle(key(Messages.GUI_PUBLISH_PROJECT_0));
                // determine the project id and name for publishing
                computePublishProject();
                // determine target to close the report
            }
        }
    }

    /**
     * Determine the right project id and name if no request parameter "projectid" is given.<p>
     */
    private void computePublishProject() {

        String projectId = getParamProjectid();
        int id;
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(projectId)) {
            // projectid not found in request parameter,
            id = getCms().getRequestContext().currentProject().getId();
            setParamProjectname(getCms().getRequestContext().currentProject().getName());
            setParamProjectid("" + id);
        } else {
            id = Integer.parseInt(projectId);
            try {
                setParamProjectname(getCms().readProject(id).getName());
            } catch (CmsException e) {
                LOG.error(Messages.get().getBundle().key(Messages.LOG_SET_PROJECT_NAME_FAILED_0), e);
            }
        }
    }

    /**
     * Fills the resource information "resource name", "date last modified" and "last modified by" in parameter values.<p>
     */
    private void computePublishResource() {

        if (! isMultiOperation()) {
            try {
                CmsResource res = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
                setParamResourcename(res.getName());
                setParamModifieddate(CmsDateUtil.getDateTime(
                    new Date(res.getDateLastModified()),
                    DateFormat.SHORT,
                    getLocale()));
                setParamModifieduser(getCms().readUser(res.getUserLastModified()).getName());
            } catch (CmsException e) {
                LOG.error(Messages.get().getBundle().key(Messages.LOG_COMPUTING_PUBRES_FAILED_0), e);
            }
        }
    }

    /**
     * Checks if the unlock confirmation dialog should be displayed.<p>
     * 
     * @return true if some resources of the project are locked, otherwise false 
     */
    private boolean showUnlockConfirmation() {

        try {
            if (Boolean.valueOf(getParamDirectpublish()).booleanValue()) {
                // direct publish: check sub resources of a folder
                if (isOperationOnFolder()) {
                    int count = 0;
                    Iterator i = getResourceList().iterator();
                    while (i.hasNext()) {
                        String resName = (String)i.next();
                        CmsResource res = getCms().readResource(resName, CmsResourceFilter.ALL);
                        if ((res.getState() != CmsResource.STATE_DELETED) && res.isFolder()) {
                            count += getCms().countLockedResources(resName);
                        }
                    }
                    return (count > 0);
                }
            } else {
                // publish project: check all project resources
                int id = Integer.parseInt(getParamProjectid());
                return (getCms().countLockedResources(id) > 0);
            }
        } catch (CmsException e) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_DISPLAY_UNLOCK_INF_FAILED_0), e);
        }
        return false;
    }

    /**
     * Starts the publish thread for the project or a resource.<p>
     * 
     * The type of publish thread is determined by the value of the "directpublish" parameter.<p>
     */
    private void startPublishThread() {

        // create a publish thread from the current publish list
        CmsPublishList publishList = getSettings().getPublishList();
        CmsWorkplaceSettings settings = (CmsWorkplaceSettings)getJsp().getRequest().getSession().getAttribute(
            CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
        CmsPublishThread thread = new CmsPublishThread(getCms(), publishList, settings);

        // set the new thread id and flag that no thread is following
        setParamThread(thread.getUUID().toString());
        setParamThreadHasNext(CmsStringUtil.FALSE);

        // start the publish thread
        thread.start();
    }

}

⌨️ 快捷键说明

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