Spring Boot: Register Dynamic Content macro

Environment:
Using an Atlassian hosted confluence cloud instance. Local server will generate dynamic macro content to insert in the cloud confluence. Required framework java/spring boot

Desired Outcome:
Create a dynamic content macro using Spring Boot. This will provide a search UI, and provide results from a corporate wide knowledge base.

Problem:
I can see how to do this in node.js/express. The sample app is very clear. In the Spring Boot examples, I don’t see how I can register the dynamic macro with the remote confluence server.

Advice would be deeply appreciated.

@jake.stone, which sample app do you refer to?

atlassian-connect-spring-boot doesn’t have any product-specific functionality, and the samples generally show how to use the functionality the library provides, or how to integrate the library with other Spring Boot functionality.

But I suppose your use case is very common, so I’ve created atlassian-connect-spring-boot-sample-cacheable-macro.

I recommend you to read Cacheable app iframes first. With a cacheable dynamic content macro, you will only use the library (atlassian-connect-express or atlassian-connect-spring-boot) to build a JWT-authenticated REST API for the macro data.

I can also mention that once we implement ACJS-1025 (hopefully soon), you may be able to save an HTTP request if your macro has body or parameters.

@epehrson
Thank you, super helpful.
Since this is probably a common usage and I am probably an archetypal user (a developer with a preference for jvm and new to Atlassian APIs), a couple of follow ups may help both myself and the community.

I am still a little confused.

My desired outcome is to generate a macro in which:

  • With my local server running, I type “{” into a confluence cloud page and
  • see my macro listed.

The node.js starter pack provides this function (using ngrok under the hood, I assume?)

  1. The code below seems to require that confluence cloud already knows the local address of my macro server and also the relevant uri.
 @RequestMapping(value = "/data", method = GET, produces = "application/json")
    public AtlassianHostUser getData(@AuthenticationPrincipal AtlassianHostUser hostUser) {
        return hostUser;
    }
  1. (sidenote) Can I assume that the above code and pretty much all examples assume credentials.json is in the classpath?

  2. Your response seems to suggest another approach, namely inserting my local macro server url in the iframe macro that is already provided by Confluence, and then utilizing the authentication protocol you show above to autheniticate requests coming from the iframe. This is a legitimate approach. I just want to clarify.

  3. Is there a way to replicate the node.js macro “register” functionality in Spring boot. It would be a brilliant feature to have. In my case, I am generating a corporate search built on scala with an ElasticSearch base. Having result server able to use dependencies from the scala middle tier would be a great plus.

Again, I thank you for your time.
(btw, I looked at the Thymeleaf demo and didn’t even see atlassian-connect jars being loaded into the runtime classpath, so I was pretty confused.)

@epehrson
btw… as an aside: I think the Confluence dev team assume that developers come to Atlassian-Connect APIS with a higher level of knowledge than many of us have… also, documentation seems to be somewhat dispersed. The REST API is an exception to this. That is very clear.

For example, https://bitbucket.org/atlassian/atlassian-connect-express/src/master/README.md#markdown-header-install-dependencies seems to include information I did not see elsewhere.

Maybe I missed something, but assuming I am a very average developer, the documentation should be accessible to me…if you wish your APIs to be easily accessible to the average developer.

@jake.stone, since you mention credentials.json, I assume you followed the Confluence Cloud Getting started tutorial. At the end of Step 2, the following paragraph describes how to use the Manage apps administration screen.

After the page refreshes, you’ll see the Upload app link. This allows you to install apps while you’re developing them.

We were very much aware of atlassian-connect-express’ automatic installation feature when building atlassian-connect-spring-boot. That functionality is tracked as ACSPRING-1 and ACSPRING-2. But for various reasons, we never wound up incorporating that functionality into the library.

atlassian-connect-express uses credentials.json only for app installation. The context of the current host and user is managed in a similar way in both libraries. atlassian-connect-express just tends to be a lot more verbose :wink:

Note that you only need to reinstall your app if your app descriptor changes, which I expect you will only come across rarely.