@DELETE @Path("/{" + ADDON_KEY_PATH_PARAMETER + "}") @ResourceFilters(SysadminOnlyResourceFilter.class) @Produces("application/json") public Response uninstallAddon(@PathParam(ADDON_KEY_PATH_PARAMETER) String addonKey) { try { Optional<ConnectAddonBean> optionalAddonBean = addonAccessor.getAddon(addonKey); if (optionalAddonBean.isPresent()) { RestMinimalAddon addon = new RestMinimalAddon(addonKey, optionalAddonBean.get().getVersion()); connectAddonManager.uninstallConnectAddon(addonKey); return Response.ok().entity(addon).build(); } } catch (Exception e) { String message = "Unable to uninstall add-on " + addonKey + ": " + e.getMessage(); log.error(message, e); return getErrorResponse(message, Response.Status.INTERNAL_SERVER_ERROR); } String message = "Add-on with key " + addonKey + " was not found"; return getErrorResponse(message, Response.Status.NOT_FOUND); }
private RestLimitedAddon createJsonAddonRest(ConnectAddonBean addonBean) { String key = addonBean.getKey(); String version = addonBean.getVersion(); PluginState state = addonRegistry.getRestartState(key); String stateString = state.name(); RestHost host = getHostResource(); RestAddonLicense license = getLicenseResourceForAddon(key); RestRelatedLinks addonLinks = getAddonLinks(key); RestInternalAddon.AddonApplink appLinkResource = getApplinkResourceForAddon(key); RestLimitedAddon resource; if (userManager.isSystemAdmin(userManager.getRemoteUserKey())) { resource = new RestInternalAddon(key, version, stateString, host, license, addonLinks, appLinkResource); } else { if (state.equals(PluginState.DISABLED) || state.equals(PluginState.DISABLING)) { resource = new RestLimitedAddon(key, version, stateString); } else { resource = new RestAddon(key, version, stateString, host, license, addonLinks); } } return resource; }
private PluginInformation createPluginInfo(ConnectAddonBean addon) { PluginInformation pluginInfo = new PluginInformation(); pluginInfo.setDescription(addon.getDescription()); pluginInfo.setVendorName(addon.getVendor().getName()); pluginInfo.setVendorUrl(addon.getVendor().getUrl()); pluginInfo.setVersion(addon.getVersion()); pluginInfo.addParameter(PARAM_ATLASSIAN_CONNECT_INFO, "true"); if (addon.getEnableLicensing()) { pluginInfo.addParameter(PARAM_ATLASSIAN_LICENSING_ENABLED, "true"); } addPluginInfoParameterForPageIfDeclared(pluginInfo, PARAM_CONFIGURE_URL, addon, new ConfigurePageModuleMeta().getDescriptorKey()); addPluginInfoParameterForPageIfDeclared(pluginInfo, PARAM_POST_INSTALL_URL, addon, new PostInstallPageModuleMeta().getDescriptorKey()); return pluginInfo; }