public AttachmentsBulkOperationResult(final Pair<List<AttachmentError>, List<T>> errorAndResult) { this(errorAndResult.left(), errorAndResult.right()); }
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; }
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 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 <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)); }
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); }
/** * 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(" ")); } }
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(); }
private Properties getPropertiesFromPlugin(final Pair<ResourceDescriptor, Plugin> pluginFeatureDesc) { return loadRequiredProperties( path -> resourceLoader.getResourceAsStream(pluginFeatureDesc.right(), path), pluginFeatureDesc.left().getLocation()); }
LOG.info("Enabling plugin {}", pair.left().getKey()); restPluginComponent.enablePlugin(pair.left()); LOG.info("Disabling plugin {}", pair.left().getKey()); restPluginComponent.disablePlugin(pair.left()); final String moduleKey = moduleKeyStatusEntry.left(); final boolean shouldEnable = moduleKeyStatusEntry.right();
@Override public Void call() throws Exception { final Collection<EventMatcherType> eventMatcherTypes = issueEventToEventMatcherTypeConverter.match(event); List<ListenableFuture<Iterable<Pair<JiraIssueEvent, NotificationInfo>>>> futures = new ArrayList<>(); // Multiple events can be fired for a given {@link IssueEvent}, multiple notifications // can be sent as a result so they are filtered below for (EventMatcherType eventMatcherType : eventMatcherTypes) { JiraIssueEvent jiraIssueEvent = new DefaultJiraIssueEvent.Builder(issueEventHelperBridge) .setEventMatcher(eventMatcherType) .setIssueEvent(event) .build(); futures.add(taskExecutorService.submitTask(taskBuilder.newDedicatedRoomProcessorTask(jiraIssueEvent))); futures.add(taskExecutorService.submitTask(taskBuilder.newEventProcessorTask(jiraIssueEvent))); } try { for (Pair<JiraIssueEvent, NotificationInfo> ni : filterDuplicateMessages(futures)) { taskExecutorService.submitTask(taskBuilder.newSendNotificationTask(ni.left(), Collections.singleton(ni.right()))); } } catch (Exception e) { LOG.error("Error processing event", e); } return null; } });
@Override public StreamItem apply(final PageElement input) { final Pair<Maybe<String>, String> author = extractAuthor(input); return new StreamItem(extractTitle(input), author.left(), author.right(), extractIcons(input), extractCountItems(input)); }
@Override public Void get(final Pair<Attachment, AttachmentKey> input) { final Promise<Attachment> op = attachmentStore.putAttachment(input.left(), source.getAttachmentFile(input.right())) .fail(new Effect<Throwable>() { @Override public void apply(final Throwable throwable) { abortCause.set(Option.some(throwable)); } }); onCompleteAttachment.foreach(new com.atlassian.fugue.Effect<Effect<Attachment>>() { @Override public void apply(final Effect<Attachment> attachmentEffect) { op.done(attachmentEffect); } }); return null; } }, ExceptionPolicy.Policies.THROW);
for (final Pair<Long, Either<AttachmentError, Attachment>> result : results) map.put(result.left(), result.right());
Pair<Pair<DefaultArtifactVersion,PomVersionElement>,ProjectRewriter> versionInfo = getVersionAndRewriter(project); DefaultArtifactVersion versionInPom = versionInfo.left().left(); PomVersionElement pomElement = versionInfo.left().right(); String pomElementType = pomElement.getType(); String versionProp = pomElement.getVersionProperty();
final Content content = contentForId.left(); final String contentType = contentForId.right();
final ArtifactResult artifactResult = pair.left().resolveArtifact(pair.right(), request); if (artifactResult.isMissing())
final ArtifactResult artifactResult = pair.left().resolveArtifact(pair.right(), request); if (artifactResult.isMissing())