Class ForestSpec
ForestSpec is used to identify structured content. All content that can be displayed by the
Structure Widget in the Grid panels — structures, queries and others — is identified by ForestSpec.
An instance of ForestSpec can be created through one of the factory methods, or deserialized from JSON.
It then can be fed to ForestService to obtain ForestSource. The ForestSource can be
asked for an update of the forest content, based on the last version that the caller has observed and cached.
Unlike ForestSource, instances of ForestSpec can be stored for a long time.
ForestSpec parameters belong to two groups: base content specification and adjustment specification.
A ForestSource will first produce the base content and then will make additional adjustments to it,
according to the spec.
Base content specification
Base content can be of the following types, each having its own factory method:
- A specific structure — see
structure(long) - A query — see
sQuery(String, String) - A specific version of a structure — see
version(long, int) - A user's clipboard — see
clipboard(String)
Adjustments
The following parameters adjust the produced content:
- Transformations apply generators to the base content — see
transform(String, Map). This is what Structure uses in the transformations and quick transformations panels. - "Secured" parameter specifies that the content must be filtered for access and all sub-trees with the
items that the user cannot see must be removed. Very important —
secure(String) - Setting
titleparameter to true would make the content placed under the top-level "title" item —ForestSpec.Builder.setTitle(boolean) - Setting
skeletonparameter to true would prevent Structure engine from generating the dynamic content. The result would be a forest with only static content, including generators, but without generators' action —skeleton(long)
Additionally, userKey parameter specifies the account, which is used to:
- secure the forest, if
securedparameter is set, and - run transformations under, if
transformationsare specified.
Note that there are no permission checks when ForestSpec is created. Permissions are checked only
when ForestService.getForestSource(ForestSpec) is called.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for forest spec.static final classRepresents a SQuery.static final classRepresents a transformation, which is a call to a generator with specified parameters.static interface -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(ForestSpec.Visitor<T> visitor) AppliesForestSpec.Visitorto this spec.static ForestSpec.Builderbuilder()Creates a new builder forForestSpec.static ForestSpec.Builderbuilder(ForestSpec spec) Creates a new build that can be used to adjust a givenForestSpec.static ForestSpecConstructsForestSpecthat represents a user's clipboard.booleanstatic ForestSpecfromRest(RestForestSpec rfs) This method can be used to restore a forest spec from a REST transfer object.Returns session ID used to identify the clipboard if the base content is a clipboard, null otherwise.Returns the last transformation used by this forest spec.For a forest spec with transformations, returns the forest spec without the last used transformation.ReturnsForestSpec.SQueryif the base content is a SQuery, null otherwise.Returns structure ID if the base content is a structure or a structure version, null otherwise.Returns the list of transformations applied to the base forest.Returns the same forest spec, but withsecuredflag turned off.Returns the same forest spec but without transformations.Returns user key that is used to run transformations and to secure the forest, if corresponding options are present.Returns version if the base content is a structure version, null otherwise.inthashCode()booleanhasTitle()Returns true if forest spec hastitleoption on.booleanReturns true if the result will be secured, that is, the items in the forest will be checked for being accessible to the user and fully inaccessible sub-trees will be removed.booleanReturns true if forest spec produces a base forest without running generators.booleanReturns true if this forest spec contains transformation.Creates a newForestSpecthat is secured for the specified user.static ForestSpecskeleton(long structureId) ConstructsForestSpecthat represents a structure with no dynamic content.static ForestSpecConstructsForestSpecthat represents a structured query.static ForestSpecstructure(long structureId) ConstructsForestSpecthat represents a structure.static ForestSpecstructure(long structureId, ApplicationUser user) ConstructsForestSpecthat represents a structure.toRest()Produces REST forest specification based on this instance's parameters.toString()Creates a transformedForestSpecthat adds a single transformation to the result of the original forest spec.static ForestSpecunsecuredStructure(long structureId) ConstructsForestSpecthat represents a structure.static ForestSpecversion(long structureId, int version) ConstructsForestSpecthat represents a historical version of a structure.Returns the same forest spec but withouttitleoption.Returns the same forest spec but withtitleoption.
-
Method Details
-
builder
Creates a new builder forForestSpec. -
builder
Creates a new build that can be used to adjust a givenForestSpec. -
structure
Constructs
ForestSpecthat represents a structure. The resulting content would display the specified structure with all dynamic content properly calculated.The resulting forest spec is secured for the current user. The forests produced by the corresponding forest source will exclude sub-trees that do not contain items visible to the user.
- Parameters:
structureId- structure ID- Returns:
- forest spec
- See Also:
-
structure
Constructs
ForestSpecthat represents a structure. The resulting content would display the specified structure with all dynamic content properly calculated.The resulting forest spec is secured for the specified user. The forests produced by the corresponding forest source will exclude sub-trees that do not contain items visible to the user.
- Parameters:
structureId- structure ID- Returns:
- forest spec
- See Also:
-
unsecuredStructure
Constructs
ForestSpecthat represents a structure. The resulting content would display the specified structure with all dynamic content properly calculated.The resulting forest spec is unsecured. Use
secure(String)orstructure(long, ApplicationUser)to properly filter the content for a given user.- Parameters:
structureId- structure ID- Returns:
- forest spec
- See Also:
-
skeleton
Constructs
ForestSpecthat represents a structure with no dynamic content. The resulting content would show only static rows of the structure, including generators, but generators will not have acted.The resulting forest spec is unsecured. Use
secure(String)to properly filter the content for a given user.- Parameters:
structureId- structure ID- Returns:
- forest spec
-
version
Constructs
ForestSpecthat represents a historical version of a structure. The resulting content would only display the manually added rows — automation does not work on historical versions.The resulting forest spec is unsecured. Use
secure(String)to properly filter the content for a given user.- Parameters:
structureId- structure IDversion- version number- Returns:
- forest spec
- See Also:
-
sQuery
Constructs
ForestSpecthat represents a structured query. A structured query is a textual, human-readable definition of the content.There may be different types of SQuery. So far, the following are supported:
jqlquery produces a flat structure with results of JQL query (up to 1000 issues).textquery produces a flat structure with results of text-based JQL query (up to 1000 issues).cqlquery works only if Structure.Pages is installed and configured, it produces a flat structure with results of CQL query in all connected Confluence instances (up to 1000 pages).
The resulting forest spec is secured for the current user (see also
StructureAuth). The result will be filtered according to the user's access to the items. UsegetUnsecured()to get an unsecured version of the result, orsecure(String)to secure it for another user.- Parameters:
type- type of queryquery- query text- Returns:
- forest spec
-
clipboard
Constructs
ForestSpecthat represents a user's clipboard. The clipboard's lifecycle is tied to the user's session, so we're using session ID to identify the user.- Parameters:
sessionId- session ID from servlet subsystem- Returns:
- forest spec
- See Also:
-
HttpServletRequest.getSession()
-
secure
Creates a new
ForestSpecthat is secured for the specified user. The rows will be checked and all sub-trees that contain only the items that the user does not have read access to will be removed.- Parameters:
userKey- user key- Returns:
- adjusted forest spec
-
transform
Creates a transformed
ForestSpecthat adds a single transformation to the result of the original forest spec. The transformation is specified by the module key of the generator and the parameters map.The new
ForestSpecwill have the current user as itsuserKeyparameter. Note that this is the user account under which the generators will execute, when performing all transformations, not only the most recent one.The resulting forest spec's "secured" flag will be the same as
isSecured()for this forest spec.- Parameters:
module- complete plugin module key of the generator that should perform the transformationparams- parameters for the generator- Returns:
- adjusted forest spec
- See Also:
-
isTransformed
public boolean isTransformed()Returns true if this forest spec contains transformation. -
getLastTransformedSpec
For a forest spec with transformations, returns the forest spec without the last used transformation. If the forest spec does not contain transformations, returns null.- See Also:
-
getLastTransformation
Returns the last transformation used by this forest spec. Returns null if there are no transformations.- See Also:
-
getUntransformedSpec
Returns the same forest spec but without transformations. -
getStructureId
Returns structure ID if the base content is a structure or a structure version, null otherwise. -
getVersion
Returns version if the base content is a structure version, null otherwise. -
getSQuery
ReturnsForestSpec.SQueryif the base content is a SQuery, null otherwise. -
getClipboardSessionId
Returns session ID used to identify the clipboard if the base content is a clipboard, null otherwise. -
getUserKey
Returns user key that is used to run transformations and to secure the forest, if corresponding options are present. -
getTransformations
Returns the list of transformations applied to the base forest. -
isSecured
public boolean isSecured()Returns true if the result will be secured, that is, the items in the forest will be checked for being accessible to the user and fully inaccessible sub-trees will be removed. -
isSkeleton
public boolean isSkeleton()Returns true if forest spec produces a base forest without running generators. -
hasTitle
public boolean hasTitle()Returns true if forest spec hastitleoption on. -
getUnsecured
Returns the same forest spec, but withsecuredflag turned off. -
withoutTitle
Returns the same forest spec but withouttitleoption. -
withTitle
Returns the same forest spec but withtitleoption. -
accept
AppliesForestSpec.Visitorto this spec.- Throws:
StructureException
-
equals
-
hashCode
public int hashCode() -
toString
-
fromRest
@NotNull public static ForestSpec fromRest(@Nullable RestForestSpec rfs) throws IllegalArgumentException This method can be used to restore a forest spec from a REST transfer object.- Parameters:
rfs- REST forest spec- Returns:
- ForestSpec
- Throws:
IllegalArgumentException- if the transfer object is invalid
-
toRest
Produces REST forest specification based on this instance's parameters.
-