public Option getParent() { return this.options.first(); }
@Override public KeyPair getKeyPair() { return cache.get().first(); }
@Override public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException { Option<Pair<String, Object>> pair = invoke(targetObject, method); for (Pair<String, Object> tuple : pair) { Object value = tuple.second(); if (value instanceof Map) { //noinspection unchecked data.putAll((Map<String, Object>) value); } else { data.put(tuple.first(), value); } } } },
/** * Converts the usernames into User objects using the given function. * * @param watchers a Pair of watcher count and watcher usernames * @param function a Function used for conversion * @return a Pair of watcher count and User object */ protected <T extends ApplicationUser> Pair<Integer, List<T>> convertUsers(final Pair<Integer, List<String>> watchers, final Function<String, T> function) { return Pair.<Integer, List<T>>of( watchers.first(), copyOf(Iterables.transform(watchers.second(), function)) ); }
public int[] getVersionNumbers() { return parseVersion(getVersion()).first(); }
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { Pair<ServletRequest, ServletResponse> debugWrapped = wrap(servletRequest, servletResponse); super.doFilter(debugWrapped.first(), debugWrapped.second(), filterChain); }
@Override public BulkWatchResult removeWatcherFromAll(final Collection<Issue> issues, final ApplicationUser remoteUser, final ApplicationUser watcher, final Context taskContext) throws WatchingDisabledException { Collection<Issue> successfulIssues = new ArrayList<Issue> (); Collection<Pair<Issue,String>> failedIssues = new ArrayList<Pair<Issue,String>> (); for (Issue issue : issues) { Pair<Boolean, String> canUnwatchIssue = canUnwatchIssue(issue, remoteUser, watcher); if (canUnwatchIssue.first().booleanValue()) { successfulIssues.add (issue); } else { failedIssues.add (Pair.nicePairOf(issue, canUnwatchIssue.second())); } } if (!successfulIssues.isEmpty()) { watcherManager.stopWatching(watcher, successfulIssues, taskContext); } return new BulkWatchResult(failedIssues); }
public void registerWith(final ComponentContainer.Scope defaultScope, final ComponentContainer container) { Assertions.stateTrue("must implement some interfaces", !implementing.isEmpty()); //at first register under concrete implementation key with default adapter factory if(parameters.isEmpty()) container.implementation(ComponentContainer.Scope.INTERNAL, concrete, concrete); else container.implementation(ComponentContainer.Scope.INTERNAL, concrete, concrete, parameters.toArray(new Parameter[parameters.size()])); final ComponentAdapter adapter = container.getComponentAdapter(concrete); for (Pair<Class<? super T>, ComponentContainer.Scope> pair : implementing) { ComponentAdapter delegatingAdapter = new KeyedDelegateComponentAdapter<T>(pair.first(), adapter); container.component(pair.second() != null ? pair.second() : defaultScope, delegatingAdapter); } } }
@Override public void apply(final Pair<String, ErrorCollection.Reason> error) { errors.addError(nameFieldName, authenticationContext.getI18nHelper().getText(error.first()), error.second()); } });
@Override MigrationState migrate(MigrationState state, final boolean licenseSuppliedByUser) { final Set<Group> sdAgentGroups = globalPermissionDao.groupsWithSdAgentPermission(); final List<String> notMigratedGroups = new ArrayList<>(); for (Group sdAgentGroup : sdAgentGroups) { Pair<MigrationState, Boolean> result = checkGroupAndMigrate(sdAgentGroup, state); if (!result.second()) { notMigratedGroups.add(sdAgentGroup.getName()); } state = result.first(); } return state.withAfterSaveTask(() -> saveNotMigratedGroups(notMigratedGroups)); }
public boolean getSectionContainsAtleastOneLink(String parentSection, String section) { LinkedList<Pair<String,String>> parentAndSectionList = new LinkedList<>(); parentAndSectionList.add(Pair.nicePairOf(parentSection,section)); while (!parentAndSectionList.isEmpty()) { final Pair<String,String> currentPair = parentAndSectionList.pop(); final List<SimpleLinkSection> sectionList = getChildSectionsForSection(currentPair.second()); if (sectionList != null) { for (final SimpleLinkSection aSectionList : sectionList) { parentAndSectionList.addLast(Pair.of(currentPair.second(), aSectionList.getId())); } } final List<SimpleLink> links = getLinksForSection(currentPair.first(),currentPair.second()); if (links != null && !links.isEmpty()) { return true; } } return false; }
@Override public void apply(final Pair<String, ErrorCollection.Reason> error) { errors.addError(nameFieldName, authenticationContext.getI18nHelper().getText(error.first()), error.second()); } });
@Override public ServiceOutcome<List<ApplicationUser>> addWatcher(final Issue issue, final ApplicationUser remoteUser, final ApplicationUser watcher) throws WatchingDisabledException { Pair<Boolean, String> canWatchIssue = canWatchIssue(issue, remoteUser, watcher); if (canWatchIssue.first().booleanValue()) { watcherManager.startWatching(watcher, issue); return ServiceOutcomeImpl.ok(getCurrentWatchersFor(issue)); } return ServiceOutcomeImpl.error(canWatchIssue.second()); }
@Override public ServiceOutcome<List<ApplicationUser>> removeWatcher(final Issue issue, final ApplicationUser remoteUser, final ApplicationUser watcher) throws WatchingDisabledException { Pair<Boolean, String> canUnwatchIssue = canUnwatchIssue(issue, remoteUser, watcher); if (canUnwatchIssue.first().booleanValue()) { watcherManager.stopWatching(watcher, issue); return ServiceOutcomeImpl.ok(getCurrentWatchersFor(issue)); } return ServiceOutcomeImpl.error(canUnwatchIssue.second()); }
private Option<ErrorCollection> validateName(final String name, final Option<IssueType> issueTypeToUpdate) { final Option<Pair<String, ErrorCollection.Reason>> nameValidation = constantsManager.validateName(name, issueTypeToUpdate); if (nameValidation.isDefined()) { return errorCollection("name", nameValidation.get().first(), nameValidation.get().second()); } return none(); }
public ApplicationPropertiesServiceImpl(ApplicationPropertiesStore applicationPropertiesStore, EventPublisher eventPublisher, PermissionManager permissionManager, JiraAuthenticationContext authenticationContext, FeatureManager featureManager) { this.applicationPropertiesStore = applicationPropertiesStore; this.eventPublisher = eventPublisher; this.permissionManager = permissionManager; this.authenticationContext = authenticationContext; this.featureManager = featureManager; this.featurePredicate = input -> { if (input.getMetadata().getRequiredFeatureKey() == null) { return true; } if (input.getMetadata().getRequiredFeatureKey().second()) { return ApplicationPropertiesServiceImpl.this.featureManager.isEnabled(input.getMetadata().getRequiredFeatureKey().first()); } else { return !ApplicationPropertiesServiceImpl.this.featureManager.isEnabled(input.getMetadata().getRequiredFeatureKey().first()); } }; }
private WatchersBean buildBean(final Issue issue, final ApplicationUser callingUser) { try { Pair<Integer, List<ApplicationUser>> watcherCountList = watcherService.getWatchers(issue, callingUser).get(); List<UserJsonBean> watcherUserBeans = transform(watcherCountList.second(), toJson(callingUser)); log.trace("Visible watchers on issue '{}': {}", issue.getKey(), watcherUserBeans); return WatchersBean.Builder.create() .self(selfLink(issue)) .isWatching(watcherCountList.second().contains(callingUser)) .watchers(watcherUserBeans) .watchCount(watcherCountList.first()) .build(); } catch (WatchingDisabledException e) { return null; // don't report any watcher info } }
Result getResult() { if (previousFieldValue == null && nextFieldValue == null) { return null; } Pair<String, Long> previousValueAndOffset = valueAndOffSet(previousFieldValue, config.getPreviousField()); Pair<String, Long> nextValueAndOffset = valueAndOffSet(nextFieldValue, config.getNextField()); String previousValue = previousValueAndOffset.first(); String nextValue = nextValueAndOffset.first(); if (previousValue == null && nextValue == null) { return null; } Long previousPeriodOffSet = previousValueAndOffset.second(); Long nextPeriodOffSet = nextValueAndOffset.second(); if (previousValue != null && nextValue != null) { return new Result(getBothFieldsMessage(previousValue, nextValue, previousPeriodOffSet, nextPeriodOffSet), true, true); } if (previousValue != null) { return new Result(getPreviousFieldMessage(previousValue), true, false); } return new Result(getNextFieldMessage(nextValue, nextPeriodOffSet), false, true); }
public ReviewList getReviewsForProject(final Project project, final int lastNDays) { final String timerKey = "ReviewManager.getReviewsForProject() project=" + project.getKey() + " lastNDays=" + lastNDays; List<Review> reviews = Lists.newArrayList(); List<SourceErrorReport> errors = Lists.newArrayList(); try { UtilTimerStack.push(timerKey); if (fisheyeConfig.isTextCruSearch() || fishEyeManager.existsCrucibleStandaloneInstances()) { reviews.addAll(getReviewsFromCrucibleInstances(project.getKey(), project.getKey() + "-", false, errors)); } if (fisheyeConfig.isChangesetCruSearch()) { Pair<Set<FishEyeRepository>, Map<FishEyeInstance, Set<FishEyeRepository>>> repositoriesToSearch = splitOutLegacyRepositories(project.getKey(), fishEyeManager.getRepositoriesForProject(project.getKey())); Set<FishEyeRepository> legacyReposToSearch = repositoriesToSearch.first(); Map<FishEyeInstance, Set<FishEyeRepository>> instancesToSearch = repositoriesToSearch.second(); reviews.addAll(getReviewsFromFishEyeInstances(instancesToSearch, project.getKey(), errors)); reviews.addAll(getReviewsFromRepositories(legacyReposToSearch, project.getKey(), lastNDays, errors)); } reviews = ReviewFilter.unique(reviews); reviews = ReviewFilter.orderByKeyAndTruncate(reviews, MAX_REVIEWS_PROJECT); } finally { UtilTimerStack.pop(timerKey); } return new ReviewList(reviews, errors); }
@Override public Unit get(final AttachmentGetData attachmentGetData) { final Pair<InputStream, Effect<Object>> streamWithCloseHandler = resendingAttachmentStreamCreator .getInputStreamWithCloseHandler(attachmentGetData); final Effect<Object> cleanup = streamWithCloseHandler.second(); try { final StoreAttachmentBean storeAttachmentBean = new StoreAttachmentBean.Builder(streamWithCloseHandler.first()) .withSize(attachmentGetData.getSize()) .withKey(attachmentKey) .build(); store.putAttachment(storeAttachmentBean) .then(getFutureCallbackFromEffect(cleanup)); return Unit.VALUE; } catch (final RuntimeException e) { cleanup.apply(Unit.VALUE); throw e; } }