/** * 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); }
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); } } } }
public void deleteApplicationLink(ApplicationId applicationId) { try { final MutableApplicationLink applicationLink = applinkservice.getApplicationLink(applicationId); if (applicationLink != null) { applinkservice.deleteApplicationLink(applicationLink); } } catch (TypeNotInstalledException e) { //ignore } }
/** * 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 @Path("{applinkId}/property/{key}") public Response removeProperty(@PathParam("applinkId") String applinkId, @PathParam("key") String key) throws TypeNotInstalledException { ApplicationId id = parseApplicationId(applinkId); ApplicationLink applink = linkService.getApplicationLink(id); applink.removeProperty(key); return Response.noContent().build(); }
@PUT @Path("{applinkId}/property/{key}") public Response setProperty(@PathParam("applinkId") String applinkId, @PathParam("key") String key, RestProperty restProperty) throws TypeNotInstalledException { ApplicationId id = parseApplicationId(applinkId); ApplicationLink applink = linkService.getApplicationLink(id); applink.putProperty(key, restProperty.getValue()); return Response.created(URI.create("")).entity(restProperty).build(); }
@Nonnull @Override public MutableApplicationLink getMutableApplicationLink(@Nonnull ApplicationId id) throws NoSuchApplinkException { checkNotNull(id, "id"); try { MutableApplicationLink link = mutatingApplicationLinkService.getApplicationLink(id); checkExists(id, link); return link; } catch (TypeNotInstalledException e) { throw typeNotInstalled(e); } }
@AnonymousAllowed @GET @Path("{applinkid}") public Response singleApplink(@PathParam("applinkid") String applinkId) throws TypeNotInstalledException { final ApplicationLink applink = linkService.getApplicationLink(new ApplicationId(applinkId)); return Response.ok(new ApplinkEntity(applink)).build(); }
@GET @Path("{id}") public Response getApplicationLink(@PathParam("id") final String id) throws TypeNotInstalledException { final ApplicationLink application = applicationLinkService.getApplicationLink(new ApplicationId(id)); return ok(toApplicationLinkEntity(application)); }
@GET @Path ("{id}") public Response getApplicationLink(@PathParam ("id") final String id) throws TypeNotInstalledException { final ApplicationLink application = applicationLinkService.getApplicationLink(new ApplicationId(id)); return ok(toApplicationLinkEntity(application)); }
private PermissionCode hasPermissionToModify(final ApplicationId id) { if (userManager.getRemoteUsername() == null) { return PermissionCode.NO_AUTHENTICATION; } if (!uiAuthenticator.isCurrentUserAdmin()) { return PermissionCode.NO_PERMISSION; } ApplicationLink applicationLink = null; try { applicationLink = applicationLinkService.getApplicationLink(id); } catch (TypeNotInstalledException e) { // ignore, uninstalled type is equivalent to missing for reciprocation purposes } if (applicationLink == null) { return PermissionCode.MISSING; } return PermissionCode.ALLOWED; }
@PUT @Path("{applinkId}") public Response update(@PathParam("applinkId") String applinkId, ApplinkEntity entity) { try { MutableApplicationLink link = linkService.getApplicationLink(new ApplicationId(applinkId)); ApplicationLinkDetails.Builder builder = ApplicationLinkDetails.builder(link); if (entity.rpcUrl != null) { builder.rpcUrl(URI.create(entity.rpcUrl)); } if (entity.displayUrl != null) { builder.displayUrl(URI.create(entity.displayUrl)); } if (entity.name != null) { builder.name(entity.name); } // add more fields as necessary link.update(builder.build()); return Response.ok(new ApplinkEntity(link)).build(); } catch (TypeNotInstalledException e) { return Response.serverError() .entity("Failed to set applink system flag for '" + applinkId + "': " + e) .build(); } }
@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(); }
@DELETE @WebSudoNotRequired @XsrfProtectionExcluded @Path("{applinkid}") public javax.ws.rs.core.Response disableAuthentication(@PathParam("applinkid") String applinkId, @QueryParam(RestAuthenticationConfiguration.USERNAME) String remoteUsername, @QueryParam(RestAuthenticationConfiguration.PASSWORD) String remotePassword) throws Exception { ApplicationLink applink = applicationLinkService.getApplicationLink(parseApplicationId(applinkId)); for (final AutoConfiguringAuthenticatorProviderPluginModule module : getAutoConfiguringModules()) { if (authenticationConfigurationManager.isConfigured(applink.getId(), module.getAuthenticationProviderClass())) { module.disable(new BasicHttpAuthRequestFactory<>(requestFactory, remoteUsername, remotePassword), applink); } } return RestResponses.noContent(); }
} catch (IllegalArgumentException e) { try { applicationLink = applinkservice.getApplicationLink(id); if (applicationLink == null)
@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())); }
final MutableApplicationLink link = applicationLinkService.getApplicationLink(id); if (link == null)
if (applicationLinkService.getApplicationLink(applicationId) != null) {
throws TypeNotInstalledException { final ApplicationId applicationId = new ApplicationId(id); final MutableApplicationLink applicationLink = applicationLinkService.getApplicationLink(applicationId); if (applicationLink == null) { return notFound(i18nResolver.getText("applinks.notfound", id));
final MutableApplicationLink existing = applicationLinkService.getApplicationLink(applicationId);