private List<Pair<String, Option<Level>>> configureLevels() { long start = System.currentTimeMillis(); List<Pair<String, Option<Level>>> transformed = newArrayList(); for (Pair<String, Option<Level>> level : levels) { Level newLevel = restClient.getAdminSession().getLoggingComponent().setLogLevel(level.left(), level.right().getOrNull()); transformed.add(pair(level.left(), option(newLevel))); } LOG.info("Changed log levels in {}ms: {}", System.currentTimeMillis() - start, levels); return transformed; }
private Map<String, VersionAndFile> getInstalledPluginVersions() { final File[] installedPluginFiles = pluginTargetFolder.listFiles(ApplicationSource::jarsOnly); if (ArrayUtils.isNotEmpty(installedPluginFiles)) { return stream(installedPluginFiles) .map(file -> new Pair<>(file, versionDiscovery.getBundleNameAndVersion(file))) .collect(Collectors.toMap( fileAndVersion -> fileAndVersion.right().getSymbolicName(), fileAndVersion -> new VersionAndFile(fileAndVersion.right().getVersion(), fileAndVersion.left()), PluginBundleInstaller::useNewestVersion )); } return ImmutableMap.of(); }
public Builder ensureEnabled(Plugin plugin) { this.plugins.add(pair(plugin, true)); return this; }
private Collection<Pair<JiraIssueEvent, NotificationInfo>> filterDuplicateMessages( Collection<ListenableFuture<Iterable<Pair<JiraIssueEvent, NotificationInfo>>>> futures ) throws ExecutionException, InterruptedException, TimeoutException { Map<Pair<JiraIssueEvent, NotificationInfo>, Pair<JiraIssueEvent, NotificationInfo>> notifications = Maps .newHashMap(); for (Pair<JiraIssueEvent, NotificationInfo> ni : Iterables.concat(Futures.allAsList(futures) .get(1, TimeUnit.MINUTES))) { Pair<JiraIssueEvent, NotificationInfo> existing = notifications.get(ni); if (existing != null && ni.right().isNotifyingClients()) { existing.right().setNotifyingClients(true); } if (existing == null) { notifications.put(ni, ni); } } return notifications.values(); }
private Stream<Pair<ResourceDescriptor, Plugin>> getFeatureResources(final Plugin plugin) { return plugin.getResourceDescriptors() .stream().filter(FEATURE_TYPE_FILTER::apply) .map(resource -> new Pair<>(resource, plugin)); } }
public Builder ensureDisabled(Plugin plugin) { this.plugins.add(pair(plugin, false)); return this; }
public String getHipChatUserName() { final UserKey userKey = userManager.getRemoteUserKey(); Option<Pair<HipChatUserId, String>> hipChatUser = hipChatUserFinder.findHipChatUserAndName(userKey); if (hipChatUser.isEmpty()) { return null; } return hipChatUser.get().right(); }
@Override public Iterable<Pair<JiraIssueEvent,NotificationInfo>> call() throws Exception { if (!eventMatcherTypesHandled.contains(event.getEventMatcher())) { return Collections.emptyList(); } final Issue issue = event.getIssueEvent().getIssue(); final Option<DedicatedRoom> dedicatedRoom = dedicatedRoomDAO.getDedicatedRoom(issue.getId()); if (dedicatedRoom.isEmpty()) { return Collections.emptyList(); } return Collections.singletonList(new Pair<JiraIssueEvent, NotificationInfo>(event,new NotificationInfo(Long.toString(dedicatedRoom.get().getRoomId())))); }
public boolean allow(HttpServletRequest request) { if (!httpMethod.equals(request.getMethod())) { return false; } final String pathInfo = ServletUtils.extractPathInfo(request); if (path.equals(pathInfo)) { Optional<Pair<String, String>> maybeNamespaceAndName = getMethod(request); if (!maybeNamespaceAndName.isPresent()) { return false; } Pair<String, String> namespaceAndName = maybeNamespaceAndName.get(); for (SoapScope scope : soapActions) { if (scope.match(namespaceAndName.left(), namespaceAndName.right())) { return true; } } } return false; }
public Translations download(ConnectAddonBean addonBean) throws TranslationsDownloadException { List<DownloadResult<ResponsePromise>> downloadsInProgress = Stream.of(Language.values()) .map(lang -> pair(lang, lang.getPath(addonBean.getTranslations().getPaths()))) .filter(langAndPath -> langAndPath.right().isPresent()) .map(langAndPath -> scheduleDownload(langAndPath.left(), addonBean.getBaseUrl(), langAndPath.right().get())) .collect(toList()); final Map<Language, I18nKeysMapping> translations = downloadsInProgress.stream() .map(this::download) .collect(Collectors.toMap(DownloadResult::getLanguage, DownloadResult::getResult)); return Translations.from(translations); }
public String getHipChatUserName() { final ApplicationUser user = jiraAuthenticationContext.getUser(); if(user == null) { return null; } Option<Pair<HipChatUserId, String>> hipChatUser = hipChatUserFinder.findHipChatUserAndName(new UserKey(user.getKey())); if(hipChatUser.isEmpty()) { return null; } return hipChatUser.get().right(); } }
public boolean allow(HttpServletRequest request) { if (!httpMethod.equals(request.getMethod())) { return false; } final String pathInfo = ServletUtils.extractPathInfo(request); if (path.equals(pathInfo)) { Optional<Pair<String, String>> maybeNamespaceAndName = getMethod(request); if (!maybeNamespaceAndName.isPresent()) { return false; } Pair<String, String> namespaceAndName = maybeNamespaceAndName.get(); for (SoapScope scope : soapActions) { if (scope.match(namespaceAndName.left(), namespaceAndName.right())) { return true; } } } return false; }
/** * This method gathers errors from all failed installations and combines them into one message. */ private String describeAllFailures(List<MarketplaceInstallationResult> installations) { return installations.stream() .filter(MarketplaceInstallationResult::failed) .map(failure -> failure .getException().map(ex -> ex.getI18nKey() != null ? pair(ex.getI18nKey(), ex.getI18nArgs()) : null) .orElse(pair(failure.getError().get().getI18nKey(), new String[]{failure.getAddonKey()}))) .map(pair -> i18nResolver.getText(pair.left(), pair.right())) .collect(Collectors.joining(" ")); } }
public String getHipChatUserName() { final ApplicationUser user = getLoggedInApplicationUser(); Option<Pair<HipChatUserId, String>> hipChatUser = hipChatUserFinder.findHipChatUserAndName(new UserKey(user.getKey())); if (hipChatUser.isEmpty()) { return null; } return hipChatUser.get().right(); }
public <T extends Enum<T>> Either<ErrorCollection, OrderByRequest<T>> parse(String orderByValue, Class<T> fields) { Pair<Order, String> orderAndField = extractOrderAndField(orderByValue); Order order = orderAndField.left(); String value = orderAndField.right(); for (T field : fields.getEnumConstants()) { if (field.toString().equalsIgnoreCase(value)) { return Either.right(new OrderByRequest<T>(field, order)); } } return Either.<ErrorCollection, OrderByRequest<T>>left(new SimpleErrorCollection(i18n.getText("util.errors.order.query.parse", value, Arrays.toString(fields.getEnumConstants())), ErrorCollection.Reason.VALIDATION_FAILED)); }
Plugin plugin = pair.left(); boolean shouldEnable = pair.right(); boolean mutated = false; if (shouldEnable) transformedPlugins.add(pair(plugin, !shouldEnable)); String moduleKey = moduleKeyStatusEntry.left(); final Boolean shouldEnable = moduleKeyStatusEntry.right(); final boolean currentlyEnabled = restPluginComponent.isPluginModuleEnabled(plugin, moduleKey); if (shouldEnable && !currentlyEnabled) transformed.add(pair(moduleKey, false)); transformed.add(pair(moduleKey, true));