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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultWebInterfaceContextcopyOf(WebInterfaceContext webInterfaceContext) static DefaultWebInterfaceContextcreateFrom(Map<String, ?> contextMap) Creates a newDefaultWebInterfaceContextwith a copy of the data from another context map.@Nullable AttachmentReturns the attachment related to the web interface state, or null if there is no attachment.@Nullable CommentReturns the comment related to the web interface state, or null if there is no comment.@Nullable ContentEntityObjectDeprecated.since 5.9.@Nullable ConfluenceUser@Nullable DraftgetDraft()Deprecated.since 5.9.@Nullable DisplayableLabelgetLabel()Returns the label related to the web interface state, or null if there is no label.@Nullable AbstractPagegetPage()Returns the page related to the web interface state, or null if there is no page.@Nullable ObjectgetParameter(String key) Returns a custom parameter, or null if the parameter has not been set.@Nullable AbstractPageReturns the parent page related to the web interface state, or null if there is no parent page.@Nullable PersonalInformationReturns the personal information (i.e.@Nullable SpacegetSpace()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 StringReturns the space-key related to the web interface state, or null if there is no space-key.@Nullable ConfluenceUserbooleanhasParameter(String key) Returns true if the parameter has been set (even if it is set to null).booleanDeprecated.since 5.9.putAllMissing(WebInterfaceContext source) Put all missing parameters from source into current web interface contextvoidsetAttachment(Attachment attachment) voidsetComment(Comment comment) voidsetCurrentUser(@Nullable ConfluenceUser user) Set the current user on the contextvoidsetIsEditPageRestricted(boolean restricted) Deprecated.since 5.9.voidsetLabel(DisplayableLabel label) voidsetPage(@Nullable AbstractPage page) voidsetParameter(String key, @Nullable Object value) voidsetParameters(Map<String, ?> parameters) voidsetPersonalInformation(PersonalInformation personalInformation) voidvoidsetTargetedUser(@Nullable ConfluenceUser user) toMap()Converts the parameters into a map using the "context keys" defined as constants in this class.voidwithLazyParameter(String key, Supplier<?> supplier) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.confluence.plugin.descriptor.web.ContextMap
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, valuesMethods 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 newDefaultWebInterfaceContextwith 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:
getCurrentUserin 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:WebInterfaceContextReturns the page related to the web interface state, or null if there is no page.- Specified by:
getPagein interfaceWebInterfaceContext
-
getDraft
Deprecated.since 5.9. Use only if you still need access to legacy drafts, otherwise usegetPage()Description copied from interface:WebInterfaceContextReturns a draft related to the web interface state, or null if there is no draft.- Specified by:
getDraftin interfaceWebInterfaceContext
-
getContentDraft
Deprecated.since 5.9. UsegetPage()Description copied from interface:WebInterfaceContextReturns a draft related to the web interface state, or null if there is no draft.- Specified by:
getContentDraftin interfaceWebInterfaceContext
-
setPage
-
getSpace
Description copied from interface:WebInterfaceContextReturns the space related to the web interface state, or null if there is no space.- Specified by:
getSpacein interfaceWebInterfaceContext
-
getSpaceId
Description copied from interface:WebInterfaceContextReturns the space-id of the space related to the web interface state, if such space exists.- Specified by:
getSpaceIdin interfaceWebInterfaceContext
-
getSpaceKey
Description copied from interface:WebInterfaceContextReturns the space-key related to the web interface state, or null if there is no space-key.- Specified by:
getSpaceKeyin interfaceWebInterfaceContext
-
setSpace
-
getComment
Description copied from interface:WebInterfaceContextReturns the comment related to the web interface state, or null if there is no comment.- Specified by:
getCommentin interfaceWebInterfaceContext
-
setComment
-
getLabel
Description copied from interface:WebInterfaceContextReturns the label related to the web interface state, or null if there is no label.- Specified by:
getLabelin interfaceWebInterfaceContext
-
setLabel
-
getAttachment
Description copied from interface:WebInterfaceContextReturns the attachment related to the web interface state, or null if there is no attachment.- Specified by:
getAttachmentin interfaceWebInterfaceContext
-
setAttachment
-
getPersonalInformation
Description copied from interface:WebInterfaceContextReturns 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:
getPersonalInformationin interfaceWebInterfaceContext
-
setPersonalInformation
-
getParameter
Description copied from interface:WebInterfaceContextReturns a custom parameter, or null if the parameter has not been set.- Specified by:
getParameterin interfaceWebInterfaceContext
-
hasParameter
Description copied from interface:WebInterfaceContextReturns true if the parameter has been set (even if it is set to null). Useful for checking boolean custom parameters.- Specified by:
hasParameterin interfaceWebInterfaceContext
-
setParameter
-
setParameters
-
withLazyParameter
- Since:
- 7.0.1
-
toMap
Description copied from interface:WebInterfaceContextConverts 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:
toMapin interfaceContextMap<String,Object> - Specified by:
toMapin interfaceWebInterfaceContext- Returns:
- mutable copy of the context map
-
getTargetedUser
- Specified by:
getTargetedUserin 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:WebInterfaceContextIndicates if the current edit page is restricted (i.e. has some kind of permissions in place).- Specified by:
isEditPageRestrictedin interfaceWebInterfaceContext
-
getParentPage
Description copied from interface:WebInterfaceContextReturns the parent page related to the web interface state, or null if there is no parent page.- Specified by:
getParentPagein 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
-