📄 a_cmsbackoffice.java
字号:
}
return o;
}
/**
* Gets the content definition class method constructor
* @return content definition object
*/
protected Object getContentDefinition(CmsObject cms, Class cdClass, String id) {
Object o = null;
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;
}
/**
* @param cms A CmsObject to read the user with
* @param id The id of the user to read
* @return The name of the user, or the id (as a String) in case the user has been deleted
*/
public String readSaveUserName(CmsObject cms, int id) {
String userName = null;
try{
userName = cms.readUser(id).getName();
} catch(Exception e) {
userName = "" + id;
}
return userName;
}
/**
* @param cms A CmsObject to read the group with
* @param id The id of the group to read
* @return The name of the group, or the id (as a String) in case the group has been deleted
*/
public String readSaveGroupName(CmsObject cms, int id) {
String groupName = null;
try{
groupName = cms.readGroup(id).getName();
} catch(Exception e) {
groupName = "" + id;
}
return groupName;
}
/**
* 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.
* @throws 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.
* @throws 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.
* @throws 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 = readSaveUserName(cms, ((I_CmsExtendedContentDefinition) o).getOwner());
String curGroup = readSaveGroupName(cms, ((I_CmsExtendedContentDefinition) o).getGroupId());
//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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -