org.opencms.workplace.explorer
Class CmsNewResource

java.lang.Object
  extended by org.opencms.workplace.CmsWorkplace
      extended by org.opencms.workplace.tools.CmsToolDialog
          extended by org.opencms.workplace.CmsDialog
              extended by org.opencms.workplace.explorer.CmsNewResource
Direct Known Subclasses:
CmsNewResourceFolder, CmsNewResourcePointer, CmsNewResourceUpload, CmsNewResourceXmlContent, CmsNewResourceXmlPage

public class CmsNewResource
extends CmsDialog

The new resource entry dialog which displays the possible "new actions" for the current user.

It handles the creation of "simple" resource types like plain or JSP resources.

The following files use this class:

Since:
6.0.0
Version:
$Revision: 1.23 $
Author:
Andreas Zahner, Armen Markarian

Field Summary
static int ACTION_NEWFORM
          The value for the resource name form action.
static int ACTION_SUBMITFORM
          The value for the resource name form submission action.
static int BUTTON_NEXT
          Constant for the "Next" button in the build button methods.
static String DIALOG_NEWFORM
          The name for the resource form action.
static String DIALOG_SUBMITFORM
          The name for the resource form submission action.
static String DIALOG_TYPE
          The dialog type.
static String PARAM_CURRENTFOLDER
          Request parameter name for the current folder name.
static String PARAM_NEWRESOURCEEDITPROPS
          Request parameter name for the new resource edit properties flag.
static String PARAM_NEWRESOURCETYPE
          Request parameter name for the new resource type.
static String PARAM_NEWRESOURCEURI
          Request parameter name for the new resource uri.
 
Fields inherited from class org.opencms.workplace.CmsDialog
ACTION_CANCEL, ACTION_CLOSEPOPUP, ACTION_CLOSEPOPUP_SAVE, ACTION_CONFIRMED, ACTION_DEFAULT, ACTION_OK, ACTION_REPORT_BEGIN, ACTION_REPORT_END, ACTION_REPORT_UPDATE, ACTION_SET, ACTION_WAIT, ATTRIBUTE_THROWABLE, BUTTON_ADVANCED, BUTTON_BACK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_CONTINUE, BUTTON_DETAILS, BUTTON_DISCARD, BUTTON_EDIT, BUTTON_OK, BUTTON_OK_NO_SUBMIT, BUTTON_SET, DIALOG_BACK, DIALOG_CANCEL, DIALOG_CONFIRMED, DIALOG_CONTINUE, DIALOG_INITIAL, DIALOG_OK, DIALOG_SET, DIALOG_WAIT, PARAM_ACTION, PARAM_CLOSELINK, PARAM_DIALOGTYPE, PARAM_ERRORSTACK, PARAM_FILE, PARAM_FRAMENAME, PARAM_ISPOPUP, PARAM_LOCK, PARAM_MESSAGE, PARAM_REDIRECT, PARAM_RESOURCE, PARAM_TARGET, PARAM_THREAD, PARAM_THREAD_HASNEXT, PARAM_TITLE, REPORT_BEGIN, REPORT_END, REPORT_UPDATE
 
Fields inherited from class org.opencms.workplace.tools.CmsToolDialog
PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW
 
Fields inherited from class org.opencms.workplace.CmsWorkplace
DEBUG, DEFAULT_LANGUAGE, DEFAULT_LOCALE, DIALOG_PATH_COMMON, FILE_DIALOG_CLOSE, FILE_DIALOG_SCREEN_CONFIRM, FILE_DIALOG_SCREEN_ERROR, FILE_DIALOG_SCREEN_ERRORPAGE, FILE_DIALOG_SCREEN_WAIT, FILE_EXPLORER_FILELIST, FILE_REPORT_OUTPUT, HTML_END, HTML_START, PARAM_WP_EXPLORER_RESOURCE, PARAM_WP_PROJECT, PARAM_WP_SITE, PATH_DIALOGS, PATH_WORKPLACE, REQUEST_ATTRIBUTE_MULTIPART, REQUEST_ATTRIBUTE_RELOADTREE, RFS_PATH_RESOURCES, SESSION_WORKPLACE_CLASS, TEMP_FILE_PREFIX, VFS_DIR_DEFAULTBODIES, VFS_DIR_TEMPLATES, VFS_PATH_COMMONS, VFS_PATH_EDITORS, VFS_PATH_GALLERIES, VFS_PATH_LOCALES, VFS_PATH_MODULES, VFS_PATH_RESOURCES, VFS_PATH_SYSTEM, VFS_PATH_VIEWS, VFS_PATH_WORKPLACE
 
Constructor Summary
CmsNewResource(CmsJspActionElement jsp)
          Public constructor with JSP action element.
CmsNewResource(PageContext context, HttpServletRequest req, HttpServletResponse res)
          Public constructor with JSP variables.
 
Method Summary
 void actionCreateResource()
          Creates the resource using the specified resource name and the newresourcetype parameter.
 void actionEditProperties()
          Forwards to the property dialog if the resourceeditprops parameter is true.
 void actionSelect()
          Forwards to the next page of the new resource wizard after selecting the new resource type.
 String buildNewList(String attributes)
          Builds the html for the list of possible new resources.
protected  String computeCurrentFolder()
          Returns the full path of the current workplace folder.
protected  String computeFullResourceName()
          Appends the full path to the new resource name given in the resource parameter.
 String computeNewTitleProperty()
          Returns the value for the Title property from the given resource name.
protected  CmsProperty createPropertyObject(String name, String value)
          Creates a single property object and sets the value individual or shared depending on the OpenCms settings.
protected  List createResourceProperties(String resourceName, String resTypeName, String title)
          Returns the properties to create automatically with the new VFS resource.
protected  void dialogButtonsHtml(StringBuffer result, int button, String attribute)
          Renders the HTML for a single input button of a specified type.
 String dialogButtonsNextCancel(String nextAttrs, String cancelAttrs)
          Builds a button row with an "next" and a "cancel" button.
static Object getNewResourceHandler(String type, String defaultClassName, PageContext context, HttpServletRequest req, HttpServletResponse res)
          A factory to return handlers to create new resources.
 String getParamCurrentFolder()
          Returns the current folder set by the http request.
 String getParamNewResourceEditProps()
          Returns the new resource edit properties flag parameter.
 String getParamNewResourceType()
          Returns the new resource type parameter.
 String getParamNewResourceUri()
          Returns the new resource URI parameter.
 String getParamPage()
          Returns the paramPage.
protected  void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request)
          Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.
 boolean isResourceCreated()
          Returns true if the resource is created successfully; otherwise false.
 void setParamCurrentFolder(String paramCurrentFolder)
          Sets the current folder.
 void setParamNewResourceEditProps(String newResourceEditProps)
          Sets the new resource edit properties flag parameter.
 void setParamNewResourceType(String newResourceType)
          Sets the new resource type parameter.
 void setParamNewResourceUri(String newResourceUri)
          Sets the new resource URI parameter.
 void setParamPage(String paramPage)
          Sets the paramPage.
 void setResourceCreated(boolean successfullyCreated)
          Sets the boolean flag successfullyCreated.
 
Methods inherited from class org.opencms.workplace.CmsDialog
actionCloseDialog, appendDelimiter, checkResourcePermissions, checkResourcePermissions, dialog, dialogBlock, dialogBlockEnd, dialogBlockStart, dialogButtonRow, dialogButtonRowEnd, dialogButtonRowStart, dialogButtons, dialogButtonsClose, dialogButtonsClose, dialogButtonsCloseDetails, dialogButtonsOk, dialogButtonsOk, dialogButtonsOkCancel, dialogButtonsOkCancel, dialogButtonsOkCancelAdvanced, dialogButtonsSetOkCancel, dialogContent, dialogContentEnd, dialogContentStart, dialogEnd, dialogHead, dialogHorizontalSpacer, dialogRow, dialogRowEnd, dialogRowStart, dialogScriptSubmit, dialogSeparator, dialogSpacer, dialogStart, dialogStart, dialogSubheadline, dialogToggleStart, dialogWhiteBox, dialogWhiteBoxEnd, dialogWhiteBoxStart, getAction, getAdministrationBackLink, getCancelAction, getDialogRealUri, getDialogUri, getOnlineHelpUriCustom, getParamAction, getParamCloseLink, getParamDialogtype, getParamFramename, getParamIsPopup, getParamMessage, getParamRedirect, getParamResource, getParamTitle, getState, htmlStart, htmlStart, htmlStart, htmlStartStyle, includeErrorpage, initCmsDialog, isPopup, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamRedirect, setParamResource, setParamTitle
 
Methods inherited from class org.opencms.workplace.tools.CmsToolDialog
dialogTitle, getAdminTool, getCurrentToolPath, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamPath, setParamRoot, setParamStyle, useNewStyle
 
