Contenu connexe Similaire à Connecting Connect with Spring Boot (20) Connecting Connect with Spring Boot1. VINCENT KOK • DEVELOPMENT MANAGER • ATLASSIAN • @VINCENTKOK
Connecting Connect
with Spring Boot
8. A “vanilla” Spring web app
1. Dependencies
Setup the right Maven dependencies
web.xml
Setup your web.xml
9. A “vanilla” Spring web app
1. Dependencies
Setup the right Maven dependencies
application-context.xml
Enable component scanning and mvc
annotation driven
web.xml
Setup your web.xml
10. A “vanilla” Spring web app
1. Dependencies
Setup the right Maven dependencies
4. The actual controller
What you actually care about
application-context.xml
Enable component scanning and mvc
annotation driven
web.xml
Setup your web.xml
11. A “vanilla” Spring web app
5. Install Tomcat
And configure it as well
1. Dependencies
Setup the right Maven dependencies
4. The actual controller
What you actually care about
application-context.xml
Enable component scanning and mvc
annotation driven
web.xml
Setup your web.xml
12. A “vanilla” Spring web app
5. Install Tomcat
And configure it as well
6. It might work
You probably made a typo
1. Dependencies
Setup the right Maven dependencies
4. The actual controller
What you actually care about
application-context.xml
Enable component scanning and mvc
annotation driven
web.xml
Setup your web.xml
13. • Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
Repeatable pattern
https://flic.kr/p/8ykpkW
15. Example: Hello world
e
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.connect.lighthing</groupId>
<artifactId>lightingdemo</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
16. Example: Hello world
e
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.connect.lighthing</groupId>
<artifactId>lightingdemo</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
</parent>
17. Example: Hello world
e
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.connect.lighthing</groupId>
<artifactId>lightingdemo</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
18. Example: Hello world
e
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
19. Example: Hello world
e
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
@SpringBootApplication
public class HelloApplication {
20. Example: Hello world
e
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
21. Example: Hello world
e
package hello;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
22. Example: Hello world
e
package hello;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
@RestController
public class HelloController {
23. Example: Hello world
e
package hello;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
29. Example: Consume a starter
e
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependencies>
30. Example: Consume a starter
e
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
32. Example: Consume a starter
e
$> mvn spring-boot:run
$> curl http://localhost:8080/health
{”status”:”UP”}
42. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
43. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
44. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
}
45. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
"modules": {
}
47. Lifecycle
e
{
"key": “com.atlassian.connect.atlascamp.inception”,
"clientKey": "Confluence:5358671948",
"publicKey": "MIGf....ZRWzwIDAQAB",
"sharedSecret": "fda9e230-ba1b-4e8d-a76e-c9e4e6c28ea8",
"serverVersion": "6437",
"pluginsVersion": "1.1.81",
"baseUrl": “http://vincentkok.atlassian.net",
"productType": "confluence",
"description": "Atlassian Confluene at https://example.atlassian.net",
"eventType": "INSTALLED"
}
"key": “com.atlassian.connect.atlascamp.inception”,
"clientKey": "Confluence:5358671948",
48. Lifecycle
e
{
"key": “com.atlassian.connect.atlascamp.inception”,
"clientKey": "Confluence:5358671948",
"publicKey": "MIGf....ZRWzwIDAQAB",
"sharedSecret": "fda9e230-ba1b-4e8d-a76e-c9e4e6c28ea8",
"serverVersion": "6437",
"pluginsVersion": "1.1.81",
"baseUrl": “http://vincentkok.atlassian.net",
"productType": "confluence",
"description": "Atlassian Confluene at https://example.atlassian.net",
"eventType": "INSTALLED"
}
"sharedSecret": "fda9e230-ba1b-4e8d-a76e-c9e4e6c28ea8",
49. Lifecycle
e
{
"key": “com.atlassian.connect.atlascamp.inception”,
"clientKey": "Confluence:5358671948",
"publicKey": "MIGf....ZRWzwIDAQAB",
"sharedSecret": "fda9e230-ba1b-4e8d-a76e-c9e4e6c28ea8",
"serverVersion": "6437",
"pluginsVersion": "1.1.81",
"baseUrl": “http://vincentkok.atlassian.net",
"productType": "confluence",
"description": "Atlassian Confluene at https://example.atlassian.net",
"eventType": "INSTALLED"
} “eventType": "INSTALLED",
54. JWT
e
{
"typ":"JWT",
"alg":"HS256"
}
{
"iss": "confluence:1314039",
"iat": 1300819370,
"exp": 1300819380,
"qsh": "8063ff4ca1e41df7bc90c8ab6d0f6207d491cf6dad7c66ea797b4614b71922e9",
"sub": "alana",
"context": {
"user": {
"userKey": "alana",
"username": "aaware",
"displayName": "Bruce Wayne"
}
}
}
"iss": "confluence:1314039",
"iat": 1300819370,
"exp": 1300819380,
"qsh": “8063ff4…2e9”,
"sub": "alana",
57. • Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
DRY
https://flic.kr/p/qkUpu
62. • Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
Let’s build a Connect add-on
from scratch
https://flic.kr/p/rtmnT2
63. • Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
A page in a page
https://flic.kr/p/216z4i
69. Create a project
e
$> mvn archetype:generate -DgroupId=com.atlassian.labs.atlascamp
-DartifactId=inception -DarchetypeArtifactId=maven-archetype-
quickstart -DinteractiveMode=false
74. Create the application
e
package com.atlassian.connect.atlascamp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class InceptionApplication {
public static void main( String[] args ) {
SpringApplication.run(InceptionApplication.class, args);
}
}
75. Create the application
e
package com.atlassian.connect.atlascamp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class InceptionApplication {
public static void main( String[] args ) {
SpringApplication.run(InceptionApplication.class, args);
}
}
@SpringBootApplication
public class InceptionApplication {
76. Create the application
e
package com.atlassian.connect.atlascamp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class InceptionApplication {
public static void main( String[] args ) {
SpringApplication.run(InceptionApplication.class, args);
}
}
public static void main(String[] args) {
SpringApplication.run(InceptionApplication.class, args);
}
78. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
79. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “https://1c12a2cd.ngrok.io”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
80. Descriptor
e
{
"name": "Inception",
"description": “A page in a page",
"key": “com.atlassian.connect.atlascamp.inception”,
"baseUrl": “http://localhost:8080”,
"vendor": {
"name": "Atlassian",
"url": "http://www.atlassian.com"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed",
"uninstalled": "/uninstalled",
"enabled": "/enabled",
"disabled": "/disabled"
},
"apiVersion": 1,
"scopes": [
"read"
],
"modules": {
}
}
"modules": {
}
81. Descriptor
e
"modules": {
"dynamicContentMacros": [ {
"url": "/inception-macro?pageId={page.id}",
"description": {
"value": "A page in a page"
},
"name": {
"value": "Inception"
},
"categories": [
"visuals"
],
"outputType": "block",
"bodyType": "none",
"aliases": [
"inception"
],
"featured": true,
"parameters": [],
"key": "inception-macro"
}
]
}
82. Descriptor
e
"modules": {
"dynamicContentMacros": [ {
"url": "/inception-macro?pageId={page.id}",
"description": {
"value": "A page in a page"
},
"name": {
"value": "Inception"
},
"categories": [
"visuals"
],
"outputType": "block",
"bodyType": "none",
"aliases": [
"inception"
],
"featured": true,
"parameters": [],
"key": "inception-macro"
}
]
}
"dynamicContentMacros": [ {
"url": "/inception-macro?pageId={page.id}",
"description": {
"value": "A page in a page"
},
88. Macro template
e
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui.min.css" media="all"/>
<script th:src=“${js-all-url}” type="text/javascript"></script>
</head>
<body>
<section id="content" class="ac-content">
<p th:utext="${body}"/>
</section>
</body>
</html>
89. Macro template
e
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui.min.css" media="all"/>
<script th:src=“${js-all-url}” type="text/javascript"></script>
</head>
<body>
<section id="content" class="ac-content">
<p th:utext="${body}"/>
</section>
</body>
</html>
<script th:src=“${js-all-url}” type="text/javascript"></script>
90. Macro template
e
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui.min.css" media="all"/>
<script th:src=“${js-all-url}” type="text/javascript"></script>
</head>
<body>
<section id="content" class="ac-content">
<p th:utext="${body}"/>
</section>
</body>
</html>
<section id="content" class="ac-content">
<p th:utext="${body}"/>
</section>
91. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
92. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
@Controller
public class InceptionController {
93. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
private static final String PAGE_URL
private static final String JS_URL
94. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
@Autowired
private RestTemplate restTemplate;
95. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
96. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
97. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
98. Controller
e
package com.atlassian.connect.atlascamp;
@Controller
public class InceptionController {
private static final String PAGE_URL = "%s/rest/api/content/%s?expand=body.export_view";
private static final String JS_URL = "%s/atlassian-connect/all.js";
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/inception-macro")
public String render(@RequestParam long pageId,
@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {
final String baseURL = hostUser.getHost().getBaseUrl();
final String contentUrl = String.format(PAGE_URL, baseURL, pageId);
final String pageContent = restTemplate.getForObject(contentUrl, String.class);
final String pageBody = extractPageBody(pageContent);
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
}
model.addAttribute("body", pageBody);
model.addAttribute("jsurl", String.format(JS_URL, baseURL));
return "inception-macro";
109. VINCENT KOK • DEVELOPMENT MANAGER • ATLASSIAN • @VINCENTKOK
Thank you!