Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to enable/disable blueprints for a space using the Confluence API?

Nicolas Simon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2017

Hello all,

I um currently developing a plugin for Confluence which will enable/disable Blueprints for a specific space through the Confluence Java API.

I reviewed the online technical Java doc but was unable to find how to achieve my goal.

Has anyone run into this challenge before?

Thanks a lot

2 answers

2 votes
Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2017

What developpers would need for this case is access to the BlueprintStateController (com.atlassian.confluence.plugins.createcontent.BlueprintStateController) if possible. This class does exactly the job but is not available for injection

Corentin Méhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 6, 2018

Did you eventually managed to bypass this limitation ?

Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2018

Yes I did, but it's rather a dirty hack. I copy/pasted some code in the BlueprintStateController and some other classes down  the line. Basically it's "just" a matter of pushing values in bandana

 

{code}

private void enableBlueprint(UUID blueprintId, Space space, String bandanaKey) {
if(blueprintId == null) {
throw new IllegalArgumentException("Blueprint UUID is required.");
} else {
Object bandanaContext = space == null?new ConfluenceBandanaContext():new SpaceBandanaContext(space);
Set disabledBlueprintsIds = (Set)this.bandanaManager.getValue((BandanaContext)bandanaContext, bandanaKey);
if(disabledBlueprintsIds != null) {
disabledBlueprintsIds.remove(blueprintId.toString());
}

this.bandanaManager.setValue((BandanaContext)bandanaContext, bandanaKey, disabledBlueprintsIds);
}
}

private void disableBlueprint(UUID blueprintId, Space space, String bandanaKey) {
if(blueprintId == null) {
throw new IllegalArgumentException("blueprint UUID is required.");
} else if(!blueprintId.equals(BlueprintConstants.BLANK_PAGE_BLUEPRINT.getId())
&& !blueprintId.equals(BlueprintConstants.BLOG_POST_BLUEPRINT.getId()))
{
Object bandanaContext = space == null?new ConfluenceBandanaContext():new SpaceBandanaContext(space);
Object disabledBlueprintsIds = (Set)this.bandanaManager.getValue((BandanaContext)bandanaContext, bandanaKey);
if(disabledBlueprintsIds == null) {
disabledBlueprintsIds = Sets.newHashSet();
}

((Set)disabledBlueprintsIds).add(blueprintId.toString());
this.bandanaManager.setValue((BandanaContext)bandanaContext, bandanaKey, disabledBlueprintsIds);
} else {
throw new IllegalArgumentException("You cannot disable this blueprint.");
}
}

{code}

Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2018

Would be simpler and more stable in the long run if the BlueprintStateController was a public spring component

Melek Jebnoun_Vectors_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2018

Hello Sebastien

Many thanks for all those details.

Still how did you managed to find the Bandana Keys to get the list of disabled Blueprints. Couldn't find the right BandanaKeys to do so?

Thanks

Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2018

Hi @Melek Jebnoun_Vectors_,

The bandana key in question is : "com.atlassian.confluence.blueprints.disabled"

Melek Jebnoun_Vectors_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2018

Hi @Sebastien Delcoigne

Super! Many thanks for your help.

iamgoingtosneeze October 17, 2018

Hi - i've played around with setting values on the bandana global context  but I seem to only ever getting null

Would anybody be able to share more of how they have managed this? It's really frustrating !

Thanks in advance for your time. 

Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2018

Hi @iamgoingtosneeze,

 

Could you show an example of your code ? The examples shown above have been working pretty fine so far.

0 votes
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 23, 2017

Hi Nicolas,

We have a feature request to create the Javadocs for Blueprint API here, as we don't yet have that:

I am not aware of a way to do specifically what you request, but you could add your Blueprint as a promoted Blueprint using the following procedure:

I hope this helps.

Kind regards,

Shannon

Nicolas Simon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 27, 2017

Hello @Shannon S,

Thank you for your reply. I watch this issue now.

There is actually a way to enable/disable Blueprints for a space with the help of the Confluence REST API:

curl -u admin:admin -X PUT http://server:port/rest/create-dialog/1.0/modules/883d16f5-6eaa-46db-9201-54a1eb9cfcac?spaceKey=VS
curl -u admin:admin -X DELETE http://server:port/rest/create-dialog/1.0/modules/883d16f5-6eaa-46db-9201-54a1eb9cfcac?spaceKey=VS

In the example above, admin is the user (with password "admin"),
http://server:port/ is the instance base URL, VS is the Space key and 883d16f5-6eaa-46db-9201-54a1eb9cfcac is the Template ID - which can be found on the "UUID" column of the "AO_54C900_CONTENT_BLUEPRINT_AO" table in Confluence database.

(I got this hint from the Atlassian support team by the way)

 

However, I would rather use the Java classes instead of a REST call as it is required to authenticate first.

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2017

Hi Nicolas,

I was aware of the way via REST API, but not specifically of Java API, as it's not documented anywhere.

Hopefully someone will see this that knows if there is a way to do so, but what I'm hearing from the Confluence Server team is that it may not be possible.

If you do determine the way to do it, since it's undocumented, please let us know here in case any other users have the same issue.

Kind regards,

Shannon

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events