com.atlassian.confluence.plugin.descriptor.web
Class DefaultWebInterfaceContext

java.lang.Object
  extended by com.atlassian.confluence.plugin.descriptor.web.DefaultWebInterfaceContext
All Implemented Interfaces:
WebInterfaceContext

public class DefaultWebInterfaceContext
extends java.lang.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_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_KEY, CONTEXT_KEY_TARGET_USER, CONTEXT_KEY_USER
 
Constructor Summary
DefaultWebInterfaceContext()
           
DefaultWebInterfaceContext(java.util.Map<java.lang.String,java.lang.Object> context)
          Creates a web interface context from a map generated by toMap().
DefaultWebInterfaceContext(WebInterfaceContext webInterfaceContext)
          Copy constructor: construct a web interface context from another existing context.
 
Method Summary
 Attachment getAttachment()
          Returns the attachment related to the web interface state, or null if there is no attachment.
 Comment getComment()
          Returns the comment related to the web interface state, or null if there is no comment.
 ConfluenceUser getCurrentUser()
           
 Draft getDraft()
          Returns a draft related to the web interface state, or null if there is no draft.
 DisplayableLabel getLabel()
          Returns the label related to the web interface state, or null if there is no label.
 AbstractPage getPage()
          Returns the page related to the web interface state, or null if there is no page.
 java.lang.Object getParameter(java.lang.String key)
          Returns a custom parameter, or null if the parameter has not been set.
 AbstractPage getParentPage()
          Returns the parent page related to the web interface state, or null if there is no parent page.
 PersonalInformation getPersonalInformation()
          Returns the personal information (i.e.
 Space getSpace()
          Returns the space related to the web interface state, or null if there is no space.
 java.lang.String getSpaceKey()
          Returns the space-key related to the web interface state, or null if there is no space-key.
 ConfluenceUser getTargetedUser()
           
 com.atlassian.user.User getTargetUser()
          Deprecated. 
 com.atlassian.user.User getUser()
          Deprecated. 
 boolean hasParameter(java.lang.String key)
          Returns true if the parameter has been set (even if it is set to null).
 boolean isEditPageRestricted()
          Indicates if the current edit page is restricted (i.e.
 void setAttachment(Attachment attachment)
           
 void setComment(Comment comment)
           
 void setCurrentUser(ConfluenceUser user)
          Set the current user on the context
 void setIsEditPageRestricted(boolean restricted)
           
 void setLabel(DisplayableLabel label)
           
 void setPage(AbstractPage page)
           
 void setParameter(java.lang.String key, java.lang.Object value)
           
 void setPersonalInformation(PersonalInformation personalInformation)
           
 void setSpace(Space space)
           
 void setTargetedUser(ConfluenceUser user)
           
 void setTargetUser(com.atlassian.user.User user)
          Deprecated. since 5.2
 void setUser(com.atlassian.user.User user)
          Deprecated. since 5.2. See setCurrentUser(ConfluenceUser).
 java.util.Map<java.lang.String,java.lang.Object> toMap()
          Converts the parameters into a map using the "context keys" defined as constants in this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWebInterfaceContext

public DefaultWebInterfaceContext()

DefaultWebInterfaceContext

public DefaultWebInterfaceContext(java.util.Map<java.lang.String,java.lang.Object> context)
Creates a web interface context from a map generated by toMap().

Parameters:
context - the context parameters in a map

DefaultWebInterfaceContext

public DefaultWebInterfaceContext(WebInterfaceContext webInterfaceContext)
Copy constructor: construct a web interface context from another existing context. The implementation currently assumes that the other context is of this class, so uses toMap() and DefaultWebInterfaceContext(Map) for construction.

Parameters:
webInterfaceContext - the other context to copy the parameters from
Method Detail

getUser

@Deprecated
public com.atlassian.user.User getUser()
Deprecated. 

Description copied from interface: WebInterfaceContext
Returns the current user, or null if there is no user logged in.

Specified by:
getUser in interface WebInterfaceContext

getCurrentUser

public ConfluenceUser getCurrentUser()
Specified by:
getCurrentUser in interface WebInterfaceContext
Returns:
the current user or null if there is no user logged in.

setUser

@Deprecated
public void setUser(com.atlassian.user.User user)
Deprecated. since 5.2. See setCurrentUser(ConfluenceUser).

Parameters:
user -

setCurrentUser

public void setCurrentUser(ConfluenceUser user)
Set the current user on the context

Parameters:
user - the current user
Since:
5.2

getPage

public 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 interface WebInterfaceContext

getDraft

public Draft getDraft()
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 interface WebInterfaceContext

setPage

public void setPage(AbstractPage page)

getSpace

public 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 interface WebInterfaceContext

getSpaceKey

public java.lang.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 interface WebInterfaceContext

setSpace

public void setSpace(Space space)

getComment

public 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 interface WebInterfaceContext

setComment

public void setComment(Comment comment)

getLabel

public 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 interface WebInterfaceContext

setLabel

public void setLabel(DisplayableLabel label)

getAttachment

public 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 interface WebInterfaceContext

setAttachment

public void setAttachment(Attachment attachment)

getPersonalInformation

public 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 interface WebInterfaceContext

setPersonalInformation

public void setPersonalInformation(PersonalInformation personalInformation)

getParameter

public java.lang.Object getParameter(java.lang.String key)
Description copied from interface: WebInterfaceContext
Returns a custom parameter, or null if the parameter has not been set.

Specified by:
getParameter in interface WebInterfaceContext

hasParameter

public boolean hasParameter(java.lang.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 interface WebInterfaceContext

setParameter

public void setParameter(java.lang.String key,
                         java.lang.Object value)

toMap

public java.util.Map<java.lang.String,java.lang.Object> 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 interface WebInterfaceContext

getTargetUser

@Deprecated
public com.atlassian.user.User getTargetUser()
Deprecated. 

Description copied from interface: WebInterfaceContext
Returns the target user of the action, or null if there is no target user. The target user is the user the action is performing against, not necessarily the logged in user.

Specified by:
getTargetUser in interface WebInterfaceContext

getTargetedUser

public ConfluenceUser getTargetedUser()
Specified by:
getTargetedUser in interface WebInterfaceContext
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.

setTargetUser

@Deprecated
public void setTargetUser(com.atlassian.user.User user)
Deprecated. since 5.2

Parameters:
user -

setTargetedUser

public void setTargetedUser(ConfluenceUser user)
Parameters:
user - the user targeted by the current action.
Since:
5.2

setIsEditPageRestricted

public void setIsEditPageRestricted(boolean restricted)

isEditPageRestricted

public boolean isEditPageRestricted()
Description 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 interface WebInterfaceContext

getParentPage

public 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 interface WebInterfaceContext


Copyright © 2003-2014 Atlassian. All Rights Reserved.