Package org.opencms.workplace.tools
Class CmsToolMacroResolver
- java.lang.Object
-
- org.opencms.workplace.tools.CmsToolMacroResolver
-
- All Implemented Interfaces:
I_CmsMacroResolver
public class CmsToolMacroResolver extends java.lang.Object implements I_CmsMacroResolver
Resolves special macros for the admin view.Supported macros are:
- admin.userName|id
- admin.groupName|id
- admin.jobName|id
- admin.projectName|id
- admin.ouDescription|fqn
- admin.ouType|fqn
- admin.roleName|id
- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_GROUPNAME
Identifier for admin parameter names.static java.lang.String
KEY_JOBNAME
Identifier for admin parameter names.static java.lang.String
KEY_OUDESCRIPTION
Identifier for admin parameter names.static java.lang.String
KEY_OUTYPE
Identifier for admin parameter names.static java.lang.String
KEY_PROJECTNAME
Identifier for admin parameter names.static java.lang.String
KEY_ROLENAME
Identifier for admin parameter names.static java.lang.String
KEY_USERNAME
Identifier for admin parameter names.static java.lang.String
PREFIX_ADMIN
Identifier for admin macros prefix.static java.lang.String[]
VALUE_NAME_ARRAY
Identified for admin parameter commands.static java.util.List<java.lang.String>
VALUE_NAMES
The admin commands wrapped in a List.-
Fields inherited from interface org.opencms.util.I_CmsMacroResolver
MACRO_DELIMITER, MACRO_DELIMITER_OLD, MACRO_END, MACRO_END_OLD, MACRO_START, MACRO_START_OLD
-
-
Constructor Summary
Constructors Constructor Description CmsToolMacroResolver(CmsWorkplace wp)
Default private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMacroValue(java.lang.String macro)
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.boolean
isKeepEmptyMacros()
Returnstrue
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String.java.lang.String
resolveMacros(java.lang.String input)
Resolves the macros in the given input.static java.lang.String
resolveMacros(java.lang.String input, CmsWorkplace wp)
Resolves the macros in the given input using the provided parameters.
-
-
-
Field Detail
-
PREFIX_ADMIN
public static final java.lang.String PREFIX_ADMIN
Identifier for admin macros prefix.- See Also:
- Constant Field Values
-
KEY_USERNAME
public static final java.lang.String KEY_USERNAME
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_GROUPNAME
public static final java.lang.String KEY_GROUPNAME
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_JOBNAME
public static final java.lang.String KEY_JOBNAME
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_PROJECTNAME
public static final java.lang.String KEY_PROJECTNAME
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_OUDESCRIPTION
public static final java.lang.String KEY_OUDESCRIPTION
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_OUTYPE
public static final java.lang.String KEY_OUTYPE
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
KEY_ROLENAME
public static final java.lang.String KEY_ROLENAME
Identifier for admin parameter names.- See Also:
- Constant Field Values
-
VALUE_NAME_ARRAY
public static final java.lang.String[] VALUE_NAME_ARRAY
Identified for admin parameter commands.
-
VALUE_NAMES
public static final java.util.List<java.lang.String> VALUE_NAMES
The admin commands wrapped in a List.
-
-
Constructor Detail
-
CmsToolMacroResolver
public CmsToolMacroResolver(CmsWorkplace wp)
Default private constructor.- Parameters:
wp
- the workplace instance
-
-
Method Detail
-
resolveMacros
public static java.lang.String resolveMacros(java.lang.String input, CmsWorkplace wp)
Resolves the macros in the given input using the provided parameters.A macro in the form
${key}
in the content is replaced with it's assigned value returned by the
method of the givenI_CmsMacroResolver.getMacroValue(String)
instance.I_CmsMacroResolver
If a macro is found that can not be mapped to a value by the given macro resolver, it is left untouched in the input.
- Parameters:
input
- the input in which to resolve the macroswp
- the workplace class for falling back- Returns:
- the input with the macros resolved
-
getMacroValue
public java.lang.String getMacroValue(java.lang.String macro)
Description copied from interface:I_CmsMacroResolver
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.- Specified by:
getMacroValue
in interfaceI_CmsMacroResolver
- Parameters:
macro
- the macro to resolve- Returns:
- the resolved macro or
null
if the macro could not be resolved - See Also:
I_CmsMacroResolver.getMacroValue(java.lang.String)
-
resolveMacros
public java.lang.String resolveMacros(java.lang.String input)
Resolves the macros in the given input.Calls
until no more macros can be resolved in the input. This way "nested" macros in the input are resolved as well.resolveMacros(String)
- Specified by:
resolveMacros
in interfaceI_CmsMacroResolver
- Parameters:
input
- the input to resolve the macros in- Returns:
- the input with all macros resolved
- See Also:
I_CmsMacroResolver.resolveMacros(java.lang.String)
-
isKeepEmptyMacros
public boolean isKeepEmptyMacros()
Description copied from interface:I_CmsMacroResolver
Returnstrue
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String.- Specified by:
isKeepEmptyMacros
in interfaceI_CmsMacroResolver
- Returns:
true
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String- See Also:
I_CmsMacroResolver.isKeepEmptyMacros()
-
-