Methods inherited from class org.opencms.workplace.CmsWorkplace
addMessages, allParamsAsHidden, allParamsAsRequest, allParamValues, bodyEnd, bodyStart, bodyStart, buildSelect, buildSelect, button, button, buttonBar, buttonBar, buttonBarHorizontalLine, buttonBarLabel, buttonBarLabel, buttonBarLine, buttonBarLineSpacer, buttonBarSeparator, buttonBarSpacer, buttonBarStartTab, calendarIncludes, calendarIncludes, calendarInit, calendarInit, checkLock, checkLock, decodeParamValue, fillParamValues, fillParamValues, getBroadcastMessageString, getCalendarDate, getCalendarJavaDateFormat, getCalendarLocalizedTime, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStyleUri, getStyleUri, getStyleUri, htmlEnd, initMessages, initSettings, initUserSettings, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, key, key, key, nullToEmpty, paramsAsHidden, paramsAsHidden, paramsAsParameterMap, paramsAsRequest, paramValues, resolveMacros, sendCmsRedirect, sendForward, setForwarded, shortKey, switchToCurrentProject, switchToTempProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_NEWFORM

public static final int ACTION_NEWFORM
The value for the resource name form action.

See Also:
Constant Field Values

ACTION_SUBMITFORM

public static final int ACTION_SUBMITFORM
The value for the resource name form submission action.

See Also:
Constant Field Values

BUTTON_NEXT

public static final int BUTTON_NEXT
Constant for the "Next" button in the build button methods.

See Also:
Constant Field Values

DIALOG_NEWFORM

public static final String DIALOG_NEWFORM
The name for the resource form action.

See Also:
Constant Field Values

DIALOG_SUBMITFORM

public static final String DIALOG_SUBMITFORM
The name for the resource form submission action.

See Also:
Constant Field Values

DIALOG_TYPE

public static final String DIALOG_TYPE
The dialog type.

See Also:
Constant Field Values

PARAM_CURRENTFOLDER

public static final String PARAM_CURRENTFOLDER
Request parameter name for the current folder name.

See Also:
Constant Field Values

PARAM_NEWRESOURCEEDITPROPS

public static final String PARAM_NEWRESOURCEEDITPROPS
Request parameter name for the new resource edit properties flag.

See Also:
Constant Field Values

PARAM_NEWRESOURCETYPE

public static final String PARAM_NEWRESOURCETYPE
Request parameter name for the new resource type.

See Also:
Constant Field Values

PARAM_NEWRESOURCEURI

public static final String PARAM_NEWRESOURCEURI
Request parameter name for the new resource uri.

See Also:
Constant Field Values
Constructor Detail

CmsNewResource

public CmsNewResource(CmsJspActionElement jsp)
Public constructor with JSP action element.

Parameters:
jsp - an initialized JSP action element

CmsNewResource

public CmsNewResource(PageContext context,
                      HttpServletRequest req,
                      HttpServletResponse res)
Public constructor with JSP variables.

Parameters:
context - the JSP page context
req - the JSP request
res - the JSP response
Method Detail

getNewResourceHandler

public static Object getNewResourceHandler(String type,
                                           String defaultClassName,
                                           PageContext context,
                                           HttpServletRequest req,
                                           HttpServletResponse res)
                                    throws CmsRuntimeException
A factory to return handlers to create new resources.

Parameters:
type - the resource type name to get a new resource handler for, as specified in the explorer type settings
defaultClassName - a default handler class name, to be used if the handler class specified in the explorer type settings cannot be found
context - the JSP page context
req - the JSP request
res - the JSP response
Returns:
a new instance of the handler class
Throws:
CmsRuntimeException - if something goes wrong

actionCreateResource

public void actionCreateResource()
                          throws JspException
Creates the resource using the specified resource name and the newresourcetype parameter.

Throws:
JspException - if inclusion of error dialog fails

actionEditProperties

public void actionEditProperties()
                          throws IOException,
                                 JspException,
                                 ServletException
Forwards to the property dialog if the resourceeditprops parameter is true.

If the parameter is not true, the dialog will be closed.

Throws:
IOException - if forwarding to the property dialog fails
ServletException - if forwarding to the property dialog fails
JspException - if an inclusion fails

actionSelect

public void actionSelect()
                  throws IOException,
                         ServletException
Forwards to the next page of the new resource wizard after selecting the new resource type.

Throws:
IOException - if forwarding fails
ServletException - if forwarding fails

buildNewList

public String buildNewList(String attributes)
Builds the html for the list of possible new resources.

Parameters:
attributes - optional attributes for the radio input tags
Returns:
the html for the list of possible new resources

computeNewTitleProperty

public String computeNewTitleProperty()
Returns the value for the Title property from the given resource name.

Additionally translates the new resource name according to the file translation rules.

Returns:
the value for the Title property from the given resource name

dialogButtonsNextCancel

public String dialogButtonsNextCancel(String nextAttrs,
                                      String cancelAttrs)
Builds a button row with an "next" and a "cancel" button.

Parameters:
nextAttrs - optional attributes for the next button
cancelAttrs - optional attributes for the cancel button
Returns:
the button row

getParamCurrentFolder

public String getParamCurrentFolder()
Returns the current folder set by the http request.

If the request parameter value is null/empty then returns the default computed folder.

Returns:
the current folder set by the request param or the computed current folder

getParamNewResourceEditProps

public String getParamNewResourceEditProps()
Returns the new resource edit properties flag parameter.

Returns:
the new resource edit properties flag parameter

getParamNewResourceType

public String getParamNewResourceType()
Returns the new resource type parameter.

Returns:
the new resource type parameter

getParamNewResourceUri

public String getParamNewResourceUri()
Returns the new resource URI parameter.

Returns:
the new resource URI parameter

getParamPage

public String getParamPage()
Returns the paramPage.

Returns:
the paramPage

isResourceCreated

public boolean isResourceCreated()
Returns true if the resource is created successfully; otherwise false.

Returns:
true if the resource is created successfully; otherwise false

setParamCurrentFolder

public void setParamCurrentFolder(String paramCurrentFolder)
Sets the current folder.

Parameters:
paramCurrentFolder - the current folder to set

setParamNewResourceEditProps

public void setParamNewResourceEditProps(String newResourceEditProps)
Sets the new resource edit properties flag parameter.

Parameters:
newResourceEditProps - the new resource edit properties flag parameter

setParamNewResourceType

public void setParamNewResourceType(String newResourceType)
Sets the new resource type parameter.

Parameters:
newResourceType - the new resource type parameter

setParamNewResourceUri

public void setParamNewResourceUri(String newResourceUri)
Sets the new resource URI parameter.

Parameters:
newResourceUri - the new resource URI parameter

setParamPage

public void setParamPage(String paramPage)
Sets the paramPage.

Parameters:
paramPage - the paramPage to set

setResourceCreated

public void setResourceCreated(boolean successfullyCreated)
Sets the boolean flag successfullyCreated.

Parameters:
successfullyCreated - a boolean flag that indicates if the create resource operation was successfull or not

computeCurrentFolder

protected String computeCurrentFolder()
Returns the full path of the current workplace folder.

Returns:
the full path of the current workplace folder

computeFullResourceName

protected String computeFullResourceName()
Appends the full path to the new resource name given in the resource parameter.

Returns:
the full path of the new resource

createPropertyObject

protected CmsProperty createPropertyObject(String name,
                                           String value)
Creates a single property object and sets the value individual or shared depending on the OpenCms settings.

Parameters:
name - the name of the property
value - the value to set
Returns:
an initialized property object

createResourceProperties

protected List createResourceProperties(String resourceName,
                                        String resTypeName,
                                        String title)
Returns the properties to create automatically with the new VFS resource.

If configured, the Title and Navigation properties are set on resource creation.

Parameters:
resourceName - the full resource name
resTypeName - the name of the resource type
title - the Title String to use for the property values
Returns:
the List of initialized property objects

dialogButtonsHtml

protected void dialogButtonsHtml(StringBuffer result,
                                 int button,
                                 String attribute)
Description copied from class: CmsDialog
Renders the HTML for a single input button of a specified type.

Overrides:
dialogButtonsHtml in class CmsDialog
Parameters:
result - a string buffer where the rendered HTML gets appended to
button - a integer key to identify the button
attribute - an optional string with possible tag attributes, or null
See Also:
CmsDialog.dialogButtonsHtml(java.lang.StringBuffer, int, java.lang.String)

initWorkplaceRequestValues

protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings,
                                          HttpServletRequest request)
Description copied from class: CmsWorkplace
Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.

Overrides:
initWorkplaceRequestValues in class CmsDialog
Parameters:
settings - the workplace settings
request - the current request
See Also:
CmsWorkplace.initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)