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.
-
-
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 DefaultWebInterfaceContext
copyOf(WebInterfaceContext webInterfaceContext)
Creates a newDefaultWebInterfaceContext
with a copy of the data from another context.static DefaultWebInterfaceContext
createFrom(Map<String,?> contextMap)
Creates a newDefaultWebInterfaceContext
with the datas from the givenMap
.@Nullable Attachment
getAttachment()
Returns the attachment related to the web interface state, or null if there is no attachment.@Nullable Comment
getComment()
Returns the comment related to the web interface state, or null if there is no comment.@Nullable ContentEntityObject
getContentDraft()
Deprecated.since 5.9.@Nullable ConfluenceUser
getCurrentUser()
@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
getParentPage()
Returns the parent page related to the web interface state, or null if there is no parent page.@Nullable PersonalInformation
getPersonalInformation()
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.Optional<Long>
getSpaceId()
Returns the space-id of the space related to the web interface state, if such space exists.@Nullable String
getSpaceKey()
Returns the space-key related to the web interface state, or null if there is no space-key.@Nullable ConfluenceUser
getTargetedUser()
boolean
hasParameter(String key)
Returns true if the parameter has been set (even if it is set to null).boolean
isEditPageRestricted()
Deprecated.since 5.9.DefaultWebInterfaceContext
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
setLazyParameter(String key, com.google.common.base.Supplier<Object> supplier)
Deprecated.since 7.0.1.void
setPage(@Nullable AbstractPage page)
void
setParameter(String key, @Nullable Object value)
void
setParameters(Map<String,Object> parameters)
void
setPersonalInformation(PersonalInformation personalInformation)
void
setSpace(@Nullable Space space)
void
setTargetedUser(@Nullable ConfluenceUser user)
Map<String,Object>
toMap()
Converts the contents of this object as a Map.void
withLazyParameter(String key, Supplier<Object> 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
-
-
-
-
Method Detail
-
copyOf
public static DefaultWebInterfaceContext copyOf(WebInterfaceContext webInterfaceContext)
Creates a newDefaultWebInterfaceContext
with 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 newDefaultWebInterfaceContext
with the datas from the givenMap
. The map will be copied.- Since:
- 5.8
-
getCurrentUser
public @Nullable ConfluenceUser getCurrentUser()
- Specified by:
getCurrentUser
in 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:WebInterfaceContext
Returns the page related to the web interface state, or null if there is no page.- Specified by:
getPage
in 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:WebInterfaceContext
Returns a draft related to the web interface state, or null if there is no draft.- Specified by:
getDraft
in interfaceWebInterfaceContext
-
getContentDraft
@Deprecated public @Nullable ContentEntityObject 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
public void setPage(@Nullable AbstractPage page)
-
getSpace
public @Nullable Space 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
public Optional<Long> 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
public @Nullable String 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
public void setSpace(@Nullable Space space)
-
getComment
public @Nullable Comment 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
public void setComment(Comment comment)
-
getLabel
public @Nullable DisplayableLabel 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
public void setLabel(DisplayableLabel label)
-
getAttachment
public @Nullable Attachment 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
public void setAttachment(Attachment attachment)
-
getPersonalInformation
public @Nullable PersonalInformation 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
public void setPersonalInformation(PersonalInformation personalInformation)
-
getParameter
public @Nullable Object getParameter(String key)
Description copied from interface:WebInterfaceContext
Returns a custom parameter, or null if the parameter has not been set.- Specified by:
getParameter
in interfaceWebInterfaceContext
-
hasParameter
public boolean hasParameter(String key)
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
-
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:
toMap
in interfaceContextMap<String,Object>
- Specified by:
toMap
in interfaceWebInterfaceContext
- Returns:
- A mutable Map containing a snapshot of the contents of this context.
-
getTargetedUser
public @Nullable ConfluenceUser 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
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:WebInterfaceContext
Indicates if the current edit page is restricted (i.e. has some kind of permissions in place).- Specified by:
isEditPageRestricted
in interfaceWebInterfaceContext
-
getParentPage
public @Nullable AbstractPage 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
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
-
-