@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 |
filterInvisibleProjects(LongSizedIterable projects,
ApplicationUser user,
boolean overrideSecurity,
LongCollector invisibleCollector)
Used to figure out which projects are not visible to the user.
|
JiraAuthenticationContext |
getAuthenticationContext() |
List<Group> |
getAvailableGroups(ApplicationUser user)
Retrieves the security groups that the user is allowed to see.
|
default List<Group> |
getAvailableGroupsForCurrentUser()
Retrieves the security groups that the current user is allowed to see.
|
List<ProjectRole> |
getAvailableRoles()
Retrieves the roles that exist in the system.
|
StructureCacheHelper |
getCacheHelper() |
Collator |
getCollator(ApplicationUser user)
Returns a collator for strings in the user's locale.
|
StructureConfiguration |
getConfiguration()
Retrieves
StructureConfiguration |
default Query |
getConfigurationScopeQuery()
Retrieves a query that limits scope to the projects enabled for Structure.
|
CustomFieldManager |
getCustomFieldManager() |
PluginEventManager |
getEventManager() |
GlobalPermissionManager |
getGlobalPermissionManager() |
default I18nHelper |
getI18n()
Retrieves i18n helper for the current user.
|
I18nHelper |
getI18n(ApplicationUser user)
Retrieves i18n helper for a concrete user.
|
Issue |
getIssue(long issueId)
Retrieves an instance of
Issue. |
Issue |
getIssue(String key)
Retrieves an instance of issue by issue key.
|
default StructureError |
getIssueError(Issue issue,
boolean checkEdit)
Convenience method to check issue access for the current user.
|
default StructureError |
getIssueError(Issue issue,
boolean checkEdit,
boolean checkProjectEnabledForStructure)
Convenience method to check issue access for the current user.
|
StructureError |
getIssueError(Issue issue,
boolean checkEdit,
boolean checkProjectEnabledForStructure,
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,
ApplicationUser user)
Checks user access to the issue for viewing or editing.
|
IssueManager |
getIssueManager() |
JqlOperandResolver |
getJqlOperandResolver() |
JqlQueryParser |
getJqlQueryParser() |
JqlStringSupport |
getJqlStringSupport() |
Locale |
getLocale()
Returns the current user's locale.
|
PermissionManager |
getPermissionManager() |
PluginAccessor |
getPluginAccessor() |
ProjectManager |
getProjectManager() |
ProjectRoleManager |
getProjectRoleManager() |
List<Project> |
getProjectsForCurrentUser()
Retrieves the list of projects that are visible to the current user.
|
SearchRequestManager |
getSearchRequestManager() |
SearchService |
getSearchService() |
Comparator<Structure> |
getStructureComparator(ApplicationUser user)
Returns comparator for sorting structures by name, according to the given user's locale.
|
List<Project> |
getStructureProjectsForCurrentUser()
Retrieves the list of projects that are enabled for structure and visible to the current user.
|
TimeTrackingConfiguration |
getTimeTrackingConfiguration() |
ApplicationUser |
getUser()
Retrieves the current user.
|
UserManager |
getUserManager() |
UserPreferencesManager |
getUserPreferencesManager() |
boolean |
hasPermission(GlobalPermissionKey permission,
ApplicationUser user)
Checks if the given user has the given global permission.
|
boolean |
hasPermission(ProjectPermissionKey permission,
Issue issue,
ApplicationUser user)
Checks if the given user has the given project-level permission on an issue's project.
|
boolean |
hasPermission(ProjectPermissionKey permission,
Project project,
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 "System Administrator"!).
|
boolean |
isAdmin(ApplicationUser user)
Checks if the given user is a Jira administrator (but not necessarily "System Administrator"!).
|
boolean |
isAllowed(StructureAppPermission permission,
ApplicationUser user)
Checks if the given user allowed to perform the action guarded by the given permission.
|
default boolean |
isAuthenticated()
Checks if the current user has authenticated in the system.
|
default boolean |
isAutomationAccessAllowed(ApplicationUser user)
Checks if the given user is allowed to create and run generators.
|
default boolean |
isCreateStructureAllowed(ApplicationUser user)
Checks if the given user is allowed to create new structures.
|
boolean |
isIssueEditable(Issue issue,
ApplicationUser user)
Checks if the issue can be edited by the given user.
|
boolean |
isProjectStructuredForCurrentUser(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.
|
default boolean |
isStructureAvailableToUser(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.
|
default boolean |
isSynchronizationAllowed(ApplicationUser user)
Checks if the given user is allowed to create and run synchronizers.
|
default boolean |
isSystemAdmin()
Checks if the current user is a Jira system administrator.
|
boolean |
isSystemAdmin(ApplicationUser user)
Checks if the given user is a Jira system administrator.
|
boolean |
isViewCreationAllowed(ApplicationUser user)
Checks if the given user can create new views.
|
boolean |
isViewSharingAllowed(ApplicationUser user)
Checks if the given user can share views.
|
void |
matchIssues(LongList issues,
Query query,
boolean collectMatching,
LongCollector collector)
Passes the issues through JIRA search engine and lets the caller collect either all matching or non-matching
issues.
|
void |
matchIssuesSorted(LongList issuesSorted,
Query query,
boolean collectMatching,
ApplicationUser user,
boolean overrideSecurity,
LongCollector collector)
A variation of
matchIssuesSorted(LongList, Query, boolean, LongCollector) that lets you specify
the user and override security checks. |
void |
matchIssuesSorted(LongList issuesSorted,
Query query,
boolean collectMatching,
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 |
requireResourcesForContext(String context)
Loads resources associated with a context
|
void |
requireWidgetResource()
Requires all resources needed to render Structure Widget.
|
LongArray |
searchAndSortQuery(Query query)
Runs search with sorting.
|
LongArray |
searchAndSortQuery(Query query,
int limit)
Runs search with sorting and result count limit.
|
LongArray |
searchAndSortQuery(String query)
Runs JQL search with sorting.
|
LongArray |
searchQuery(Query query)
Runs search.
|
LongArray |
searchQuery(String query)
Runs JQL search.
|
MessageSet |
validateQuery(ApplicationUser user,
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 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 Issue issue, boolean checkEdit, boolean checkProjectEnabledForStructure, @Nullable 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 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 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
Project project)
project - the projectdefault boolean isStructureAvailableToUser(@Nullable
ApplicationUser user)
default boolean isStructureAvailableToCurrentUser()
default boolean isCreateStructureAllowed(@Nullable
ApplicationUser user)
default boolean isSynchronizationAllowed(@Nullable
ApplicationUser user)
default boolean isAutomationAccessAllowed(@Nullable
ApplicationUser user)
boolean isAllowed(@NotNull
StructureAppPermission permission,
@Nullable
ApplicationUser user)
CoreAppPermissionsdefault boolean isAuthenticated()
boolean isAdmin(@Nullable
ApplicationUser user)
default boolean isAdmin()
boolean isSystemAdmin(@Nullable
ApplicationUser user)
user - the user to checktrue if the given user is not null and a Jira system administrator.default boolean isSystemAdmin()
true if the current user is a Jira system administrator.boolean isViewCreationAllowed(@Nullable
ApplicationUser user)
boolean isViewSharingAllowed(@Nullable
ApplicationUser user)
boolean isIssueEditable(@Nullable
Issue issue,
@Nullable
ApplicationUser user)
issue - issue in questionuser - user to make the editboolean hasPermission(@NotNull
GlobalPermissionKey permission,
@Nullable
ApplicationUser user)
permission - global permissionuser - user in questionboolean hasPermission(@NotNull
ProjectPermissionKey permission,
@Nullable
Issue issue,
@Nullable
ApplicationUser user)
permission - project permission from ProjectPermissionsissue - an issueuser - user in questionboolean hasPermission(@NotNull
ProjectPermissionKey permission,
@Nullable
Project project,
@Nullable
ApplicationUser user)
permission - project permission from ProjectPermissionsproject - a projectuser - user in question@Nullable ApplicationUser getUser()
StructureAuth@NotNull List<Group> getAvailableGroups(@Nullable ApplicationUser user)
user - user@NotNull default List<Group> getAvailableGroupsForCurrentUser()
@NotNull List<ProjectRole> getAvailableRoles()
@NotNull List<Project> getStructureProjectsForCurrentUser()
@NotNull List<Project> getProjectsForCurrentUser()
@NotNull JiraAuthenticationContext getAuthenticationContext()
@NotNull IssueManager getIssueManager()
@NotNull PermissionManager getPermissionManager()
@NotNull PluginAccessor getPluginAccessor()
@NotNull PluginEventManager getEventManager()
@NotNull ProjectManager getProjectManager()
@NotNull ProjectRoleManager getProjectRoleManager()
@NotNull UserManager getUserManager()
@NotNull JqlStringSupport getJqlStringSupport()
@NotNull JqlQueryParser getJqlQueryParser()
@NotNull SearchService getSearchService()
@NotNull JqlOperandResolver getJqlOperandResolver()
@NotNull SearchRequestManager getSearchRequestManager()
@NotNull GlobalPermissionManager getGlobalPermissionManager()
@NotNull TimeTrackingConfiguration getTimeTrackingConfiguration()
@NotNull UserPreferencesManager getUserPreferencesManager()
@NotNull 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 requireResourcesForContext(String context)
context - context namevoid requireQuickEditResources()
void requireIssueShortcuts()
void filterInvisibleProjects(@Nullable
LongSizedIterable projects,
@Nullable
ApplicationUser user,
boolean overrideSecurity,
@NotNull
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
LongArray searchQuery(@Nullable
String query)
throws SearchException,
JqlParseException
query - JQL (empty or null string will result in empty result)SearchException - if search problem happenedJqlParseException - if JQL is invalid@NotNull
LongArray searchQuery(@Nullable
Query query)
throws SearchException
query - querySearchException - if search problem happened@NotNull
LongArray searchAndSortQuery(@Nullable
String query)
throws SearchException,
JqlParseException
query - JQL (empty or null string will result in empty result)SearchException - if search problem happenedJqlParseException - if JQL is invalid@NotNull
LongArray searchAndSortQuery(@Nullable
Query query)
throws SearchException
query - querySearchException - if search problem happened@NotNull
LongArray searchAndSortQuery(@Nullable
Query query,
int limit)
throws SearchException
query - querylimit - maximum number of issues in the resultSearchException - if search problem happenedvoid matchIssues(@Nullable
LongList issues,
@Nullable
Query query,
boolean collectMatching,
@NotNull
LongCollector collector)
throws 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.SearchException - if a bad thing happensvoid matchIssuesSorted(@Nullable
LongList issuesSorted,
@Nullable
Query query,
boolean collectMatching,
LongCollector collector)
throws 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 collectorSearchException - if a bad thing happensmatchIssues(LongList, Query, boolean, LongCollector)void matchIssuesSorted(@Nullable
LongList issuesSorted,
@Nullable
Query query,
boolean collectMatching,
@Nullable
ApplicationUser user,
boolean overrideSecurity,
LongCollector collector)
throws 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 collectorSearchException - if a bad thing happensmatchIssues(LongList, Query, boolean, LongCollector),
StructureAuth.sudo(ApplicationUser, boolean, CallableE)@NotNull
MessageSet validateQuery(ApplicationUser user,
Query query)
user - userquery - query@Nullable default Query getConfigurationScopeQuery()
null if Structure is allowed for all projectsStructureConfiguration.getConfigurationScopeQuery()@NotNull
I18nHelper getI18n(@Nullable
ApplicationUser user)
user - the user@NotNull default I18nHelper getI18n()
@NotNull Comparator<Structure> getStructureComparator(@Nullable ApplicationUser user)
user - the user to take locale from@NotNull Collator getCollator(@Nullable ApplicationUser user)
user - the user@NotNull Locale getLocale()
StructureCacheHelper getCacheHelper()
boolean isStructureLocked()
@Nullable Issue getIssue(long issueId)
Issue.issueId - the ID of the issue@Nullable 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 © 2022 ALM Works. All Rights Reserved.