@Internal
public interface StructurePluginHelper
StructurePluginHelper
is a helper component that provides a lot of helpful methods and which is extensively
used by Structure plugin itself and by Structure extensions.
As a consumer of Structure API, you can also benefit from using these methods, however, since this class is
marked @Internal
, you may need to retest or recompile your code with every new minor or micro release of
the Structure API.
The methods in this class form several groups:
Modifier and Type | Method and Description |
---|---|
void |
clearAllCaches()
Clears all caches on the current JIRA instance that are maintained by Structure and Structure extensions.
|
void |
clearAllCachesOnAllNodes()
Clears all caches (maintained by Structure and Structure extensions) on the current JIRA instance and causes
eventual caches clearing on other nodes (when running on JIRA Data Center).
|
void |
clearCurrentUserCaches()
Clears caches on the current node for the current user.
|
void |
clearUserCaches(com.atlassian.jira.user.ApplicationUser user)
Clears caches on the current node for the given non-anonymous user.
|
void |
filterInvisibleProjects(com.almworks.integers.LongSizedIterable projects,
com.atlassian.jira.user.ApplicationUser user,
boolean overrideSecurity,
com.almworks.integers.LongCollector invisibleCollector)
Used to figure out which projects are not visible to the user.
|
com.atlassian.jira.security.JiraAuthenticationContext |
getAuthenticationContext() |
List<com.atlassian.crowd.embedded.api.Group> |
getAvailableGroups(com.atlassian.jira.user.ApplicationUser user)
Retrieves the security groups that the user is allowed to see.
|
default List<com.atlassian.crowd.embedded.api.Group> |
getAvailableGroupsForCurrentUser()
Retrieves the security groups that the current user is allowed to see.
|
List<com.atlassian.jira.security.roles.ProjectRole> |
getAvailableRoles()
Retrieves the roles that exist in the system.
|
Collator |
getCollator(com.atlassian.jira.user.ApplicationUser user)
Returns a collator for strings in the user's locale.
|
StructureConfiguration |
getConfiguration()
Retrieves
StructureConfiguration |
default com.atlassian.query.Query |
getConfigurationScopeQuery()
Retrieves a query that limits scope to the projects enabled for Structure.
|
com.atlassian.jira.issue.CustomFieldManager |
getCustomFieldManager() |
com.atlassian.plugin.event.PluginEventManager |
getEventManager() |
com.atlassian.jira.security.GlobalPermissionManager |
getGlobalPermissionManager() |
default com.atlassian.jira.util.I18nHelper |
getI18n()
Retrieves i18n helper for the current user.
|
com.atlassian.jira.util.I18nHelper |
getI18n(com.atlassian.jira.user.ApplicationUser user)
Retrieves i18n helper for a concrete user.
|
com.atlassian.jira.issue.Issue |
getIssue(long issueId)
Retrieves an instance of
Issue . |
com.atlassian.jira.issue.Issue |
getIssue(String key)
Retrieves an instance of issue by issue key.
|
default StructureError |
getIssueError(com.atlassian.jira.issue.Issue issue,
boolean checkEdit)
Convenience method to check issue access for the current user.
|
default StructureError |
getIssueError(com.atlassian.jira.issue.Issue issue,
boolean checkEdit,
boolean checkProjectEnabledForStructure)
Convenience method to check issue access for the current user.
|
StructureError |
getIssueError(com.atlassian.jira.issue.Issue issue,
boolean checkEdit,
boolean checkProjectEnabledForStructure,
com.atlassian.jira.user.ApplicationUser user)
Checks user access to the issue for viewing or editing.
|
default StructureError |
getIssueError(Long issue,
boolean checkEdit)
Convenience method to check issue access for the current user.
|
StructureError |
getIssueError(Long issue,
boolean checkEdit,
com.atlassian.jira.user.ApplicationUser user)
Checks user access to the issue for viewing or editing.
|
com.atlassian.jira.issue.IssueManager |
getIssueManager() |
com.atlassian.jira.jql.operand.JqlOperandResolver |
getJqlOperandResolver() |
com.atlassian.jira.jql.parser.JqlQueryParser |
getJqlQueryParser() |
com.atlassian.jira.jql.util.JqlStringSupport |
getJqlStringSupport() |
Locale |
getLocale()
Returns the current user's locale.
|
com.atlassian.jira.security.PermissionManager |
getPermissionManager() |
com.atlassian.plugin.PluginAccessor |
getPluginAccessor() |
com.atlassian.jira.project.ProjectManager |
getProjectManager() |
com.atlassian.jira.security.roles.ProjectRoleManager |
getProjectRoleManager() |
List<com.atlassian.jira.project.Project> |
getProjectsForCurrentUser()
Retrieves the list of projects that are visible to the current user.
|
com.atlassian.jira.issue.search.SearchRequestManager |
getSearchRequestManager() |
com.atlassian.jira.bc.issue.search.SearchService |
getSearchService() |
com.atlassian.jira.web.session.SessionSearchObjectManagerFactory |
getSessionSearchObjectManagerFactory() |
Comparator<Structure> |
getStructureComparator(com.atlassian.jira.user.ApplicationUser user)
Returns comparator for sorting structures by name, according to the given user's locale.
|
List<com.atlassian.jira.project.Project> |
getStructureProjectsForCurrentUser()
Retrieves the list of projects that are enabled for structure and visible to the current user.
|
com.atlassian.jira.bc.issue.worklog.TimeTrackingConfiguration |
getTimeTrackingConfiguration() |
com.atlassian.jira.user.ApplicationUser |
getUser()
Retrieves the current user.
|
com.atlassian.jira.user.util.UserManager |
getUserManager() |
com.atlassian.jira.user.preferences.UserPreferencesManager |
getUserPreferencesManager() |
boolean |
hasPermission(com.atlassian.jira.permission.GlobalPermissionKey permission,
com.atlassian.jira.user.ApplicationUser user)
Checks if the given user has the given global permission.
|
boolean |
hasPermission(com.atlassian.jira.security.plugin.ProjectPermissionKey permission,
com.atlassian.jira.issue.Issue issue,
com.atlassian.jira.user.ApplicationUser user)
Checks if the given user has the given project-level permission on an issue's project.
|
boolean |
hasPermission(com.atlassian.jira.security.plugin.ProjectPermissionKey permission,
com.atlassian.jira.project.Project project,
com.atlassian.jira.user.ApplicationUser user)
Checks if the given user has the given project-level permission on a project.
|
<T> T |
instantiate(Class<T> clazz)
Creates a new instance of the given class, injecting all dependencies into the constructor.
|
default boolean |
isAdmin()
Checks if the current user is a JIRA administrator (but not necessarily JIRA's "System Administrator"!).
|
boolean |
isAdmin(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user is a JIRA administrator (but not necessarily JIRA's "System Administrator"!).
|
default boolean |
isAuthenticated()
Checks if the current user has authenticated in the system.
|
boolean |
isAutomationAccessAllowed(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user is allowed to create and run generators.
|
boolean |
isCreateStructureAllowed(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user is allowed to create new structures.
|
boolean |
isIssueEditable(com.atlassian.jira.issue.Issue issue,
com.atlassian.jira.user.ApplicationUser user)
Checks if the issue can be edited by the given user.
|
boolean |
isProjectStructuredForCurrentUser(com.atlassian.jira.project.Project project)
Checks if the project is enabled for Structure and the current user can see it.
|
default boolean |
isStructureAvailableToCurrentUser()
Checks if the current user is allowed to work with Structure add-on.
|
boolean |
isStructureAvailableToUser(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user is allowed to work with Structure add-on.
|
boolean |
isStructureLocked()
Returns true when Structure cannot be used because it is locked, either for full restore or for system startup.
|
boolean |
isSynchronizationAllowed(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user is allowed to create and run synchronizers.
|
boolean |
isViewCreationAllowed(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user can create new views.
|
boolean |
isViewSharingAllowed(com.atlassian.jira.user.ApplicationUser user)
Checks if the given user can share views.
|
void |
matchIssues(com.almworks.integers.LongList issues,
com.atlassian.query.Query query,
boolean collectMatching,
com.almworks.integers.LongCollector collector)
Passes the issues through JIRA search engine and lets the caller collect either all matching or non-matching
issues.
|
void |
matchIssuesSorted(com.almworks.integers.LongList issuesSorted,
com.atlassian.query.Query query,
boolean collectMatching,
com.atlassian.jira.user.ApplicationUser user,
boolean overrideSecurity,
com.almworks.integers.LongCollector collector)
A variation of
matchIssuesSorted(LongList, Query, boolean, LongCollector) that lets you specify
the user and override security checks. |
void |
matchIssuesSorted(com.almworks.integers.LongList issuesSorted,
com.atlassian.query.Query query,
boolean collectMatching,
com.almworks.integers.LongCollector collector)
Passes the issues, sorted by their IDs, through JIRA search engine to collect matching or non-matching issues.
|
void |
requireIssueDetailsResources()
Loads resources needed for the issue details layout.
|
void |
requireIssueShortcuts()
Loads resources needed for standard JIRA keyboard shortcuts.
|
void |
requireLocalizedResource(String resourceKey)
Requires a resource that may be localized.
|
void |
requireQuickEditResources()
Loads resources needed for "quick edit" code to work (dialog with editing / creating an issue).
|
void |
requireResource(String resourceKey)
Marks resource as needed for loading.
|
void |
requireResourceIfPresent(String resourceKey)
Marks resource as needed for loading, if the resource exists.
|
void |
requireWidgetResource()
Requires all resources needed to render Structure Widget.
|
com.almworks.integers.LongArray |
searchAndSortQuery(com.atlassian.query.Query query)
Runs search with sorting.
|
com.almworks.integers.LongArray |
searchAndSortQuery(com.atlassian.query.Query query,
int limit)
Runs search with sorting and result count limit.
|
com.almworks.integers.LongArray |
searchAndSortQuery(String query)
Runs JQL search with sorting.
|
com.almworks.integers.LongArray |
searchQuery(com.atlassian.query.Query query)
Runs search.
|
com.almworks.integers.LongArray |
searchQuery(String query)
Runs JQL search.
|
com.atlassian.jira.util.MessageSet |
validateQuery(com.atlassian.jira.user.ApplicationUser user,
com.atlassian.query.Query query)
Checks if the query is valid and that the user has access to all the things mentioned in the query.
|
@Nullable StructureError getIssueError(@Nullable Long issue, boolean checkEdit, @Nullable com.atlassian.jira.user.ApplicationUser user)
issue
- issue IDcheckEdit
- if true, edit permissions are required.user
- user to check fornull
if everything is ok@Nullable default StructureError getIssueError(@Nullable Long issue, boolean checkEdit)
issue
- issue IDcheckEdit
- if true, edit permissions are required.null
if everything is okgetIssueError(Long, boolean, ApplicationUser)
@Contract(value="null, _, _, _ -> !null") @Nullable StructureError getIssueError(@Nullable com.atlassian.jira.issue.Issue issue, boolean checkEdit, boolean checkProjectEnabledForStructure, @Nullable com.atlassian.jira.user.ApplicationUser user)
issue
- issuecheckEdit
- if true, edit permissions are requiredcheckProjectEnabledForStructure
- if true, issue's project must be enabled for Structureuser
- user to check fornull
if everything is ok@Contract(value="null, _ -> !null") @Nullable default StructureError getIssueError(@Nullable com.atlassian.jira.issue.Issue issue, boolean checkEdit)
issue
- issuecheckEdit
- if true, edit permissions are requirednull
if everything is okgetIssueError(Issue, boolean, boolean, ApplicationUser)
@Contract(value="null, _, _ -> !null") @Nullable default StructureError getIssueError(@Nullable com.atlassian.jira.issue.Issue issue, boolean checkEdit, boolean checkProjectEnabledForStructure)
issue
- issuecheckEdit
- if true, edit permissions are requiredcheckProjectEnabledForStructure
- if true, issue's project must be enabled for Structurenull
if everything is okgetIssueError(Issue, boolean, boolean, ApplicationUser)
boolean isProjectStructuredForCurrentUser(@Nullable com.atlassian.jira.project.Project project)
project
- the projectboolean isStructureAvailableToUser(@Nullable com.atlassian.jira.user.ApplicationUser user)
default boolean isStructureAvailableToCurrentUser()
boolean isCreateStructureAllowed(@Nullable com.atlassian.jira.user.ApplicationUser user)
boolean isSynchronizationAllowed(@Nullable com.atlassian.jira.user.ApplicationUser user)
boolean isAutomationAccessAllowed(@Nullable com.atlassian.jira.user.ApplicationUser user)
default boolean isAuthenticated()
boolean isAdmin(@Nullable com.atlassian.jira.user.ApplicationUser user)
default boolean isAdmin()
boolean isViewCreationAllowed(@Nullable com.atlassian.jira.user.ApplicationUser user)
boolean isViewSharingAllowed(@Nullable com.atlassian.jira.user.ApplicationUser user)
boolean isIssueEditable(@Nullable com.atlassian.jira.issue.Issue issue, @Nullable com.atlassian.jira.user.ApplicationUser user)
issue
- issue in questionuser
- user to make the editboolean hasPermission(@NotNull com.atlassian.jira.permission.GlobalPermissionKey permission, @Nullable com.atlassian.jira.user.ApplicationUser user)
permission
- global permissionuser
- user in questionboolean hasPermission(@NotNull com.atlassian.jira.security.plugin.ProjectPermissionKey permission, @Nullable com.atlassian.jira.issue.Issue issue, @Nullable com.atlassian.jira.user.ApplicationUser user)
permission
- project permission from ProjectPermissions
issue
- an issueuser
- user in questionboolean hasPermission(@NotNull com.atlassian.jira.security.plugin.ProjectPermissionKey permission, @Nullable com.atlassian.jira.project.Project project, @Nullable com.atlassian.jira.user.ApplicationUser user)
permission
- project permission from ProjectPermissions
project
- a projectuser
- user in question@Nullable com.atlassian.jira.user.ApplicationUser getUser()
StructureAuth
@NotNull List<com.atlassian.crowd.embedded.api.Group> getAvailableGroups(@Nullable com.atlassian.jira.user.ApplicationUser user)
user
- user@NotNull default List<com.atlassian.crowd.embedded.api.Group> getAvailableGroupsForCurrentUser()
@NotNull List<com.atlassian.jira.security.roles.ProjectRole> getAvailableRoles()
@NotNull List<com.atlassian.jira.project.Project> getStructureProjectsForCurrentUser()
@NotNull List<com.atlassian.jira.project.Project> getProjectsForCurrentUser()
@NotNull com.atlassian.jira.security.JiraAuthenticationContext getAuthenticationContext()
@NotNull com.atlassian.jira.issue.IssueManager getIssueManager()
@NotNull com.atlassian.jira.security.PermissionManager getPermissionManager()
@NotNull com.atlassian.plugin.PluginAccessor getPluginAccessor()
@NotNull com.atlassian.plugin.event.PluginEventManager getEventManager()
@NotNull com.atlassian.jira.project.ProjectManager getProjectManager()
@NotNull com.atlassian.jira.security.roles.ProjectRoleManager getProjectRoleManager()
@NotNull com.atlassian.jira.user.util.UserManager getUserManager()
@NotNull com.atlassian.jira.jql.util.JqlStringSupport getJqlStringSupport()
@NotNull com.atlassian.jira.jql.parser.JqlQueryParser getJqlQueryParser()
@NotNull com.atlassian.jira.bc.issue.search.SearchService getSearchService()
@NotNull com.atlassian.jira.web.session.SessionSearchObjectManagerFactory getSessionSearchObjectManagerFactory()
@NotNull com.atlassian.jira.jql.operand.JqlOperandResolver getJqlOperandResolver()
@NotNull com.atlassian.jira.issue.search.SearchRequestManager getSearchRequestManager()
@NotNull com.atlassian.jira.security.GlobalPermissionManager getGlobalPermissionManager()
@NotNull com.atlassian.jira.bc.issue.worklog.TimeTrackingConfiguration getTimeTrackingConfiguration()
@NotNull com.atlassian.jira.user.preferences.UserPreferencesManager getUserPreferencesManager()
@NotNull com.atlassian.jira.issue.CustomFieldManager getCustomFieldManager()
void requireWidgetResource()
void requireLocalizedResource(@NotNull String resourceKey)
Requires a resource that may be localized. A localized version of the resource will have _locale suffix in its key - for example, com.almworks.jira.structure:my-resource_de
The locale of current user is used to load the resource. If such resource is missing, nothing happens.
resourceKey
- base resource keyvoid requireResource(@NotNull String resourceKey)
resourceKey
- resource keyvoid requireResourceIfPresent(String resourceKey)
resourceKey
- resource keyrequireResource(String)
void requireIssueDetailsResources()
void requireQuickEditResources()
void requireIssueShortcuts()
void filterInvisibleProjects(@Nullable com.almworks.integers.LongSizedIterable projects, @Nullable com.atlassian.jira.user.ApplicationUser user, boolean overrideSecurity, @NotNull com.almworks.integers.LongCollector invisibleCollector)
projects
- list of project IDsuser
- the useroverrideSecurity
- if true, permissions don't matter, only project existence is checkedinvisibleCollector
- a collector to get the IDs of invisible projects@NotNull com.almworks.integers.LongArray searchQuery(@Nullable String query) throws com.atlassian.jira.issue.search.SearchException, com.atlassian.jira.jql.parser.JqlParseException
query
- JQL (empty or null string will result in empty result)com.atlassian.jira.issue.search.SearchException
- if search problem happenedcom.atlassian.jira.jql.parser.JqlParseException
- if JQL is invalid@NotNull com.almworks.integers.LongArray searchQuery(@Nullable com.atlassian.query.Query query) throws com.atlassian.jira.issue.search.SearchException
query
- querycom.atlassian.jira.issue.search.SearchException
- if search problem happened@NotNull com.almworks.integers.LongArray searchAndSortQuery(@Nullable String query) throws com.atlassian.jira.issue.search.SearchException, com.atlassian.jira.jql.parser.JqlParseException
query
- JQL (empty or null string will result in empty result)com.atlassian.jira.issue.search.SearchException
- if search problem happenedcom.atlassian.jira.jql.parser.JqlParseException
- if JQL is invalid@NotNull com.almworks.integers.LongArray searchAndSortQuery(@Nullable com.atlassian.query.Query query) throws com.atlassian.jira.issue.search.SearchException
query
- querycom.atlassian.jira.issue.search.SearchException
- if search problem happened@NotNull com.almworks.integers.LongArray searchAndSortQuery(@Nullable com.atlassian.query.Query query, int limit) throws com.atlassian.jira.issue.search.SearchException
query
- querylimit
- maximum number of issues in the resultcom.atlassian.jira.issue.search.SearchException
- if search problem happenedvoid matchIssues(@Nullable com.almworks.integers.LongList issues, @Nullable com.atlassian.query.Query query, boolean collectMatching, @NotNull com.almworks.integers.LongCollector collector) throws com.atlassian.jira.issue.search.SearchException
Passes the issues through JIRA search engine and lets the caller collect either all matching or non-matching issues.
The implementation sorts issues and splits them up into chunks (of 100+ ids each) and creates a JQL query for each. This has proven to be a quick method of checking. However, if the number of issues is likely to be the same order of magnitude as the full result of the query, it's better to run the full query and compare result with the list.
The issues are checked to be accessible for the current user - so no need to run additional BROWSE permission checks.
You can quickly check which issues among the list are visible to the user by running matchIssues() with
null
query.
If it is certain that the issue list is sorted, it's more efficient to call matchIssuesSorted(com.almworks.integers.LongList, com.atlassian.query.Query, boolean, com.almworks.integers.LongCollector)
.
If you need to skip checking for the user access or check access for non-current user,
use com.almworks.jira.structure.api.auth.StructureAuth#sudo)
.
query
- query to check against. If null, the issues are only checked to be visible to the user and to the
Structure pluginissues
- issue IDscollectMatching
- if true, collector will receive the issues that match query and visible to the user;
if false, collector will receive non-matching issuescollector
- an instance for receiving the results. Chunks are processed in order, for each chunk the
(non-)matching issues are added. No guarantees are made for the order of the results inside the same chunk.com.atlassian.jira.issue.search.SearchException
- if a bad thing happensvoid matchIssuesSorted(@Nullable com.almworks.integers.LongList issuesSorted, @Nullable com.atlassian.query.Query query, boolean collectMatching, com.almworks.integers.LongCollector collector) throws com.atlassian.jira.issue.search.SearchException
Passes the issues, sorted by their IDs, through JIRA search engine to collect matching or non-matching issues.
This is more efficient method than matchIssues(com.almworks.integers.LongList, com.atlassian.query.Query, boolean, com.almworks.integers.LongCollector)
if you already have IDs sorted.
issuesSorted
- issues listquery
- additional querycollectMatching
- if true, collector receives matching issues, if false, collector receives non-matching issues.collector
- the collectorcom.atlassian.jira.issue.search.SearchException
- if a bad thing happensmatchIssues(LongList, Query, boolean, LongCollector)
void matchIssuesSorted(@Nullable com.almworks.integers.LongList issuesSorted, @Nullable com.atlassian.query.Query query, boolean collectMatching, @Nullable com.atlassian.jira.user.ApplicationUser user, boolean overrideSecurity, com.almworks.integers.LongCollector collector) throws com.atlassian.jira.issue.search.SearchException
matchIssuesSorted(LongList, Query, boolean, LongCollector)
that lets you specify
the user and override security checks.issuesSorted
- issues listquery
- additional querycollectMatching
- if true, collector receives matching issues, if false, collector receives non-matching issues.user
- the user that will be used to check accessoverrideSecurity
- if true, user access will not be checkedcollector
- the collectorcom.atlassian.jira.issue.search.SearchException
- if a bad thing happensmatchIssues(LongList, Query, boolean, LongCollector)
,
StructureAuth.sudo(ApplicationUser, boolean, CallableE)
@NotNull com.atlassian.jira.util.MessageSet validateQuery(com.atlassian.jira.user.ApplicationUser user, com.atlassian.query.Query query)
user
- userquery
- query@Nullable default com.atlassian.query.Query getConfigurationScopeQuery()
null
if Structure is allowed for all projectsStructureConfiguration.getConfigurationScopeQuery()
@NotNull com.atlassian.jira.util.I18nHelper getI18n(@Nullable com.atlassian.jira.user.ApplicationUser user)
user
- the user@NotNull default com.atlassian.jira.util.I18nHelper getI18n()
@NotNull Comparator<Structure> getStructureComparator(@Nullable com.atlassian.jira.user.ApplicationUser user)
user
- the user to take locale from@NotNull Collator getCollator(@Nullable com.atlassian.jira.user.ApplicationUser user)
user
- the user@NotNull Locale getLocale()
void clearAllCaches()
Clears all caches on the current JIRA instance that are maintained by Structure and Structure extensions.
Note that in JIRA Data Center environment, this does not clear caches on other nodes.
After this method has finished execution, the caches are cleared.
CachingComponent
,
clearAllCachesOnAllNodes()
void clearAllCachesOnAllNodes()
Clears all caches (maintained by Structure and Structure extensions) on the current JIRA instance and causes eventual caches clearing on other nodes (when running on JIRA Data Center).
When running on non-JDC instance, works the same as clearAllCaches()
.
After this method has finished execution, the caches are cleared on the local node, but may not be cleared yet on other nodes.
CachingComponent
,
clearAllCaches()
void clearCurrentUserCaches()
void clearUserCaches(@NotNull com.atlassian.jira.user.ApplicationUser user)
boolean isStructureLocked()
@Nullable com.atlassian.jira.issue.Issue getIssue(long issueId)
Issue
.issueId
- the ID of the issue@Nullable com.atlassian.jira.issue.Issue getIssue(String key)
key
- issue key@NotNull StructureConfiguration getConfiguration()
StructureConfiguration
<T> T instantiate(@NotNull Class<T> clazz)
T
- type parameterclazz
- class to be instantiatedCopyright © 2018 ALM Works. All Rights Reserved.