private ConnectAddonBean deserializeDescriptor(final String jsonDescriptor) { JsonElement element = new JsonParser().parse(jsonDescriptor); ShallowConnectAddonBean shallowBean = ConnectModulesGsonFactory.shallowAddonFromJson(element); ModuleListDeserializer moduleDeserializer = new PluggableModuleListDeserializer( pluginAccessor, descriptorSchemaValidator, moduleListEntryDeserializer, shallowBean); final Map<String, Supplier<List<ModuleBean>>> moduleList = ConnectModulesGsonFactory.moduleListFromJson(element, moduleDeserializer); return new ConnectAddonBeanBuilder(shallowBean).withModuleList(moduleList).build(); }
/** * Create a ConnectRunner for an add-on with a specified key * @param productBaseUrl the url of the product to install the add-on into * @param key the key for the add-on */ public ConnectRunner(String productBaseUrl, String key) { this.productBaseUrl = checkNotNull(productBaseUrl); this.addonBuilder = newConnectAddonBean() .withKey(key) .withName(key) .withVersion("1.0"); this.installer = new AtlassianConnectRestClient(productBaseUrl, "admin", "admin"); }
public ConnectRunner enableLicensing() { addonBuilder.withLicensing(true); return this; }
private LifecycleBean getLifecycle() { if (null == addonBuilder.getLifecycle()) { addonBuilder.withLifecycle(newLifecycleBean().build()); } return addonBuilder.getLifecycle(); }
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); }
.collect(Collectors.toSet()); final ConnectAddonBeanBuilder builder = new ConnectAddonBeanBuilder() .withKey(rawConnectAddon.getAddonKey()) .withAuthentication(new AuthenticationBeanBuilder().withType(AuthenticationType.valueOf(rawConnectAddon.getAuthType())).build()) .withBaseurl(rawConnectAddon.getBaseUrl()) .withScopes(addonScopes) .withDependencies(new DependenciesBean(dependencyBeanSet)); rawConnectAddon.getVersion().ifPresent(version -> builder.withVersion(version)); oRawConnectAddonListingData.ifPresent(rawConnectAddonListingData -> builder.withName(rawConnectAddonListingData.getAddonName().orElse(null)) .withDescription(rawConnectAddonListingData.getDescription().orElse(null)) .withVendor(new VendorBeanBuilder() .withName(rawConnectAddonListingData.getVendorName().orElse(null)) .withUrl(rawConnectAddonListingData.getVendorUrl().orElse("")) .build() .withLicensing(rawConnectAddonListingData.isLicenseEnabled()) ); return Optional.of(builder.build()); } else { return Optional.empty();
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(); } }
}); addonBuilder.withTranslations(new TranslationsBean(paths)); addonBuilder.withBaseurl(addonBaseUrl); addonBuilder.withScopes(scopes); this.addon = builderMapper.apply(addonBuilder).build();
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; }
public ConnectRunner addDisableLifecycle() { LifecycleBean lifecycle = getLifecycle(); addonBuilder.withLifecycle(newLifecycleBean(lifecycle).withDisabled(DISABLED_PATH).build()); return this; }
public ConnectRunner setAuthenticationToNone() { addonBuilder.withAuthentication(AuthenticationBean.none()); return this; }
public static ConnectAddonBeanBuilder newConnectAddonBean() { return new ConnectAddonBeanBuilder(); }
public ConnectRunner setVendor(final VendorBean vendor) { addonBuilder.withVendor(vendor); return this; }
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); }
public ConnectRunner addEnableLifecycle() { LifecycleBean lifecycle = getLifecycle(); addonBuilder.withLifecycle(newLifecycleBean(lifecycle).withEnabled(ENABLED_PATH).build()); return this; }
public ConnectRunner setAuthenticationToNone() { addonBuilder.withAuthentication(AuthenticationBean.none()); return this; }
private LifecycleBean getLifecycle() { if (null == addonBuilder.getLifecycle()) { addonBuilder.withLifecycle(newLifecycleBean().build()); } return addonBuilder.getLifecycle(); }
public static ConnectAddonBeanBuilder newConnectAddonBean(ShallowConnectAddonBean defaultBean) { return new ConnectAddonBeanBuilder(defaultBean); }
public ConnectRunner setVendor(final VendorBean vendor) { addonBuilder.withVendor(vendor); return this; }
/** * Create a ConnectRunner for an add-on with a specified key * @param productBaseUrl the url of the product to install the add-on into * @param key the key for the add-on */ public ConnectRunner(String productBaseUrl, String key) { this.productBaseUrl = checkNotNull(productBaseUrl); this.addonKey = key; this.addonBuilder = newConnectAddonBean() .withKey(key) .withName(key) .withVersion("1.0"); this.installer = new AtlassianConnectRestClient(productBaseUrl, "admin", "admin"); }