|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Structure
A structure is a hierarchical list of issues.
Structure interface lets you inspect and change properties of a structure,
while Forest contains the hierarchy itself.
You typically get an instance of Structure by calling
one of the StructureManager methods. There are get... methods
to retrieve the existing structures, and StructureManager.createStructure()
method to create a new structure.
To get the Forest associated with the structure, you can use
getForest(com.atlassian.crowd.embedded.api.User, boolean) method from this class, but you don't have to get an
instance of Structure to get the forest - methods
StructureManager.getForest(java.lang.Long, com.atlassian.crowd.embedded.api.User, boolean) and StructureManager.getForestUpdate(java.lang.Long, java.lang.Long, java.lang.Long, com.atlassian.crowd.embedded.api.User, boolean)
accept the structure ID.
To change properties of a structure, you need to get the instance of
Structure, call some of the set... methods and then
call saveChanges(com.atlassian.crowd.embedded.api.User, boolean). Until you call saveChanges() the modifications
are made only to the copy of the structure in memory.
To create a new structure, call StructureManager.createStructure() to get
an empty Structure instance, call set... methods to set
properties (at least structure name must be set) and then call saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
When saveChanges is completed, the new Structure has been created and
you can use getId() to get the new structure's ID.
Note that the maximum length of a structure name is 255. Longer names will be truncated.
Instances of classes implementing this interface have reference equality: their equals()
and hashCode() behave in the same way as Object's.
The implementations of this interface are not thread-safe. Every thread must obtain their
own copy of the Structure instance. Moreover, every time you need an
instance of Structure, you should get it from the StructureManager
because the properties might have changed or the structure might have been deleted.
StructureManager,
Forest| Method Summary | |
|---|---|
String |
getDescription()
|
PermissionLevel |
getEffectivePermission(com.atlassian.crowd.embedded.api.User user)
Calculates access level to this structure for the specified user. |
Forest |
getForest(com.atlassian.crowd.embedded.api.User user,
boolean overrideSecurity)
This is a convenience method to get the forest of this structure. |
long |
getId()
Returns the ID of the structure, or 0 if the structure has no ID (when it's
new and hasn't been saved yet). |
String |
getName()
|
PermissionSubject |
getOwner()
|
List<PermissionRule> |
getPermissions()
|
boolean |
isEditRequiresParentIssuePermission()
|
Structure |
saveChanges(com.atlassian.crowd.embedded.api.User updater,
boolean overrideSecurity)
Call this method to save the changes made with set... |
Structure |
setDescription(String description)
Sets the description of the structure. |
Structure |
setEditRequiresParentIssuePermission(boolean flag)
Changes the security flag that requires the user to have Edit Issue permission on parent issues of the issues being moved, added or deleted from structure. |
Structure |
setId(long id)
Sets the ID of the structure. |
Structure |
setName(String name)
Sets the name of the structure. |
Structure |
setOwner(PermissionSubject owner)
Sets the owner of the structure, usually an instance of PermissionSubject.JiraUser. |
Structure |
setPermissions(Collection<? extends PermissionRule> permissions)
Sets the permission rules for this structure. |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Method Detail |
|---|
long getId()
0 if the structure has no ID (when it's
new and hasn't been saved yet).
@Nullable PermissionSubject getOwner()
@NotNull String getName()
@NotNull String getDescription()
boolean isEditRequiresParentIssuePermission()
@NotNull List<PermissionRule> getPermissions()
@NotNull Structure setId(long id)
Sets the ID of the structure. You can only set the ID of a structure instance that's newly created with
StructureManager.createStructure() method - this lets you create new structures with a predefined ID.
Structure ID must be a positive number, additional limitations on the allowed predefined numbers may be
imposed by the implementation.
Note that you do not have to call this method! You can create a new structure without ID and a next
free ID will be assigned to it when you call saveChanges().
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
id - the ID for the new structure
IllegalStateException - if this is not a new structure
IllegalArgumentException - if the ID is invalid
@NotNull
Structure setOwner(@Nullable
PermissionSubject owner)
Sets the owner of the structure, usually an instance of PermissionSubject.JiraUser.
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
owner - new owner
@NotNull
Structure setName(@Nullable
String name)
Sets the name of the structure. Although it is possible to set name to null, it is an invalid value
and saveChanges will throw an error when called, unless a non-null name is set.
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
name - structure name
@NotNull
Structure setDescription(@Nullable
String description)
Sets the description of the structure.
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
description - structure description
@NotNull Structure setEditRequiresParentIssuePermission(boolean flag)
Changes the security flag that requires the user to have Edit Issue permission on parent issues of the issues being moved, added or deleted from structure.
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
flag - if true, Edit Issue permission is required
@NotNull
Structure setPermissions(@Nullable
Collection<? extends PermissionRule> permissions)
Sets the permission rules for this structure. Permission rules are evaluated in the specified order and the last matching rule defines the access level to the structure for the given user.
Structure owner and JIRA administrators always have PermissionLevel.ADMIN access level.
To store the changed information in the database, use saveChanges(com.atlassian.crowd.embedded.api.User, boolean). At this point, the specified rules are validated, and
StructureException is thrown if any of them fails to validate.
permissions - a collection of permissions, null means empty list
@NotNull
Structure saveChanges(@Nullable
com.atlassian.crowd.embedded.api.User updater,
boolean overrideSecurity)
throws StructureException
Call this method to save the changes made with set... methods and update the database.
Before this method is called, all changes are only stored in this instance of Structure and have no other effect. After this method has successfully executed, the changes are stored in the database and applied.
The calling user account is passed in the updater parameter. The updater must have
PermissionLevel.ADMIN access level to the structure, and be allowed to use Structure plugin in
StructureConfiguration. Additionally, if this is a new structure being saved, the user must have
permissions to create new structures.
All security checks are bypassed if overrideSecurity is true.
Permission rules (set through setPermissions(java.util.Collection) or existing if this method was not used) are validated before changing the database.
If any of the rules is not valid, StructureException is thrown with the following StructureError:
StructureError.STRUCTURE_NOT_EXISTS_OR_NOT_ACCESSIBLE |
There is an "apply structure permission" rule that refers to a structure that does not exist or is inaccessible. | StructureException.getStructure() returns ID of the referred structure. |
StructureError.PERMISSION_RULE_APPLICATION_FORMS_CYCLE |
There is an "apply structure permission" rule that refers to a structure belonging to a permission dependency cycle. This rule or some other may be responsible for that cycle. | Throwable.getMessage() contains the structures in that cycle and the conflicting dependency. The message is not localized. |
StructureError.GROUP_NOT_EXISTS_OR_INACCESSIBLE |
There is a "set level" permission rule applied to a JIRA group that does not exist or is inaccessible (current user is not its member.) | Throwable.getMessage() contains group ID. The message is not localized. |
StructureError.PROJECT_NOT_EXISTS_OR_INACCESSIBLE |
There is a "set level" permission rule applied to a JIRA project role in a project that is not enabled for the Structure plugin, does not exist or is inaccessible (current user does not have Browse permission for it.) | Throwable.getMessage() contains project ID (numeric.) The message is not localized. |
StructureError.PROJECT_ROLE_NOT_EXISTS_OR_INACCESSIBLE |
There is a "set level" permission rule applied to a JIRA project role that does not exist or is not visible to the current user. | Throwable.getMessage() contains project role ID (numeric.) The message is not localized. |
updater - the user who performs the update, null means anonymousoverrideSecurity - if true, no security checks are made. The user parameter may be used to record change history.
StructureException - if there's a permissions problem, if required fields (name) are not set, or if there
are other problems
@NotNull
PermissionLevel getEffectivePermission(@Nullable
com.atlassian.crowd.embedded.api.User user)
Calculates access level to this structure for the specified user. If the user is not allowed to use Structure plugin,
the result will always be PermissionLevel.NONE.
This method does not take into account pending changes to the permissions list made through setPermissions(java.util.Collection extends com.almworks.jira.structure.api.PermissionRule>)
method call, until they are committed to the database with saveChanges(com.atlassian.crowd.embedded.api.User, boolean).
user - the user, null means anonymous
StructureManager.getStructurePermission(java.lang.Long, com.atlassian.crowd.embedded.api.User)
@NotNull
Forest getForest(@Nullable
com.atlassian.crowd.embedded.api.User user,
boolean overrideSecurity)
throws StructureException
StructureManager.getForestUpdate(java.lang.Long, java.lang.Long, java.lang.Long, com.atlassian.crowd.embedded.api.User, boolean).
user - the user requesting the forestoverrideSecurity - if true, no security checks are performed (however, issues are still verified to exist and belong to a project enabled for Structure)
StructureException - if there are any problems (permissions problem, no such structure, and others)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||