cmsnewresource.java
来自「找了很久才找到到源代码」· Java 代码 · 共 1,095 行 · 第 1/3 页
JAVA
1,095 行
super.actionCloseDialog();
}
/**
* Creates the resource using the specified resource name and the newresourcetype parameter.<p>
*
* @throws JspException if inclusion of error dialog fails
*/
public void actionCreateResource() throws JspException {
try {
// calculate the new resource Title property value
String title = computeNewTitleProperty();
// create the full resource name
String fullResourceName = computeFullResourceName();
// create the Title and Navigation properties if configured
I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(getParamNewResourceType());
List properties = createResourceProperties(fullResourceName, resType.getTypeName(), title);
// create the resource
getCms().createResource(fullResourceName, resType.getTypeId(), null, properties);
setParamResource(fullResourceName);
setResourceCreated(true);
} catch (Throwable e) {
// error creating file, show error dialog
includeErrorpage(this, e);
}
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#actionDialog()
*/
public void actionDialog() throws JspException, ServletException, IOException {
super.actionDialog();
switch (getAction()) {
case ACTION_SUBMITFORM:
actionCreateResource();
if (isResourceCreated()) {
actionEditProperties(); // redirects only if the edit properties option was checked
}
break;
case ACTION_OK:
actionSelect();
break;
case ACTION_NEWFORM:
setParamAction(DIALOG_SUBMITFORM);
break;
case ACTION_DEFAULT:
default:
setParamAction(DIALOG_OK);
break;
}
}
/**
* Forwards to the property dialog if the resourceeditprops parameter is true.<p>
*
* If the parameter is not true, the dialog will be closed.<p>
*
* @throws IOException if forwarding to the property dialog fails
* @throws ServletException if forwarding to the property dialog fails
* @throws JspException if an inclusion fails
*/
public void actionEditProperties() throws IOException, JspException, ServletException {
boolean editProps = Boolean.valueOf(getParamNewResourceEditProps()).booleanValue();
if (editProps) {
// edit properties checkbox checked, forward to property dialog
Map params = new HashMap();
params.put(PARAM_RESOURCE, getParamResource());
if (isCreateIndexMode()) {
params.put(CmsPropertyAdvanced.PARAM_DIALOGMODE, CmsPropertyAdvanced.MODE_WIZARD_INDEXCREATED);
} else {
params.put(CmsPropertyAdvanced.PARAM_DIALOGMODE, CmsPropertyAdvanced.MODE_WIZARD);
}
sendForward(CmsPropertyAdvanced.URI_PROPERTY_DIALOG_HANDLER, params);
} else {
// edit properties not checked, close the dialog
actionCloseDialog();
}
}
/**
* Forwards to the next page of the new resource wizard after selecting the new resource type.<p>
*
* @throws IOException if forwarding fails
* @throws ServletException if forwarding fails
*/
public void actionSelect() throws IOException, ServletException {
String nextUri = getParamNewResourceUri();
if (!nextUri.startsWith("/")) {
// no absolute path given, use default dialog path
nextUri = PATH_DIALOGS + nextUri;
}
setParamAction(DIALOG_NEWFORM);
CmsUriSplitter splitter = new CmsUriSplitter(nextUri);
Map params = CmsRequestUtil.createParameterMap(splitter.getQuery());
params.putAll(paramsAsParameterMap());
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_page)) {
params.remove(PARAM_PAGE);
}
sendForward(splitter.getPrefix(), params);
}
/**
* Returns the value for the Title property from the given resource name.<p>
*
* @return the value for the Title property from the given resource name
*/
public String computeNewTitleProperty() {
return computeNewTitleProperty(getParamResource());
}
/**
* Builds a default button row with a continue and cancel button.<p>
*
* Override this to have special buttons for your dialog.<p>
*
* @return the button row
*/
public String dialogButtons() {
return dialogButtonsAdvancedNextCancel(
" onclick=\"submitAdvanced();\"",
"id=\"nextButton\" disabled=\"disabled\"",
null);
}
/**
* Builds a button row with an optional "advanced", "next" and a "cancel" button.<p>
*
* @param advancedAttrs optional attributes for the advanced button
* @param nextAttrs optional attributes for the next button
* @param cancelAttrs optional attributes for the cancel button
* @return the button row
*/
public String dialogButtonsAdvancedNextCancel(String advancedAttrs, String nextAttrs, String cancelAttrs) {
if (m_limitedRestypes && OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) {
return dialogButtons(new int[] {BUTTON_ADVANCED, BUTTON_NEXT, BUTTON_CANCEL}, new String[] {
advancedAttrs,
nextAttrs,
cancelAttrs});
} else {
return dialogButtons(new int[] {BUTTON_NEXT, BUTTON_CANCEL}, new String[] {nextAttrs, cancelAttrs});
}
}
/**
* Builds a button row with a "next" and a "cancel" button.<p>
*
* @param nextAttrs optional attributes for the next button
* @param cancelAttrs optional attributes for the cancel button
* @return the button row
*/
public String dialogButtonsNextCancel(String nextAttrs, String cancelAttrs) {
return dialogButtons(new int[] {BUTTON_NEXT, BUTTON_CANCEL}, new String[] {nextAttrs, cancelAttrs});
}
/**
* Returns the parameter to check if a ".html" suffix should be added to the new resource name.<p>
*
* @return the parameter to check if a ".html" suffix should be added to the new resource name
*/
public String getParamAppendSuffixHtml() {
return m_paramAppendSuffixHtml;
}
/**
* Returns the current folder set by the http request.<p>
*
* If the request parameter value is null/empty then returns the default computed folder.<p>
*
* @return the current folder set by the request param or the computed current folder
*/
public String getParamCurrentFolder() {
if (CmsStringUtil.isEmpty(m_paramCurrentFolder)) {
return computeCurrentFolder();
}
return m_paramCurrentFolder;
}
/**
* Returns the value of the dialogmode parameter,
* or null if this parameter was not provided.<p>
*
* The dialogmode parameter stores the different modes of the property dialog,
* e.g. for displaying other buttons in the new resource wizard.<p>
*
* @return the value of the usetempfileproject parameter
*/
public String getParamDialogmode() {
return m_paramDialogMode;
}
/**
* Returns the new form URI parameter.<p>
*
* @return the new form URI parameter
*/
public String getParamNewFormUri() {
return m_paramNewFormUri;
}
/**
* Returns the new resource edit properties flag parameter.<p>
*
* @return the new resource edit properties flag parameter
*/
public String getParamNewResourceEditProps() {
return m_paramNewResourceEditProps;
}
/**
* Returns the new resource type parameter.<p>
*
* @return the new resource type parameter
*/
public String getParamNewResourceType() {
return m_paramNewResourceType;
}
/**
* Returns the new resource URI parameter.<p>
*
* @return the new resource URI parameter
*/
public String getParamNewResourceUri() {
return m_paramNewResourceUri;
}
/**
* Returns the paramPage.<p>
*
* @return the paramPage
*/
public String getParamPage() {
return m_paramPage;
}
/**
* Returns true if the current mode is: create an index page in a newly created folder.<p>
*
* @return true if we are in wizard mode to create an index page, otherwise false
*/
public boolean isCreateIndexMode() {
return CmsPropertyAdvanced.MODE_WIZARD_CREATEINDEX.equals(getParamDialogmode());
}
/**
* Returns true if the resource is created successfully; otherwise false.<p>
*
* @return true if the resource is created successfully; otherwise false
*/
public boolean isResourceCreated() {
return m_resourceCreated;
}
/**
* Overrides the super implementation to avoid problems with double reqource input fields.<p>
*
* @see org.opencms.workplace.CmsWorkplace#paramsAsHidden()
*/
public String paramsAsHidden() {
String resourceName = getParamResource();
// remove resource parameter from hidden params to avoid problems with double input fields in form
setParamResource(null);
String params = super.paramsAsHidden();
// set resource parameter to stored value
setParamResource(resourceName);
return params;
}
/**
* Sets the parameter to check if a ".html" suffix should be added to the new resource name.<p>
*
* @param paramAppendSuffixHtml the parameter to check if a ".html" suffix should be added to the new resource name
*/
public void setParamAppendSuffixHtml(String paramAppendSuffixHtml) {
m_paramAppendSuffixHtml = paramAppendSuffixHtml;
}
/**
* Sets the current folder.<p>
*
* @param paramCurrentFolder the current folder to set
*/
public void setParamCurrentFolder(String paramCurrentFolder) {
m_paramCurrentFolder = paramCurrentFolder;
}
/**
* Sets the value of the dialogmode parameter.<p>
*
* @param value the value to set
*/
public void setParamDialogmode(String value) {
m_paramDialogMode = value;
}
/**
* Sets the new form URI parameter.<p>
*
* @param paramNewFormUri the new form URI parameter to set
*/
public void setParamNewFormUri(String paramNewFormUri) {
m_paramNewFormUri = paramNewFormUri;
}
/**
* Sets the new resource edit properties flag parameter.<p>
*
* @param newResourceEditProps the new resource edit properties flag parameter
*/
public void setParamNewResourceEditProps(String newResourceEditProps) {
m_paramNewResourceEditProps = newResourceEditProps;
}
/**
* Sets the new resource type parameter.<p>
*
* @param newResourceType the new resource type parameter
*/
public void setParamNewResourceType(String newResourceType) {
m_paramNewResourceType = newResourceType;
}
/**
* Sets the new resource URI parameter.<p>
*
* @param newResourceUri the new resource URI parameter
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?