List of usage examples for java.util Set forEach
default void forEach(Consumer<? super T> action)
From source file:com.hortonworks.streamline.registries.dashboard.service.DashboardCatalogService.java
public void addWidgetDatasourceMapping(Widget widget, Set<Long> datasourceIds) { datasourceIds.forEach(datasourceId -> { ensureDatasourceExists(widget.getDashboardId(), datasourceId); dao.<WidgetDatasourceMapping>add(new WidgetDatasourceMapping(widget.getId(), datasourceId)); });/*www . java 2 s. co m*/ }
From source file:com.devicehive.auth.rest.providers.BasicAuthenticationProvider.java
@SuppressWarnings("unchecked") @Override//from w ww .j ava 2 s. c om public Authentication authenticate(Authentication authentication) throws AuthenticationException { String key = (String) authentication.getPrincipal(); String pass = (String) authentication.getCredentials(); logger.debug("Basic authentication requested for username {}", key); UserVO user = null; try { user = userService.authenticate(key, pass); } catch (HiveException e) { logger.error("User auth failed", e); } if (user != null && user.getStatus() == UserStatus.ACTIVE) { String role = user.isAdmin() ? HiveRoles.ADMIN : HiveRoles.CLIENT; logger.info("User {} authenticated with role {}", key, role); HivePrincipal principal = new HivePrincipal(user); if (user.isAdmin()) { Set<String> allActions = AvailableActions.getAllActions(); Set<HiveAction> allowedActions = new HashSet<>(); allActions.forEach(action -> allowedActions.add(HiveAction.fromString(action))); principal.setActions(allowedActions); } else { String[] actions = AvailableActions.getClientActions(); Set<HiveAction> allowedActions = new HashSet<>(); for (String action : actions) allowedActions.add(HiveAction.fromString(action)); principal.setActions(allowedActions); } return new HiveAuthentication(principal, AuthorityUtils.createAuthorityList(role)); } logger.warn("Basic auth for {} failed", key); throw new BadCredentialsException("Invalid credentials"); }
From source file:ddf.catalog.validation.impl.validator.RequiredAttributesMetacardValidator.java
private Optional<MetacardValidationReport> getReport(final Set<ValidationViolation> violations) { final MetacardValidationReportImpl report = new MetacardValidationReportImpl(); violations.forEach(report::addMetacardViolation); return Optional.of(report); }
From source file:edu.kit.dama.ui.admin.wizard.BaseMetadataExtractionAndIndexingCreation.java
public void buildMainLayout() { extractorProperties = new HashMap<>(); Label information = new Label( "In order to query for digital objects by metadata, relevant metadata must be extracted, processed and indexed at ingest time. " + "Typically, this process highly depends on the community ingesting data as metadata might be located next to the data, within the data or externally. " + "In order to be able to query at least for base metadata available for all digital objects, basic METS metadata extraction marked below should remain enabled. " + "It is highly recommended to keep the default settings and to modify them later according to special needs.<br/>" + "If you already have a custom metadata extractor in place, feel free to disable the checkbox.", ContentMode.HTML);/*from w ww .j ava 2 s . c o m*/ createMetsExtractor = new CheckBox("Select to Enable basic METS metadata extraction for each ingest."); createMetsExtractor.setValue(true); createMetsExtractor.addValueChangeListener((event) -> { Set<Entry<String, TextField>> entries = extractorProperties.entrySet(); entries.forEach((entry) -> { entry.getValue().setEnabled(createMetsExtractor.getValue()); }); }); getMainLayout().addComponent(information); getMainLayout().addComponent(createMetsExtractor); getMainLayout().setComponentAlignment(information, Alignment.TOP_LEFT); getMainLayout().setComponentAlignment(createMetsExtractor, Alignment.TOP_LEFT); BasicMetsExtractor ext = new BasicMetsExtractor(""); String[] internalKeys = ext.getInternalPropertyKeys(); for (String internalKey : internalKeys) { TextField field = UIUtils7.factoryTextField(internalKey, null); field.setRequired(true); field.setDescription(ext.getInternalPropertyDescription(internalKey)); if (MetsMetadataExtractor.COMMUNITY_DMD_SECTION_ID.equals(internalKey)) { field.setValue("cmd0"); } else if (MetsMetadataExtractor.COMMUNITY_MD_TYPE_ID.equals(internalKey)) { field.setValue("DC"); } else if (MetsMetadataExtractor.COMMUNITY_METADATA_SCHEMA_ID.equals(internalKey)) { field.setValue("oai_dc"); } else { field.setValue("TRUE"); } extractorProperties.put(internalKey, field); getMainLayout().addComponent(field); getMainLayout().setComponentAlignment(field, Alignment.TOP_LEFT); } }
From source file:se.uu.it.cs.recsys.constraint.builder.ScheduleDomainBuilder.java
private Map<CourseSchedule, Set<Integer>> getTaughtYearAndStartPeriodToIdMapping(Set<CourseSchedule> schedule) { Map<CourseSchedule, Set<Integer>> taughtYearAndStartPeriodToIdMapping = new HashMap<>(); schedule.forEach(sch -> { Set<Course> courseSet = this.courseRepository.findByTaughtYearAndStartPeriod(sch.getTaughtYear(), sch.getStartPeriod());/*from w w w. j a va2 s . c o m*/ Set<Integer> idSet = courseSet.stream().map(c -> c.getAutoGenId()).collect(Collectors.toSet()); taughtYearAndStartPeriodToIdMapping.put(sch, idSet); }); return taughtYearAndStartPeriodToIdMapping; }
From source file:co.rsk.peg.BridgeState.java
private List<String> toStringList(Set<Sha3Hash> keys) { List<String> hashes = new ArrayList<>(); if (keys != null) { keys.forEach(s -> hashes.add(s.toString())); }// www. j av a 2s. co m return hashes; }
From source file:com.openthinks.webscheduler.model.task.ITaskRef.java
public default String getContent() { Set<String> properties = this.stringPropertyNames(); StringBuffer sb = new StringBuffer(); properties.forEach((propertyName) -> { String propertyValue = this.getProperty(propertyName); sb.append(propertyName + "=" + propertyValue); sb.append("\r\n"); });/*from w w w.j a v a 2s. com*/ return sb.toString(); }
From source file:org.sakuli.services.forwarder.icinga2.Icinga2RestCientTest.java
@Test public void testInitIcingaClient() throws Exception { // testling.initIcingaClient() will be called on context startup Set<Object> registeredObjects = ((Client) ReflectionTestUtils.getField(testling, "icingaClient")) .getConfiguration().getInstances(); assertEquals(registeredObjects.size(), 2); registeredObjects.forEach(e -> { if (e instanceof HttpAuthenticationFeature) { assertNotNull(ReflectionTestUtils.getField(e, "basicCredentials")); return; }// ww w .j a v a 2s.c om if (e instanceof Icinga2RestCient.ErrorResponseFilter) { return; } throw new RuntimeException("not epected class of registered Object of 'icingaClient'"); }); }
From source file:ru.trett.cis.rest.CommonAPI.java
private Class getModelClass(String className) throws ClassMappingException { Reflections reflections = new Reflections("ru.trett.cis.models"); Set<Class<? extends BaseEntity>> classes = reflections.getSubTypesOf(BaseEntity.class); Set<String> classNames = new LinkedHashSet<>(); classes.forEach(x -> classNames.add(x.getSimpleName())); if (!classNames.contains(className)) throw new ClassMappingException("Class is not Model."); try {/* w w w .j a v a 2 s. co m*/ return Class.forName("ru.trett.cis.models." + className); } catch (ClassNotFoundException e) { LOGGER.error(e.getMessage()); return null; } }
From source file:com.haulmont.cuba.security.jmx.ServerTokenStore.java
@Override public String removeTokensByUserLogin(String userLogin) { if (StringUtils.isEmpty(userLogin)) { return "Please specify the user's login"; }/*from w w w .j a v a2 s . c o m*/ try { Set<String> tokens = serverTokenStore.getAccessTokenValuesByUserLogin(userLogin); if (tokens.isEmpty()) { return String.format("No tokens found for user '%s'", userLogin); } tokens.forEach(serverTokenStore::removeAccessToken); return String.format("%s tokens were removed for user '%s' successfully.", tokens.size(), userLogin); } catch (Throwable t) { return ExceptionUtils.getStackTrace(t); } }