public final class

JiraWebContext

extends Object
java.lang.Object
   ↳ com.atlassian.jira.plugin.webfragment.JiraWebContext

Class Overview

Useful wrapper for web contexts.

Context is normally a map but it contains some standard entries which can be easily retrieved using this class.

All getters return empty if requested object is not set in the context map or has a type different than expected.

Summary

Public Methods
static JiraWebContext from(Map<StringObject> context)
<T> Optional<T> get(String key, Class<T> type)
Returns value assigned to the specified key provided it is present in the map and has the specified type.
Optional<JiraHelper> getHelper()
Optional<I18nHelper> getI18n()
Optional<String> getLocation()
Optional<ApplicationUser> getUser()
Tries to figure out the user from context.
Optional<String> getUsername()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static JiraWebContext from (Map<StringObject> context)

public Optional<T> get (String key, Class<T> type)

Returns value assigned to the specified key provided it is present in the map and has the specified type.

Parameters
key entry key
type expected type
Returns
  • value if present

public Optional<JiraHelper> getHelper ()

public Optional<I18nHelper> getI18n ()

public Optional<String> getLocation ()

public Optional<ApplicationUser> getUser ()

Tries to figure out the user from context. It checks the "user" key first and if it does not contain ApplicationUser value then tries to load the user based on the "username" key in the context.

Returns
  • user in the context

public Optional<String> getUsername ()