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

📄 a_cmsbackoffice.java

📁 java 编写的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    try {
      Constructor c = cdClass.getConstructor(new Class[] {CmsObject.class, String.class});
      o = c.newInstance(new Object[] {cms, id});
    } catch (InvocationTargetException ite) {
      if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
        A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice contentDefinitionConstructor: Invocation target exception!");
      }
    } catch (NoSuchMethodException nsm) {
      if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
    A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice contentDefinitionConstructor: Requested method was not found!");
      }
    } catch (InstantiationException ie) {
      if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
    A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice contentDefinitionConstructor: the reflected class is abstract!");
      }
    } catch (Exception e) {
      if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
        A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice contentDefinitionConstructor: Other exception! "+e);
      }
    if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
      A_OpenCms.log(C_OPENCMS_INFO, e.getMessage() );
    }
  }
  return o;
  }

  /**
  * Gets the content of a given template file.
  * <P>
  * While processing the template file the table entry
  * <code>entryTitle<code> will be displayed in the delete dialog
  *
  * @param cms A_CmsObject Object for accessing system resources
  * @param templateFile Filename of the template file
  * @param elementName not used here
  * @param parameters get the parameters action for the button activity
  * and id for the used content definition instance object
  * @param templateSelector template section that should be processed.
  * @return Processed content of the given template file.
  * @exception CmsException
  */

  public byte[] getContentDelete(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {

    //return var
    byte[] processResult = null;

    // session will be created or fetched
    I_CmsSession session = (CmsSession) cms.getRequestContext().getSession(true);
    //get the class of the content definition
    Class cdClass = getContentDefinitionClass();

    //get (stored) id parameter
    String id = (String) parameters.get("id");
    if (id == null) {
      id = "";
    }

    // get value of hidden input field action
    String action = (String) parameters.get("action");

    //no button pressed, go to the default section!
    //delete dialog, displays the title of the entry to be deleted
    if (action == null || action.equals("")) {
      if (id != "") {
        //set template section
    templateSelector = "delete";

        //create new language file object
    CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);

    //get the dialog from the language file and set it in the template
    template.setData("deletetitle", lang.getLanguageValue("messagebox.title.delete"));
    template.setData("deletedialog", lang.getLanguageValue("messagebox.message1.delete"));
    template.setData("newsentry", id);
    template.setData("setaction", "default");
      }
      // confirmation button pressed, process data!
    } else {
      //set template section
      templateSelector = "done";
      //remove marker
      session.removeValue("iddelete");
      //delete the content definition instance
      Integer idInteger = null;
      try {
        idInteger = Integer.valueOf(id);
      } catch (Exception e) {
    //access content definition constructor by reflection
    Object o = null;
    o = getContentDefinition(cms, cdClass, id);
    //get delete method and delete content definition instance
    try {
         ((A_CmsContentDefinition) o).delete(cms);
    } catch (Exception e1) {
          if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
      A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice: delete method throwed an exception!");
    }
      templateSelector = "deleteerror";
      template.setData("deleteerror", e1.getMessage());
    }
    //finally start the processing
    processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
    return processResult;
      }

      //access content definition constructor by reflection
      Object o = null;
      o = getContentDefinition(cms, cdClass, idInteger);
      //get delete method and delete content definition instance
      try {
        ((A_CmsContentDefinition) o).delete(cms);
      }catch (Exception e) {
        templateSelector = "deleteerror";
        template.setData("deleteerror", e.getMessage());
      }
    }

    //finally start the processing
    processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
    return processResult;
  }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the delete dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @exception CmsException
     */
    public byte[] getContentUndelete(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        //return var
        byte[] processResult = null;

        // session will be created or fetched
        I_CmsSession session = (CmsSession) cms.getRequestContext().getSession(true);
        //get the class of the content definition
        Class cdClass = getContentDefinitionClass();

        //get (stored) id parameter
        String id = (String) parameters.get("id");
        if (id == null) {
            id = "";
        }

        //set template section
        templateSelector = "done";
        //remove marker
        session.removeValue("idundelete");
        //undelete the content definition instance
        Integer idInteger = null;
        try {
            idInteger = Integer.valueOf(id);
        } catch (Exception e) {
            //access content definition constructor by reflection
            Object o = null;
            o = getContentDefinition(cms, cdClass, id);
            //get undelete method and undelete content definition instance
            try {
                ((I_CmsExtendedContentDefinition) o).undelete(cms);
            } catch (Exception e1) {
                if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
                    A_OpenCms.log(C_OPENCMS_INFO, getClassName() + ": Backoffice: undelete method throwed an exception!");
                }
                templateSelector = "undeleteerror";
                template.setData("undeleteerror", e1.getMessage());
            }
            //finally start the processing
            processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
            return processResult;
        }
        //access content definition constructor by reflection
        Object o = null;
        o = getContentDefinition(cms, cdClass, idInteger);
        //get undelete method and undelete content definition instance
        try {
            ((I_CmsExtendedContentDefinition) o).undelete(cms);
        }catch (Exception e) {
            templateSelector = "undeleteerror";
            template.setData("undeleteerror", e.getMessage());
        }

        //finally start the processing
        processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        return processResult;
    }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the delete dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @exception CmsException
     */
    public byte[] getContentCopy(CmsObject cms, CmsXmlWpTemplateFile template, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        //return var
        byte[] processResult = null;

        // session will be created or fetched
        I_CmsSession session = (CmsSession) cms.getRequestContext().getSession(true);
        //get the class of the content definition
        Class cdClass = getContentDefinitionClass();

        //get (stored) id parameter
        String id = (String) parameters.get("id");
        if (id == null) {
            id = "";
        }
        // get value of hidden input field action
        String action = (String) parameters.get("action");

        //no button pressed, go to the default section!
        //copy dialog, displays information of the entry to be copy
        if (action == null || action.equals("")) {
            if (id != "") {
                //access content definition constructor by reflection
                Object o = getContentDefinition(cms, cdClass, new Integer(id));
                // get owner and group of content definition
                String curOwner = cms.readUser(((I_CmsExtendedContentDefinition) o).getOwner()).getName();
                String curGroup = cms.readGroup(((I_CmsExtendedContentDefinition) o).getGroupId()).getName();

                //set template section
                templateSelector = "copy";

                //get the dialog from the language file and set it in the template
                template.setData("username", curOwner);
                template.setData("groupname", curGroup);
                template.setData("id", id);
                template.setData("setaction", "default");
            }
            // confirmation button pressed, process data!
        } else {
            //set template section
            templateSelector = "done";
            //remove marker
            session.removeValue("idcopy");
            //copy the content definition instance
            Integer idInteger = null;
            Object o = null;
            try {
                idInteger = Integer.valueOf(id);
                //access content definition constructor by reflection
                o = getContentDefinition(cms, cdClass, idInteger);
            } catch (Exception e) {
                //access content definition constructor by reflection
                o = getContentDefinition(cms, cdClass, id);
            }

            //get copy method and copy content definition instance
            try {
                ((I_CmsExtendedContentDefinition) o).copy(cms);
            }catch (Exception e) {
                templateSelector = "copyerror";
                template.setData("copyerror", e.getMessage());
            }
        }
        //finally start the processing
        processResult = startProcessing(cms, template, elementName, parameters, templateSelector);
        return processResult;
    }

    /**
     * Gets the content of a given template file.
     * <P>
     * While processing the template file the table entry
     * <code>entryTitle<code> will be displayed in the direct publish dialog
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     * and id for the used content definition instance object
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @exception CmsException
     */

⌨️ 快捷键说明

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