This question is in reference to Atlassian Developer Documentation: Custom actions with the Blueprint API
The link above tells us to use com.atlassian.confluence.plugins.createcontent.actions.BlueprintContentGenerator#generateBlueprintPageObject()
to create a page from a blueprint. Here's my assumption:
CreateBlueprintPageRequest request = new CreateBlueprintPageRequest(space, "title", null, parentPage, context, templateRef, user, contentBlueprint); Page instance = blueprintGenerator.generateBlueprintPageObject(request);
All parameters are self-explanatory, except:
Has anyone succeeded to generate a blueprint from Java?
Community moderators have prevented the ability to post new answers.
ContentBlueprintManager
was able to provide it. So here's the code:
private Page createPage(Space space, String title, ConfluenceUser user) { // Find the blueprint ContentBlueprint contentBlueprint = contentBlueprintManager.getPluginBackedContentBlueprint(new ModuleCompleteKey("com.playsql.requirementyogi", "bp-6"), space.getKey()); if (contentBlueprint == null) { throw new RuntimeException("(Your message)"); } ContentTemplateRef templateRef = null; for (ContentTemplateRef ref : contentBlueprint.getContentTemplateRefs()) { if (equal(ref.getModuleCompleteKey(), "com.playsql.requirementyogi:dictionary-template")) { templateRef = ref; break; } } if (templateRef == null) { throw new RuntimeException("(Your message)"); } // Create the instance Page parentPage = null; Map<String, Object> context = Maps.newHashMap(); CreateBlueprintPageRequest request = new CreateBlueprintPageRequest( space, title, null, parentPage, context, templateRef, user, contentBlueprint); Page page = blueprintGenerator.generateBlueprintPageObject(request); pageManager.saveContentEntity(page, DefaultSaveContext.DEFAULT); return page; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.