public ConnectRunner start() throws Exception { URI host = URI.create(this.productBaseUrl); port = Utils.pickFreePort(); final String displayUrl = "http://" + host.getHost() + ':' + port + urlPath; addonBuilder.withBaseurl(displayUrl); addonBuilder.withScopes(scopes); this.addon = addonBuilder.build(); server = new Server(port); HandlerList list = new HandlerList(); server.setHandler(list); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); context.addServlet(new ServletHolder(new DescriptorServlet()), REGISTRATION_ROUTE); for (final Map.Entry<String, HttpServlet> entry : routes.entrySet()) { if (entry.getValue() instanceof HttpContextServlet) { ((HttpContextServlet) entry.getValue()).getBaseContext().putAll(getBaseContext()); } context.addServlet(new ServletHolder(entry.getValue()), entry.getKey()); } toggleableConditionServlet = new ToggleableConditionServlet(true); context.addServlet(new ServletHolder(toggleableConditionServlet), ToggleableConditionServlet.TOGGLE_CONDITION_URL); list.addHandler(context); server.start(); log.info("Started Atlassian Connect Add-On at " + displayUrl + REGISTRATION_ROUTE); register(); return this; }
addonBuilder.withBaseurl(addonBaseUrl); addonBuilder.withScopes(scopes);
private static String createAddonExample() { Map<String, String> links = ImmutableMap.<String, String>builder().put("self", "http://www.example.com/connect/jira").build(); Set<ScopeName> scopes = Sets.newHashSet(ScopeName.READ, ScopeName.WRITE); ConnectAddonBean addonBean = newConnectAddonBean() .withKey("my-addon-key") .withName("My Connect Addon") .withDescription("A connect addon that does something") .withVendor(newVendorBean().withName("My Company").withUrl("http://www.example.com").build()) .withBaseurl("http://www.example.com/connect/jira") .withLinks(links) .withAuthentication(newAuthenticationBean().build()) .withLicensing(true) .withLifecycle(LifecycleBean.newLifecycleBean().withInstalled("/installed").withUninstalled("/uninstalled").build()) .withScopes(scopes) .build(); final JsonElement jsonRepresentation = gson.toJsonTree(addonBean); // Remove the version element from the example because our vendors should jsonRepresentation.getAsJsonObject().remove("version"); return gson.toJson(jsonRepresentation); }
private static String createAddonExample() { Map<String, String> links = ImmutableMap.<String, String>builder().put("self", "http://www.example.com/connect/jira").build(); Set<ScopeName> scopes = Sets.newHashSet(ScopeName.READ, ScopeName.WRITE); ConnectAddonBean addonBean = newConnectAddonBean() .withKey("my-addon-key") .withName("My Connect Addon") .withDescription("A connect addon that does something") .withVendor(newVendorBean().withName("My Company").withUrl("http://www.example.com").build()) .withBaseurl("http://www.example.com/connect/jira") .withLinks(links) .withAuthentication(newAuthenticationBean().build()) .withLicensing(true) .withLifecycle(LifecycleBean.newLifecycleBean().withInstalled("/installed").withUninstalled("/uninstalled").build()) .withScopes(scopes) .build(); final JsonElement jsonRepresentation = gson.toJsonTree(addonBean); // Remove the version element from the example because our vendors should jsonRepresentation.getAsJsonObject().remove("version"); return gson.toJson(jsonRepresentation); }
.withKey(rawConnectAddon.getAddonKey()) .withAuthentication(new AuthenticationBeanBuilder().withType(AuthenticationType.valueOf(rawConnectAddon.getAuthType())).build()) .withBaseurl(rawConnectAddon.getBaseUrl()) .withScopes(addonScopes) .withDependencies(new DependenciesBean(dependencyBeanSet));
private ConnectAddonBean createAddonBeanWithScope(ScopeName scopeName) { final String key = getPluginKeyForScopeName(scopeName); ConnectAddonBeanBuilder connectAddonBeanBuilder = newConnectAddonBean() .withKey(key) .withName(key) .withBaseurl(testPluginInstaller.getInternalAddonBaseUrl(key)) .withLicensing(true) .withAuthentication(newAuthenticationBean() .withType(AuthenticationType.JWT) .build()) .withLifecycle(newLifecycleBean() .withInstalled("/installed") .build()) .withModule("generalPages", newPageBean() .withUrl("/hello-world.html") .withKey("general") .withName(I18nProperty.value("Greeting")) .build()); // scopes are optional so that we can have "no scopes" test classes if (null != scopeName) { connectAddonBeanBuilder = connectAddonBeanBuilder.withScopes(new HashSet<>(singletonList(scopeName))); } return connectAddonBeanBuilder.build(); } }