Class DefaultWebInterfaceContext
- java.lang.Object
-
- com.atlassian.confluence.plugin.descriptor.web.DefaultWebInterfaceContext
-
- All Implemented Interfaces:
WebInterfaceContext
@ParametersAreNonnullByDefault public class DefaultWebInterfaceContext extends Object implements WebInterfaceContext
Implementation which stores everything in a map for easy conversion and copying, if not type safety.
-
-
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 Constructor Description DefaultWebInterfaceContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DefaultWebInterfaceContextcopyOf(WebInterfaceContext webInterfaceContext)Creates a newDefaultWebInterfaceContextwith a copy of the data from another context.static DefaultWebInterfaceContextcreateFrom(Map<String,?> contextMap)Creates a newDefaultWebInterfaceContextwith the datas from the givenMap.@Nullable AttachmentgetAttachment()Returns the attachment related to the web interface state, or null if there is no attachment.@Nullable CommentgetComment()Returns the comment related to the web interface state, or null if there is no comment.@Nullable ContentEntityObjectgetContentDraft()Deprecated.since 5.9.@Nullable ConfluenceUsergetCurrentUser()@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 AbstractPagegetParentPage()Returns the parent page related to the web interface state, or null if there is no parent page.@Nullable PersonalInformationgetPersonalInformation()Returns the personal information (i.e.@Nullable SpacegetSpace()Returns the space related to the web interface state, or null if there is no space.Optional<Long>getSpaceId()Returns the space-id of the space related to the web interface state, if such space exists.@Nullable StringgetSpaceKey()Returns the space-key related to the web interface state, or null if there is no space-key.@Nullable ConfluenceUsergetTargetedUser()booleanhasParameter(String key)Returns true if the parameter has been set (even if it is set to null).booleanisEditPageRestricted()Deprecated.since 5.9.DefaultWebInterfaceContextputAllMissing(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)voidsetLazyParameter(String key, com.google.common.base.Supplier<Object> supplier)Deprecated.since 7.0.1.voidsetPage(@Nullable AbstractPage page)voidsetParameter(String key, @Nullable Object value)voidsetParameters(Map<String,Object> parameters)voidsetPersonalInformation(PersonalInformation personalInformation)voidsetSpace(@Nullable Space space)voidsetTargetedUser(@Nullable ConfluenceUser user)Map<String,Object>toMap()Converts the contents of this object as a Map.voidwithLazyParameter(String key, Supplier<Object> supplier)
-
-
-
Method Detail
-
copyOf
public static DefaultWebInterfaceContext copyOf(WebInterfaceContext webInterfaceContext)
Creates a newDefaultWebInterfaceContextwith a copy of the data from another context. 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
-
createFrom
public static DefaultWebInterfaceContext createFrom(Map<String,?> contextMap)
Creates a newDefaultWebInterfaceContextwith the datas from the givenMap. The map will be copied.- Since:
- 5.8
-
getCurrentUser
public @Nullable ConfluenceUser getCurrentUser()
- Specified by:
getCurrentUserin interfaceWebInterfaceContext- Returns:
- the current user or null if there is no user logged in.
-
setCurrentUser
public void setCurrentUser(@Nullable ConfluenceUser user)
Set the current user on the context- Parameters:
user- the current user- Since:
- 5.2
-
getPage
public @Nullable AbstractPage 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 public @Nullable Draft 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 public @Nullable ContentEntityObject 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
public void setPage(@Nullable AbstractPage page)
-
getSpace
public @Nullable Space 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
public Optional<Long> 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
public @Nullable String 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
public void setSpace(@Nullable Space space)
-
getComment
public @Nullable Comment 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
public void setComment(Comment comment)
-
getLabel
public @Nullable DisplayableLabel 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
public void setLabel(DisplayableLabel label)
-
getAttachment
public @Nullable Attachment 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
public void setAttachment(Attachment attachment)
-
getPersonalInformation
public @Nullable PersonalInformation 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
public void setPersonalInformation(PersonalInformation personalInformation)
-
getParameter
public @Nullable Object getParameter(String key)
Description copied from interface:WebInterfaceContextReturns a custom parameter, or null if the parameter has not been set.- Specified by:
getParameterin interfaceWebInterfaceContext
-
hasParameter
public boolean hasParameter(String key)
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
-
setLazyParameter
@Deprecated public void setLazyParameter(String key, com.google.common.base.Supplier<Object> supplier)
Deprecated.since 7.0.1. UsewithLazyParameter(String, java.util.function.Supplier)- Since:
- 5.8
-
withLazyParameter
public void withLazyParameter(String key, Supplier<Object> supplier)
- Since:
- 7.0.1
-
toMap
public Map<String,Object> toMap()
Converts the contents of this object as a Map. Note that any lazy attributes of this context will be evaluated as part of this conversion, so this should be defered as long as possible.- Specified by:
toMapin interfaceWebInterfaceContext- Returns:
- A mutable Map containing a snapshot of the contents of this context.
-
getTargetedUser
public @Nullable ConfluenceUser 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
public void setTargetedUser(@Nullable ConfluenceUser user)
- Parameters:
user- the user targeted by the current action.- Since:
- 5.2
-
setIsEditPageRestricted
@Deprecated public void setIsEditPageRestricted(boolean restricted)
Deprecated.since 5.9. Use proper permissions checks on the content
-
isEditPageRestricted
@Deprecated public boolean 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
public @Nullable AbstractPage 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
public DefaultWebInterfaceContext putAllMissing(WebInterfaceContext source)
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
-
-