Class DefaultWebInterfaceContext
java.lang.Object
com.atlassian.confluence.plugin.descriptor.web.DefaultWebInterfaceContext
- All Implemented Interfaces:
ContextMap<String,
,Object> WebInterfaceContext
,Map<String,
Object>
@ParametersAreNonnullByDefault
public class DefaultWebInterfaceContext
extends Object
implements WebInterfaceContext
Implementation which stores everything in a map for easy conversion and copying, if not type safety.
-
Nested Class Summary
-
Field Summary
Fields inherited from interface com.atlassian.confluence.plugin.descriptor.web.WebInterfaceContext
CONTEXT_KEY_ATTACHMENT, CONTEXT_KEY_COMMENT, CONTEXT_KEY_CONTENT_DRAFT, CONTEXT_KEY_DRAFT, CONTEXT_KEY_EDIT_PAGE_RESTRICTED, CONTEXT_KEY_LABEL, CONTEXT_KEY_PAGE, CONTEXT_KEY_PARENT_PAGE, CONTEXT_KEY_PERSONAL_INFORMATION, CONTEXT_KEY_SPACE, CONTEXT_KEY_SPACE_ID, CONTEXT_KEY_SPACE_KEY, CONTEXT_KEY_TARGET_USER, CONTEXT_KEY_USER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultWebInterfaceContext
copyOf
(WebInterfaceContext webInterfaceContext) static DefaultWebInterfaceContext
createFrom
(Map<String, ?> contextMap) Creates a newDefaultWebInterfaceContext
with a copy of the data from another context map.@Nullable Attachment
Returns the attachment related to the web interface state, or null if there is no attachment.@Nullable Comment
Returns the comment related to the web interface state, or null if there is no comment.@Nullable ContentEntityObject
Deprecated.since 5.9.@Nullable ConfluenceUser
@Nullable Draft
getDraft()
Deprecated.since 5.9.@Nullable DisplayableLabel
getLabel()
Returns the label related to the web interface state, or null if there is no label.@Nullable AbstractPage
getPage()
Returns the page related to the web interface state, or null if there is no page.@Nullable Object
getParameter
(String key) Returns a custom parameter, or null if the parameter has not been set.@Nullable AbstractPage
Returns the parent page related to the web interface state, or null if there is no parent page.@Nullable PersonalInformation
Returns the personal information (i.e.@Nullable Space
getSpace()
Returns the space related to the web interface state, or null if there is no space.Returns the space-id of the space related to the web interface state, if such space exists.@Nullable String
Returns the space-key related to the web interface state, or null if there is no space-key.@Nullable ConfluenceUser
boolean
hasParameter
(String key) Returns true if the parameter has been set (even if it is set to null).boolean
Deprecated.since 5.9.putAllMissing
(WebInterfaceContext source) Put all missing parameters from source into current web interface contextvoid
setAttachment
(Attachment attachment) void
setComment
(Comment comment) void
setCurrentUser
(@Nullable ConfluenceUser user) Set the current user on the contextvoid
setIsEditPageRestricted
(boolean restricted) Deprecated.since 5.9.void
setLabel
(DisplayableLabel label) void
setPage
(@Nullable AbstractPage page) void
setParameter
(String key, @Nullable Object value) void
setParameters
(Map<String, ?> parameters) void
setPersonalInformation
(PersonalInformation personalInformation) void
void
setTargetedUser
(@Nullable ConfluenceUser user) toMap()
Converts the parameters into a map using the "context keys" defined as constants in this class.void
withLazyParameter
(String key, Supplier<?> supplier) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.confluence.plugin.descriptor.web.ContextMap
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
DefaultWebInterfaceContext
public DefaultWebInterfaceContext()
-
-
Method Details
-
copyOf
- Since:
- 5.8
-
createFrom
Creates a newDefaultWebInterfaceContext
with a copy of the data from another context map. If the other context is also an implementation ofDefaultWebInterfaceContext
, then any lazy properties will be copied intact, and will not be evaluated.- Since:
- 5.8
-
getCurrentUser
- Specified by:
getCurrentUser
in interfaceWebInterfaceContext
- Returns:
- the current user or null if there is no user logged in.
-
setCurrentUser
Set the current user on the context- Parameters:
user
- the current user- Since:
- 5.2
-
getPage
Description copied from interface:WebInterfaceContext
Returns the page related to the web interface state, or null if there is no page.- Specified by:
getPage
in interfaceWebInterfaceContext
-
getDraft
Deprecated.since 5.9. Use only if you still need access to legacy drafts, otherwise usegetPage()
Description copied from interface:WebInterfaceContext
Returns a draft related to the web interface state, or null if there is no draft.- Specified by:
getDraft
in interfaceWebInterfaceContext
-
getContentDraft
Deprecated.since 5.9. UsegetPage()
Description copied from interface:WebInterfaceContext
Returns a draft related to the web interface state, or null if there is no draft.- Specified by:
getContentDraft
in interfaceWebInterfaceContext
-
setPage
-
getSpace
Description copied from interface:WebInterfaceContext
Returns the space related to the web interface state, or null if there is no space.- Specified by:
getSpace
in interfaceWebInterfaceContext
-
getSpaceId
Description copied from interface:WebInterfaceContext
Returns the space-id of the space related to the web interface state, if such space exists.- Specified by:
getSpaceId
in interfaceWebInterfaceContext
-
getSpaceKey
Description copied from interface:WebInterfaceContext
Returns the space-key related to the web interface state, or null if there is no space-key.- Specified by:
getSpaceKey
in interfaceWebInterfaceContext
-
setSpace
-
getComment
Description copied from interface:WebInterfaceContext
Returns the comment related to the web interface state, or null if there is no comment.- Specified by:
getComment
in interfaceWebInterfaceContext
-
setComment
-
getLabel
Description copied from interface:WebInterfaceContext
Returns the label related to the web interface state, or null if there is no label.- Specified by:
getLabel
in interfaceWebInterfaceContext
-
setLabel
-
getAttachment
Description copied from interface:WebInterfaceContext
Returns the attachment related to the web interface state, or null if there is no attachment.- Specified by:
getAttachment
in interfaceWebInterfaceContext
-
setAttachment
-
getPersonalInformation
Description copied from interface:WebInterfaceContext
Returns the personal information (i.e. user profile) that is related to the web interface state, or null if there is no personal information.- Specified by:
getPersonalInformation
in interfaceWebInterfaceContext
-
setPersonalInformation
-
getParameter
Description copied from interface:WebInterfaceContext
Returns a custom parameter, or null if the parameter has not been set.- Specified by:
getParameter
in interfaceWebInterfaceContext
-
hasParameter
Description copied from interface:WebInterfaceContext
Returns true if the parameter has been set (even if it is set to null). Useful for checking boolean custom parameters.- Specified by:
hasParameter
in interfaceWebInterfaceContext
-
setParameter
-
setParameters
-
withLazyParameter
- Since:
- 7.0.1
-
toMap
Description copied from interface:WebInterfaceContext
Converts the parameters into a map using the "context keys" defined as constants in this class. Parameters which have not been set may be omitted from the resulting map.- Specified by:
toMap
in interfaceContextMap<String,
Object> - Specified by:
toMap
in interfaceWebInterfaceContext
- Returns:
- mutable copy of the context map
-
getTargetedUser
- Specified by:
getTargetedUser
in interfaceWebInterfaceContext
- Returns:
- the user targeted by the action, or null if there is none. The targeted user is the user the action is performing against, not necessarily the logged in user.
-
setTargetedUser
- Parameters:
user
- the user targeted by the current action.- Since:
- 5.2
-
setIsEditPageRestricted
Deprecated.since 5.9. Use proper permissions checks on the content -
isEditPageRestricted
Deprecated.since 5.9. Use proper permissions checks on the contentDescription copied from interface:WebInterfaceContext
Indicates if the current edit page is restricted (i.e. has some kind of permissions in place).- Specified by:
isEditPageRestricted
in interfaceWebInterfaceContext
-
getParentPage
Description copied from interface:WebInterfaceContext
Returns the parent page related to the web interface state, or null if there is no parent page.- Specified by:
getParentPage
in interfaceWebInterfaceContext
-
putAllMissing
Put all missing parameters from source into current web interface context- Parameters:
source
- which contains parameters to be copied in.- Returns:
- current context
- Since:
- 5.10
-