@Nonnull public static String resolveApplicationTypeId(@Nonnull ApplicationType type) { return isIdentifiable(type) ? asIdentifiableType(type).getId().get() : type.getI18nKey(); }
@Override public Communicator get(ApplicationLink applicationLink) { checkNotNull(applicationLink); LOGGER.debug("Getting a Communicator for ApplicationLink '" + applicationLink.getName() + "' of type " + applicationLink.getType().getI18nKey()); if (applicationLink.getType() instanceof SonarQubeApplicationType) { return new DefaultCommunicator(authenticationConfigurationManager, applicationLink); } else { throw new IllegalArgumentException(applicationLink.getName() + " is not a SonarQube Application Link"); } }
@GET public Response getTypes() { List<BaseRestEntity> entityList = new ArrayList<BaseRestEntity>(); for (ApplicationType type : typeAccessor.getEnabledApplicationTypes()) { BaseRestEntity.Builder builder = new BaseRestEntity.Builder(); builder.add("name", type.getI18nKey()); builder.add("iconUrl", type.getIconUrl()); builder.add("iconUri", resolveIconUri(type)); entityList.add(builder.build()); } return ok(entityList).build(); }
/** * Get a {@link Communicator} instance for the given {@link Site} and {@link ApplicationLink} given * * @param site the {@link Site} * @param applicationLink the {@link ApplicationLink} * @return teh {@link Communicator} instance */ private Communicator getByApplicationLink(Site site, ApplicationLink applicationLink) { checkNotNull(site, "site cannot be null"); checkNotNull(applicationLink, "applicationLink cannot be null"); LOGGER.debug("Getting a Communicator for ApplicationLink '" + applicationLink.getName() + "' of type " + applicationLink.getType ().getI18nKey()); if (applicationLink.getType() instanceof JenkinsApplicationType || applicationLink.getType() instanceof HudsonApplicationType) { return new RestCommunicator(hostApplication, site, applicationLink, authenticationConfigurationManager); } else { throw new IllegalArgumentException(applicationLink.getName() + " is not a Jenkins Application Link"); } }
public Map<String, String> apply(ApplicationLink from) { return ImmutableMap.of("id", from.getId().get(), "name", from.getName(), "type", i18nResolver.getText(from.getType().getI18nKey())); } })));
if (selectedType != null && !selectedType.equals("") && !selectedType.equals(appLink.getType().getI18nKey())) { continue; String appName = appLink.getType().getI18nKey(); String authenticatedUser; try {
protected RendererContextBuilder createContextBuilder(final ApplicationLink applicationLink) { final RendererContextBuilder builder = new RendererContextBuilder() .put("localApplicationName", internalHostApplication.getName()) .put("localApplicationType", i18nResolver.getText(internalHostApplication.getType().getI18nKey())) .put("remoteApplicationName", applicationLink.getName()) .put("remoteApplicationType", i18nResolver.getText(applicationLink.getType().getI18nKey())); return builder; }
private void render( final ApplicationLink appLink, final HttpServletRequest request, final HttpServletResponse response) throws IOException { final boolean enabled = configurationManager.isConfigured(appLink.getId(), TrustedAppsAuthenticationProvider.class); final String consumer = internalHostApplication.getName(); final String consumerAppType = i18nResolver.getText(internalHostApplication.getType().getI18nKey()); final String provider = appLink.getName(); final String providerAppType = i18nResolver.getText(appLink.getType().getI18nKey()); render(request, response, consumer, consumerAppType, provider, providerAppType, enabled, emptyContext()); } }
protected RendererContextBuilder createContextBuilder(final ApplicationLink applicationLink) { return new RendererContextBuilder() .put("localApplicationName", internalHostApplication.getName()) .put("localApplicationType", i18nResolver.getText(internalHostApplication.getType().getI18nKey())) .put("remoteApplicationName", applicationLink.getName()) .put("remoteApplicationType", i18nResolver.getText(applicationLink.getType().getI18nKey())); }
public static RendererContextBuilder createContextBuilder(final ApplicationLink applicationLink, final I18nResolver i18nResolver, final InternalHostApplication internalHostApplication) { final RendererContextBuilder builder = new RendererContextBuilder() .put("localApplicationName", internalHostApplication.getName()) .put("localApplicationType", i18nResolver.getText(internalHostApplication.getType().getI18nKey())) .put("remoteApplicationName", applicationLink.getName()) .put("remoteApplicationType", i18nResolver.getText(applicationLink.getType().getI18nKey())); return builder; }
public static RendererContextBuilder createContextBuilder(final ApplicationLink applicationLink, final I18nResolver i18nResolver, final InternalHostApplication internalHostApplication) { final RendererContextBuilder builder = new RendererContextBuilder() .put("localApplicationName", internalHostApplication.getName()) .put("localApplicationType", i18nResolver.getText(internalHostApplication.getType().getI18nKey())) .put("remoteApplicationName", applicationLink.getName()) .put("remoteApplicationType", i18nResolver.getText(applicationLink.getType().getI18nKey())); return builder; }
private BaseRestEntity getAllTypes() { BaseRestEntity.Builder allTypes = new BaseRestEntity.Builder(); for (final ApplicationType applicationType : typeAccessor.getEnabledApplicationTypes()) { allTypes.add(resolveApplicationTypeId(applicationType), i18nResolver.getText(applicationType.getI18nKey())); } return allTypes.build(); } }
/** * {@link EventListener} for {@link ApplicationLinksIDChangedEvent} events * * @param event the {@link ApplicationLinksIDChangedEvent} event */ @EventListener public void onApplicationLinkIDChanged(ApplicationLinksIDChangedEvent event) { if (supportsApplicationLinkType(event)) { LOGGER.info("Updating applinkId from {} to {}", event.getOldApplicationId().get(), event.getApplicationId().get()); siteService.updateApplicationLink(event.getApplicationLink(), event.getOldApplicationId()); } else { LOGGER.debug("Skipping applinks event for type {}", event.getApplicationType().getI18nKey()); } }
private void addApplicationLinkInformation(SupportInfoBuilder builder) { for (ApplicationLink link : linkService.getApplicationLinks()) { SupportInfoBuilder linkBuilder = builder.addCategory(LINK); linkBuilder.addValue(LINK_NAME, link.getName()); linkBuilder.addValue(LINK_PRIMARY, String.valueOf(link.isPrimary())); linkBuilder.addValue(LINK_TYPE, link.getType().getI18nKey()); linkBuilder.addValue(LINK_DISPLAY_URL, link.getDisplayUrl().toString()); linkBuilder.addValue(LINK_RPC_URL, link.getRpcUrl().toString()); linkBuilder.addContext(link); } }
/** * {@link EventListener} for {@link ApplicationLinkAuthConfigChangedEvent} events * * @param event the {@link ApplicationLinkAuthConfigChangedEvent} event */ @EventListener public void onApplicationLinkAuthConfigChangedEvent(ApplicationLinkAuthConfigChangedEvent event) { if (supportsApplicationLinkType(event)) { Site site = siteService.getByApplicationLink(event.getApplicationLink()); LOGGER.info("Auth details changed for {}, scheduling job synchronisation", site.getName()); site.setSupportsBackLink(communicatorFactory.get(site).isJenkinsPluginInstalled()); siteService.save(site); jobService.syncJobList(site); } else { LOGGER.debug("Skipping applinks event for type {}", event.getApplicationType().getI18nKey()); } }
public ApplicationOption apply(final ApplicationLink from) { boolean isUal = false; try { isUal = manifestRetriever.getManifest( from.getRpcUrl(), from.getType()).getAppLinksVersion() != null; } catch (ManifestNotFoundException e) { } catch (Exception ex) { log.error("Could not retrieve manifest for applink, ignoring applink : {}", from); log.warn("Stack trace: ", ex); return null; } return new ApplicationOption( from.getId(), from.getName(), TypeId.getTypeId(from.getType()), from.getType().getI18nKey(), isUal, IconUriResolver.resolveIconUri(from.getType()) == null ? null : IconUriResolver.resolveIconUri(from.getType()).toString()); } }
final boolean enabled = null != trustedAppsId; final String consumer = appLink.getName(); final String consumerAppType = i18nResolver.getText(appLink.getType().getI18nKey()); final String provider = internalHostApplication.getName(); final String providerAppType = i18nResolver.getText(internalHostApplication.getType().getI18nKey());
/** * {@link EventListener} for {@link ApplicationLinkAddedEvent} events * * @param event the {@link ApplicationLinkAddedEvent} event */ @EventListener public void onApplicationLinkAdded(ApplicationLinkAddedEvent event) { if (supportsApplicationLinkType(event)) { LOGGER.info("Synchronizing the Job list of new applink {} [{}]", event.getApplicationLink().getName(), event.getApplicationLink().getDisplayUrl()); // The getByApplicationLink method will auto save a new Site if needed Site site = siteService.getByApplicationLink(event.getApplicationLink()); site.setSupportsBackLink(communicatorFactory.get(site).isJenkinsPluginInstalled()); site.setAutoLink(false); siteService.save(site); jobService.syncJobList(site); } else { LOGGER.debug("Skipping applinks event for type {}", event.getApplicationType().getI18nKey()); } }
final String applicationType = i18nResolver.getText(internalHostApplication.getType().getI18nKey()); try { if (isRpcUrlValid(linkDetails.getRemoteUrl(), linkDetails.getRpcUrl(), linkDetails.getUsername(), linkDetails.getPassword())) {
/** * Add i18n properties for all enabled {@link ApplicationType}, {@link EntityType} and * {@link AuthenticationProvider}s * * @return the builder */ public BatchedJSONI18nBuilder withPluggableApplinksModules() { for (final ApplicationType applicationType : typeAccessor.getEnabledApplicationTypes()) { final String key = "applinks.application.type." + TypeId.getTypeId(applicationType); put(key, i18nResolver.getText(applicationType.getI18nKey())); } for (final EntityType entityType : typeAccessor.getEnabledEntityTypes()) { final String key = "applinks.entity.type." + TypeId.getTypeId(entityType); put(key, i18nResolver.getText(entityType.getI18nKey())); final String pluralKey = "applinks.entity.type.plural." + TypeId.getTypeId(entityType); put(pluralKey, i18nResolver.getText(entityType.getPluralizedI18nKey())); } for (final AuthenticationProviderModuleDescriptor authProvider : pluginAccessor.getEnabledModuleDescriptorsByClass(AuthenticationProviderModuleDescriptor.class)) { final String key = "applinks.auth.provider." + authProvider.getModule().getAuthenticationProviderClass().getName(); put(key, i18nResolver.getText(authProvider.getI18nNameKey())); } return this; }