List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:org.hsweb.web.oauth2.service.OAuth2ServiceImpl.java
@Override public void addAccessToken(OAuth2Access auth2Access) { if (auth2Access.getId() == null) { auth2Access.setId(OAuth2Access.createUID()); }//from w w w. j a v a2 s. co m // TODO: 16-8-17 ?n? //token List<OAuth2Access> accesses = oAuth2AccessMapper .select(QueryParam.build().where("userId", auth2Access.getUserId())); if (accesses.size() > 0) { accesses.forEach(this::removeAccessFromCache); oAuth2AccessMapper.delete(DeleteParam.build().where("userId", auth2Access.getUserId())); } oAuth2AccessMapper.insert(InsertParam.build(auth2Access)); }
From source file:org.artifactory.ui.rest.service.admin.configuration.repositories.replication.ReplicationConfigService.java
public void updateLocalReplications(Set<LocalReplicationDescriptor> replications, String repoKey, MutableCentralConfigDescriptor configDescriptor) throws RepoConfigException { if (replications.size() == 0) { log.debug("No replication config received for repo {}, deleting existing ones", repoKey); List<LocalReplicationDescriptor> currentReplications = configDescriptor .getMultiLocalReplications(repoKey); cleanupLocalReplications(currentReplications); currentReplications.forEach(configDescriptor::removeLocalReplication); updateAddedAndRemovedReplications(replications, repoKey, configDescriptor); } else {// ww w.j a v a 2 s. co m LocalReplicationDescriptor replicationDescriptor = replications.iterator().next(); setRepoKey(replicationDescriptor, repoKey); updateAddedAndRemovedReplications(replications, repoKey, configDescriptor); } }
From source file:com.nike.cerberus.service.MetaDataService.java
protected Map<String, String> getIamRolePermissionMap(Map<String, String> roleIdToStringMap, String sdbId) { List<AwsIamRolePermissionRecord> iamPerms = awsIamRoleDao.getIamRolePermissions(sdbId); Map<String, String> iamRoleMap = new HashMap<>(iamPerms.size()); iamPerms.forEach(record -> { AwsIamRoleRecord iam = awsIamRoleDao.getIamRole(record.getAwsIamRoleId()).get(); String role = roleIdToStringMap.get(record.getRoleId()); iamRoleMap.put(String.format("arn:aws:iam::%s:role/%s", iam.getAwsAccountId(), iam.getAwsIamRoleName()), role);/*from w w w .j av a 2 s .c om*/ }); return iamRoleMap; }
From source file:org.lendingclub.mercator.bind.BindScanner.java
@SuppressWarnings("unchecked") private void scanRecordSetByZone() { Instant startTime = Instant.now(); List<String> zones = getBindClient().getZones(); Preconditions.checkNotNull(getProjector().getNeoRxClient(), "neorx client must be set"); zones.forEach(zone -> { logger.info("Scanning the zone {}", zone); Optional<List> recordsStream = getBindClient().getRecordsbyZone(zone); if (!recordsStream.get().isEmpty()) { logger.info("Found {} records in {} zone", recordsStream.get().size(), zone); recordsStream.get().forEach(record -> { String line = record.toString(); if (!line.startsWith(";")) { ResourceRecordSet<Map<String, Object>> dnsRecord = getRecord(line); ObjectNode recordNode = dnsRecord.toJson(); String cypher = "MATCH (z:BindHostedZone {zoneName:{zone}}) " + "MERGE (m:BindHostedZoneRecord {domainName:{dn}, type:{type}, zoneName:{zone}}) " + "ON CREATE SET m.ttl={ttl}, m.class={class}, m+={props}, m.createTs = timestamp(), m.updateTs=timestamp() " + "ON MATCH SET m+={props}, m.updateTs=timestamp() " + "MERGE (z)-[:CONTAINS]->(m);"; getProjector().getNeoRxClient().execCypher(cypher, "dn", recordNode.get("name").asText(), "type", recordNode.get("type").asText(), "ttl", recordNode.get("ttl").asText(), "class", recordNode.get("class").asText(), "props", recordNode.get("rData"), "zone", zone);/*from w w w . j av a2 s.c om*/ } }); } else { logger.error("Failed to obtain any records in {} zone", zone); } }); Instant endTime = Instant.now(); logger.info(" Took {} secs to project Bind records to Neo4j", Duration.between(startTime, endTime).getSeconds()); }
From source file:de.knoplab.todomaven.task.DefaultDataTask.java
@Override public void deleteSelected() { List<TodoTask> listToDelete = this.todoTaskList; this.todoTaskList = this.todoTaskList.stream().filter(e -> e.getState() == false) .collect(Collectors.toList()); listToDelete.removeAll(this.todoTaskList); listToDelete.forEach(e -> { todoTaskList.remove(e);//w w w.j ava 2 s. co m eventService.publish(new DataDeleteEvent(e)); }); }
From source file:com.qwazr.library.cassandra.CassandraCluster.java
public void expireUnusedSince(int minutes) { rwl.read(() -> {//from w w w .j a v a 2s .c om long time = System.currentTimeMillis() - (minutes * 60 * 1000); for (CassandraSession session : sessions.values()) if (session.getLastUse() < time) IOUtils.closeQuietly(session); }); rwl.write(() -> { List<String> keys = sessions.entrySet().stream().filter(entry -> entry.getValue().isClosed()) .map(Map.Entry::getKey).collect(Collectors.toList()); keys.forEach(key -> sessions.remove(key)); }); }
From source file:org.ng200.openolympus.services.TaskService.java
@Transactional public void rejudgeTask(final Task task) { final List<Verdict> verdictsToRemove = new ArrayList<Verdict>(); final List<Solution> solutions = this.solutionRepository.findByTask(task); solutions.stream().map(solution -> this.verdictRepository.findBySolution(solution)) .forEach(verdictsToRemove::addAll); this.verdictRepository.delete(verdictsToRemove); solutions.forEach(this.testingService::testSolutionOnAllTests); }
From source file:com.nike.cerberus.auth.connector.okta.OktaAuthConnector.java
@Override public Set<String> getGroups(AuthData authData) { Preconditions.checkNotNull(authData, "auth data cannot be null."); final List<UserGroup> userGroups = oktaApiClientHelper.getUserGroups(authData.getUserId()); final Set<String> groups = new HashSet<>(); if (userGroups == null) { return groups; }//from w w w.j ava 2s .co m userGroups.forEach(group -> groups.add(group.getProfile().getName())); return groups; }
From source file:com.epam.ta.reportportal.core.user.impl.EditUserHandler.java
private OperationCompletionRS editUser(String username, EditUserRQ editUserRQ, boolean isAdmin) { User user = userRepository.findOne(username); expect(user, notNull()).verify(USER_NOT_FOUND, username); boolean isRoleChanged = false; UpdatedRole source = null;// w ww. j av a 2 s . c om if ((null != editUserRQ.getRole()) && isAdmin) { Optional<UserRole> newRole = UserRole.findByName(editUserRQ.getRole()); expect(newRole.isPresent(), equalTo(true)).verify(BAD_REQUEST_ERROR, "Incorrect specified Account Role parameter."); user.setRole(newRole.get()); source = new UpdatedRole(username, newRole.get()); isRoleChanged = true; } if (null != editUserRQ.getDefaultProject()) { Project def = projectRepository.findOne(editUserRQ.getDefaultProject().toLowerCase()); expect(def, notNull()).verify(PROJECT_NOT_FOUND, editUserRQ.getDefaultProject()); user.setDefaultProject(editUserRQ.getDefaultProject()); } if (null != editUserRQ.getEmail()) { String updEmail = editUserRQ.getEmail().toLowerCase().trim(); expect(user.getType(), equalTo(INTERNAL)).verify(ACCESS_DENIED, "Unable to change email for external user"); expect(UserUtils.isEmailValid(updEmail), equalTo(true)).verify(BAD_REQUEST_ERROR, " wrong email: " + updEmail); User byEmail = userRepository.findByEmail(updEmail); if (null != byEmail) expect(username, equalTo(byEmail.getId())).verify(USER_ALREADY_EXISTS, updEmail); expect(UserUtils.isEmailValid(updEmail), equalTo(true)).verify(BAD_REQUEST_ERROR, updEmail); List<Project> userProjects = projectRepository.findUserProjects(username); userProjects .forEach(project -> ProjectUtils.updateProjectRecipients(user.getEmail(), updEmail, project)); user.setEmail(updEmail); try { projectRepository.save(userProjects); } catch (Exception exp) { throw new ReportPortalException("PROJECT update exception while USER editing.", exp); } } if (null != editUserRQ.getFullName()) { expect(user.getType(), equalTo(INTERNAL)).verify(ACCESS_DENIED, "Unable to change full name for external user"); user.setFullName(editUserRQ.getFullName()); } try { userRepository.save(user); if (isRoleChanged) { eventPublisher.publishEvent(new UpdateUserRoleEvent(source)); } } catch (Exception exp) { throw new ReportPortalException("Error while User editing.", exp); } return new OperationCompletionRS("User with login = '" + user.getLogin() + "' successfully updated"); }
From source file:cognition.pipeline.data.PatientDao.java
private void setPhoneNumbers(Individual individual) { SessionWrapper sessionWrapper = createSourceSession(); try {/*from w w w . j a va2 s . c om*/ Query getPhoneNumbers = sessionWrapper.getNamedQuery("getPhoneNumbers"); getPhoneNumbers.setParameter("patientId", individual.getId()); List list = getPhoneNumbers.list(); List<String> phoneNumbers = new ArrayList<>(); list.forEach(object -> { String phone = clobHelper.getStringFromExpectedClob(object); if (!StringUtils.isBlank(phone)) { phoneNumbers.add(phone); } }); individual.setPhoneNumbers(phoneNumbers); } finally { sessionWrapper.closeSession(); } }