private void deleteOldAppLinks(String pluginKey, ApplicationId appId) { ApplicationLink link; try { link = applicationLinkService.getApplicationLink(appId); } catch (TypeNotInstalledException ex) { log.warn("Link found for '{}' but the type cannot be found, deleting...", pluginKey); manuallyDeleteApplicationId(appId); return; } if (null != link) { if (pluginKey.equals(link.getProperty(PLUGIN_KEY_PROPERTY))) { // This shouldn't happen in normal operation as we delete the applink when we uninstall an addon // and we uninstall the old addon when we install a new version log.warn("Application link for remote plugin container '{}' already exists. Deleting", pluginKey); applicationLinkService.deleteApplicationLink(link); } else { throw new IllegalStateException("Application link already exists for id '" + appId + "' but it isn't the target " + " plugin '" + pluginKey + "': unexpected plugin key is: " + link.getProperty(PLUGIN_KEY_PROPERTY)); } } else { // try to find link with old display url for (final ApplicationLink otherLink : applicationLinkService.getApplicationLinks(RemotePluginContainerApplicationType.class)) { if (pluginKey.equals(otherLink.getProperty(PLUGIN_KEY_PROPERTY))) { log.debug("Old application link for this plugin '{}' found with different display url '{}', removing", pluginKey, otherLink.getDisplayUrl()); applicationLinkService.deleteApplicationLink(otherLink); } } } }
@GET @Path("setApplicationLink") public Response setApplicationLinkProperty(@QueryParam("propertyKey") String propertyKey, @QueryParam("propertyValue") String propertyValue) { final ApplicationLink applicationLink = applicationLinkService.getPrimaryApplicationLink(GenericApplicationType.class); applicationLink.putProperty(propertyKey, propertyValue); return ok("Properties updated!").build(); }
private void configureTwoWayAuth(final ConfigureAuthEntity entity, ApplicationLink link) throws AuthenticationConfigurationException { linkService.configureAuthenticationForApplicationLink( link, new AuthenticationScenario() { public boolean isCommonUserBase() { return entity.sharedUserBase; } public boolean isTrusted() { return entity.trusted; } }, entity.username, entity.password); }
@Override public void hastaLaVistaAppLinks() { for (ApplicationLink applicationLink : applicationLinkService.getApplicationLinks()) { applicationLinkService.deleteApplicationLink(applicationLink); } } }
public void deleteApplicationLink(ApplicationId applicationId) { try { final MutableApplicationLink applicationLink = applinkservice.getApplicationLink(applicationId); if (applicationLink != null) { applinkservice.deleteApplicationLink(applicationLink); } } catch (TypeNotInstalledException e) { //ignore } }
@DELETE @WebSudoNotRequired public Response cleanAll(DeleteAllRequestEntity request) { int count = 0; for (ApplicationLink link : linkService.getApplicationLinks()) { if (request.reciprocal) { try { linkService.deleteReciprocatedApplicationLink(link); } catch (Exception e) { linkService.deleteApplicationLink(link); } } else { linkService.deleteApplicationLink(link); } count++; } return Response.ok(new DeleteAllResponseEntity(count)).build(); }
/** * Find the ApplicationLink by its id. */ private ApplicationLink findApplicationLink(final String id) throws TypeNotInstalledException { ApplicationId applicationId; try { applicationId = new ApplicationId(id); } catch (IllegalArgumentException e) { return null; } return applicationLinkService.getApplicationLink(applicationId); }
@DELETE @WebSudoNotRequired @Path("{id}") public Response deleteApplicationLink(@PathParam("id") final String idString, @QueryParam("reciprocate") final Boolean reciprocate) throws TypeNotInstalledException { final ApplicationId id = new ApplicationId(idString); final MutableApplicationLink link = applicationLinkService.getApplicationLink(id); if (link == null) { return notFound(i18nResolver.getText("applinks.notfound", id.get())); } // only a sysadmin can delete a system link. if (link.isSystem() && !userManager.isSystemAdmin(userManager.getRemoteUsername())) { return forbidden(i18nResolver.getText("applinks.error.only.sysadmin.operation")); } if (reciprocate != null && reciprocate) { try { applicationLinkService.deleteReciprocatedApplicationLink(link); } catch (final CredentialsRequiredException e) { return credentialsRequired(i18nResolver); } catch (final ReciprocalActionException e) { return serverError(i18nResolver.getText("applinks.remote.delete.failed", e.getMessage())); } } else { applicationLinkService.deleteApplicationLink(link); } return ok(i18nResolver.getText("applinks.deleted", id.get())); }
ApplicationLink applicationLink; try { applicationLink = applinkservice.addApplicationLink(id, applicationType, linkDetails); log.debug(format("created application link [%s]. Continue with configuration of the link", applicationLink)); } catch (IllegalArgumentException e) { try { applicationLink = applinkservice.getApplicationLink(id); if (applicationLink == null) applinkservice.deleteApplicationLink(applicationLink); applicationLink = applinkservice.addApplicationLink(id, applicationType, linkDetails);
final MutableApplicationLink existing = applicationLinkService.getApplicationLink(applicationId); applicationLinkService.addApplicationLink(applicationLink.getId(), type, applicationLink.getDetails()); return created(createSelfLinkFor(applicationLink.getId())); } else { if (applicationLinkService.isNameInUse(linkDetails.getName(), applicationId)) { return badRequest(i18nResolver.getText("applinks.error.duplicate.name", applicationLink.getName()));
@AnonymousAllowed @GET public Response all() { final Iterable<ApplicationLink> links = linkService.getApplicationLinks(); return Response.ok(Iterables.transform(links, new Function<ApplicationLink, ApplinkEntity>() { public ApplinkEntity apply(ApplicationLink link) { return new ApplinkEntity(link); } })).build(); }
public void rollbackApplicationLinkConfiguration(ApplicationLink applicationLink) { // try to clean up local state changes, so the user can retry the connection after manually clearing state // from the target JIRA instance (as per the troubleshooting guide) try { if (applicationLink != null) { applicationLinkService.deleteApplicationLink(applicationLink); } // TODO: How to delete the reverse application link? LOG.info("Rolled back 2-way application link to JIRA."); } catch (Exception rollbackException) { // this is possibly what caused the original failure necessitating the rollback, log & ignore LOG.error("Failed to rollback local UAL/Crowd configuration", rollbackException); } }
if (applicationLinkService.getApplicationLink(applicationId) != null) { applicationLinkService.addApplicationLink(applicationId, applicationType, applicationLink.getDetails());
@PUT @WebSudoNotRequired @XsrfProtectionExcluded @Path("{applinkid}") public javax.ws.rs.core.Response configureAuthentication(@PathParam("applinkid") String applinkId, RestAuthenticationConfiguration configuration) throws Exception { ApplicationLink applink = applicationLinkService.getApplicationLink(parseApplicationId(applinkId)); applicationLinkService.configureAuthenticationForApplicationLink(applink, configuration.getAuthenticationScenario(), configuration.getUsername(), configuration.getPassword()); return RestResponses.noContent(); }
@POST @Path("createStaticUrlAppLink") public javax.ws.rs.core.Response createStaticUrlAppLink(@QueryParam("typeId") final String typeId) throws Exception { final StaticUrlApplicationType type = (StaticUrlApplicationType) typeAccessor.loadApplicationType(typeId); Manifest manifest = manifestRetriever.getManifest(type.getStaticUrl(), type); ApplicationLinkDetails details = ApplicationLinkDetails.builder().name(type.getI18nKey()) .displayUrl(type.getStaticUrl()).rpcUrl(type.getStaticUrl()).isPrimary(true).build(); final ApplicationLink createdApplicationLink = applicationLinkService.addApplicationLink(manifest.getId(), type, details); return ok(new CreatedApplicationLinkEntity(toApplicationLinkEntity(createdApplicationLink), true)); }
final MutableApplicationLink existing = applicationLinkService.getApplicationLink(applicationId); if (applicationLinkService.isNameInUse(linkDetails.getName(), applicationId)) { return RestUtil.badRequest(i18nResolver.getText("applinks.error.duplicate.name", applicationLink.getName()));
if (upgradeApplicationLinkRequestEntity.isCreateTwoWayLink()) { try { if (!applicationLinkService.isAdminUserInRemoteApplication( oldApplicationLink.getRpcUrl(), upgradeApplicationLinkRequestEntity.getUsername(), applicationLinkService.changeApplicationId(oldApplicationLink.getId(), manifest.getId()); final ApplicationLink newApplicationLink = applicationLinkService.getApplicationLink(manifest.getId());
applicationLinkService.createReciprocalLink(remoteRpcUrl, applicationLinkRequest.isCustomRpcURL() ? applicationLinkRequest.getRpcUrl() : null, applicationLinkRequest.getUsername(), applicationLinkRequest.getPassword()); } catch (final NotAdministratorException exception) { return badFormRequest(Lists.newArrayList(i18nResolver.getText("applinks.error.unauthorized")), Lists.newArrayList("authorization")); final ApplicationLink createdApplicationLink; try { createdApplicationLink = applicationLinkService.createApplicationLink(type, applicationLink.getDetails()); } catch (ManifestNotFoundException e) { return serverError(i18nResolver.getText("applinks.error.incorrect.application.type")); applicationLinkService.configureAuthenticationForApplicationLink( createdApplicationLink, new AuthenticationScenario() {
@POST @Path ("primary/{id}") public Response makePrimary(@PathParam ("id") final String idString) throws TypeNotInstalledException { final ApplicationId id = new ApplicationId(idString); applicationLinkService.makePrimary(id); return updated(Link.self(applicationLinkService.createSelfLinkFor(id)), i18nResolver.getText("applinks.primary", id.get())); }
ApplicationType type = getApplicationType(uri, entity); if (entity.twoWay) { linkService.createReciprocalLink(uri, null, entity.username, entity.password); ApplicationLink link = linkService.createApplicationLink(type, ApplicationLinkDetails.builder() .displayUrl(uri) .rpcUrl(uri)