List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:com.arangodb.impl.InternalGraphDriverImpl.java
@Override public GraphsEntity getGraphs(String databaseName) throws ArangoException { GraphsEntity graphsEntity = new GraphsEntity(); List<GraphEntity> graphEntities = new ArrayList<GraphEntity>(); List<String> graphList = this.getGraphList(databaseName); if (CollectionUtils.isNotEmpty(graphList)) { for (String graphName : graphList) { graphEntities.add(this.getGraph(databaseName, graphName)); }/*from w ww. j a v a 2 s . com*/ } graphsEntity.setGraphs(graphEntities); return graphsEntity; }
From source file:nc.noumea.mairie.appock.viewmodel.CreateDemandeArticleSpecifiqueViewModel.java
@Command public void creeArticleSpecifique(@BindingParam("win") Window window) { List<String> listeProprieteErreur = new ArrayList<>(); if (articleSpecifique.getQuantite() == null) { listeProprieteErreur.add("une quantit"); }// w w w .ja v a 2 s .c o m if (StringUtils.isBlank(articleSpecifique.getLibelle())) { listeProprieteErreur.add("un libell"); } if (articleSpecifique.getTypeColisage() == null) { listeProprieteErreur.add("un type de colisage"); } if (articleSpecifique.getTypeColisage() != null && articleSpecifique.getQuantiteColisage() == null && !articleSpecifique.getTypeColisage().getLibelle().equals("UNITE")) { listeProprieteErreur.add("une quantit de colisage"); } if (StringUtils.isBlank(articleSpecifique.getObservation())) { listeProprieteErreur.add("une motivation"); } if (CollectionUtils.isNotEmpty(listeProprieteErreur)) { Messagebox.show("Vous devez renseigner " + StringUtils.join(listeProprieteErreur, ", "), "Erreur", Messagebox.OK, Messagebox.ERROR); return; } window.detach(); Map<String, Object> args = new HashMap<>(); args.put("articleSpecifique", articleSpecifique); BindUtils.postGlobalCommand(null, null, "creeNouvelleSortieStock", args); }
From source file:com.braffdev.server.core.config.ConfigLogger.java
/** * Logs the file handler config./*from www . j av a 2 s . c o m*/ * * @param fileHandlers the list of file handlers to log. */ private void logHandlers(List<ClassConfig> fileHandlers) { if (CollectionUtils.isNotEmpty(fileHandlers)) { for (ClassConfig fileHandler : fileHandlers) { this.log("Class", fileHandler.getClazz()); } } else { this.log("No file handlers configured"); } }
From source file:at.gv.egiz.pdfas.lib.impl.signing.pdfbox.LTVEnabledPADESPDFBOXSigner.java
/** * Adds previously collected LTV verification data to the provided pdf document. * * @param pdDocument/*ww w . j a va 2 s.co m*/ * The pdf document (required; must not be {@code null}). * @param ltvVerificationInfo * The certificate verification info data (required; must not be {@code null}). * @throws CertificateEncodingException * In case of an error with certificate encoding. * @throws CRLException * In case there was an error encoding CRL data. * @throws IOException * In case there was an error adding a pdf stream to the document. */ private void addLTVInfo(PDDocument pdDocument, CertificateVerificationData ltvVerificationInfo) throws CertificateEncodingException, CRLException, IOException { // expect at least the certificate(s) if (CollectionUtils.isEmpty(Objects.requireNonNull(ltvVerificationInfo).getChainCerts())) { throw new IllegalStateException( "LTV data has not been retrieved yet. At least the signer certificate's chain is must be provided."); } log.debug("Adding LTV info to document."); addDSS(Objects.requireNonNull(pdDocument), ltvVerificationInfo); if (CollectionUtils.isNotEmpty(ltvVerificationInfo.getCRLs()) || CollectionUtils.isNotEmpty(ltvVerificationInfo.getEncodedOCSPResponses())) { log.info("LTV data (certchain and revocation info) added to document."); } else { log.info("LTV data (certchain but no revocation info) added to document."); } }
From source file:io.spotnext.maven.mojo.TransformTypesMojo.java
/** {@inheritDoc} */ @Override//from w w w.jav a2 s . co m public void execute() throws MojoExecutionException { if (skip) { getLog().info("Skipping type transformation!"); return; } trackExecution("start"); final ClassLoader classLoader = getClassloader(); final List<ClassFileTransformer> transformers = getClassFileTransformers(classLoader); List<File> classFiles = FileUtils.getFiles(project.getBuild().getOutputDirectory(), f -> f.getAbsolutePath().endsWith(".class")); getLog().debug("Found class files for processing: " + classFiles.stream().map(f -> f.getName()).collect(Collectors.joining(", "))); if (CollectionUtils.isNotEmpty(transformers)) { if (CollectionUtils.isNotEmpty(classFiles)) { getLog().info(String.format("Transforming %s classes", classFiles.size())); for (final File f : classFiles) { if (f.getName().endsWith(Constants.CLASS_EXTENSION)) { String relativeClassFilePath = StringUtils.remove(f.getPath(), project.getBuild().getOutputDirectory()); relativeClassFilePath = StringUtils.removeStart(relativeClassFilePath, "/"); final String className = relativeClassFilePath.substring(0, relativeClassFilePath.length() - Constants.CLASS_EXTENSION.length()); trackExecution("Loading class: " + f.getAbsolutePath()); byte[] byteCode; try { byteCode = Files.readAllBytes(f.toPath()); } catch (final IOException e) { String message = String.format("Can't read bytecode for class %s", className); buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e); throw new IllegalStateException(message, e); } trackExecution("Loaded class: " + f.getAbsolutePath()); for (final ClassFileTransformer t : transformers) { try { // log exceptions into separate folder, to be able to inspect them even if Eclipse swallows them ... if (t instanceof AbstractBaseClassTransformer) { ((AbstractBaseClassTransformer) t).setErrorLogger(this::logError); } // returns null if nothing has been transformed byteCode = t.transform(classLoader, className, null, null, byteCode); } catch (final Exception e) { String exception = "Exception during transformation of class: " + f.getAbsolutePath() + "\n" + e.getMessage(); trackExecution(exception); String message = String.format("Can't transform class %s, transformer %s: %s", className, t.getClass().getSimpleName(), ExceptionUtils.getStackTrace(e)); buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e); throw new MojoExecutionException(exception, e); } } if (byteCode != null && byteCode.length > 0) { try { Files.write(f.toPath(), byteCode, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); trackExecution("Saved transformed class: " + f.getAbsolutePath()); } catch (final IOException e) { String message = "Could not write modified class: " + relativeClassFilePath; buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e); throw new IllegalStateException(message); } finally { buildContext.refresh(f); getLog().info("Applied transformation to type: " + f.getAbsolutePath()); } } else { trackExecution("No changes made for class: " + f.getAbsolutePath()); getLog().debug("No transformation was applied to type: " + f.getAbsolutePath()); } } } } else { getLog().info("No class files found"); } trackExecution("All classes in build output folder transformed"); if (includeJars) { final String packaging = project.getPackaging(); final Artifact artifact = project.getArtifact(); if ("jar".equals(packaging) && artifact != null) { try { final File source = artifact.getFile(); if (source.isFile()) { final File destination = new File(source.getParent(), "instrument.jar"); final JarTransformer transformer = new JarTransformer(getLog(), classLoader, Arrays.asList(source), transformers); transformer.transform(destination); final File sourceRename = new File(source.getParent(), "notransform-" + source.getName()); if (source.renameTo(sourceRename)) { throw new MojoExecutionException(String.format("Could not move %s to %s", source.toString(), sourceRename.toString())); } if (destination.renameTo(sourceRename)) { throw new MojoExecutionException(String.format("Could not move %s to %s", destination.toString(), sourceRename.toString())); } buildContext.refresh(destination); } } catch (final Exception e) { buildContext.addMessage(artifact.getFile(), 0, 0, e.getMessage(), BuildContext.SEVERITY_ERROR, e); throw new MojoExecutionException(e.getMessage(), e); } } else { getLog().debug(String.format("Artifact %s not a jar file", artifact != null ? (artifact.getGroupId() + ":" + artifact.getArtifactId()) : "<null>")); } } } else { getLog().info("No class transformers configured"); } }
From source file:io.kodokojo.endpoint.ProjectSparkEndpoint.java
@Override public void configure() { post(BASE_API + "/projectconfig", JSON_CONTENT_TYPE, (request, response) -> { String body = request.body(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Try to create project {}", body); }/* www .j av a 2 s . co m*/ Gson gson = localGson.get(); ProjectCreationDto dto = gson.fromJson(body, ProjectCreationDto.class); if (dto == null) { halt(400); return ""; } User owner = userStore.getUserByIdentifier(dto.getOwnerIdentifier()); String entityId = owner.getEntityIdentifier(); if (StringUtils.isBlank(entityId)) { halt(400); return ""; } Set<StackConfiguration> stackConfigurations = createDefaultStackConfiguration(dto.getName()); if (CollectionUtils.isNotEmpty(dto.getStackConfigs())) { stackConfigurations = dto.getStackConfigs().stream().map(stack -> { Set<BrickConfiguration> brickConfigurations = stack.getBrickConfigs().stream().map(b -> { Brick brick = brickFactory.createBrick(b.getName()); return new BrickConfiguration(brick); }).collect(Collectors.toSet()); StackType stackType = StackType.valueOf(stack.getType()); BootstrapStackData bootstrapStackData = projectManager.bootstrapStack(dto.getName(), stack.getName(), stackType); return new StackConfiguration(stack.getName(), stackType, brickConfigurations, bootstrapStackData.getLoadBalancerHost(), bootstrapStackData.getSshPort()); }).collect(Collectors.toSet()); } List<User> users = new ArrayList<>(); users.add(owner); if (CollectionUtils.isNotEmpty(dto.getUserIdentifiers())) { for (String userId : dto.getUserIdentifiers()) { User user = userStore.getUserByIdentifier(userId); users.add(user); } } ProjectConfiguration projectConfiguration = new ProjectConfiguration(entityId, dto.getName(), Collections.singletonList(owner), stackConfigurations, users); String projectConfigIdentifier = projectStore.addProjectConfiguration(projectConfiguration); response.status(201); response.header("Location", "/projectconfig/" + projectConfigIdentifier); return projectConfigIdentifier; }); get(BASE_API + "/projectconfig/:id", JSON_CONTENT_TYPE, (request, response) -> { String identifier = request.params(":id"); ProjectConfiguration projectConfiguration = projectStore.getProjectConfigurationById(identifier); if (projectConfiguration == null) { halt(404); return ""; } SimpleCredential credential = extractCredential(request); if (userStore.userIsAdminOfProjectConfiguration(credential.getUsername(), projectConfiguration)) { return new ProjectConfigDto(projectConfiguration); } halt(403); return ""; }, jsonResponseTransformer); put(BASE_API + "/projectconfig/:id/user", JSON_CONTENT_TYPE, ((request, response) -> { SimpleCredential credential = extractCredential(request); String identifier = request.params(":id"); ProjectConfiguration projectConfiguration = projectStore.getProjectConfigurationById(identifier); if (projectConfiguration == null) { halt(404); return ""; } if (userStore.userIsAdminOfProjectConfiguration(credential.getUsername(), projectConfiguration)) { JsonParser parser = new JsonParser(); JsonArray root = (JsonArray) parser.parse(request.body()); List<User> users = IteratorUtils.toList(projectConfiguration.getUsers()); List<User> usersToAdd = new ArrayList<>(); for (JsonElement el : root) { String userToAddId = el.getAsJsonPrimitive().getAsString(); User userToAdd = userStore.getUserByIdentifier(userToAddId); if (userToAdd != null && !users.contains(userToAdd)) { users.add(userToAdd); usersToAdd.add(userToAdd); } } projectConfiguration.setUsers(users); projectStore.updateProjectConfiguration(projectConfiguration); projectManager.addUsersToProject(projectConfiguration, usersToAdd); } else { halt(403, "You have not right to add user to project configuration id " + identifier + "."); } return ""; }), jsonResponseTransformer); delete(BASE_API + "/projectconfig/:id/user", JSON_CONTENT_TYPE, ((request, response) -> { SimpleCredential credential = extractCredential(request); if (credential != null) { String identifier = request.params(":id"); ProjectConfiguration projectConfiguration = projectStore.getProjectConfigurationById(identifier); if (projectConfiguration == null) { halt(404); return ""; } if (userStore.userIsAdminOfProjectConfiguration(credential.getUsername(), projectConfiguration)) { JsonParser parser = new JsonParser(); JsonArray root = (JsonArray) parser.parse(request.body()); List<User> users = IteratorUtils.toList(projectConfiguration.getUsers()); for (JsonElement el : root) { String userToDeleteId = el.getAsJsonPrimitive().getAsString(); User userToDelete = userStore.getUserByIdentifier(userToDeleteId); if (userToDelete != null) { users.remove(userToDelete); } } projectConfiguration.setUsers(users); projectStore.updateProjectConfiguration(projectConfiguration); } else { halt(403, "You have not right to delete user to project configuration id " + identifier + "."); } } return ""; }), jsonResponseTransformer); // -- Project // Start project post(BASE_API + "/project/:id", JSON_CONTENT_TYPE, ((request, response) -> { SimpleCredential credential = extractCredential(request); if (credential != null) { User currentUser = userStore.getUserByUsername(credential.getUsername()); String projectConfigurationId = request.params(":id"); ProjectConfiguration projectConfiguration = projectStore .getProjectConfigurationById(projectConfigurationId); if (projectConfiguration == null) { halt(404, "Project configuration not found."); return ""; } if (userStore.userIsAdminOfProjectConfiguration(credential.getUsername(), projectConfiguration)) { String projectId = projectStore.getProjectIdByProjectConfigurationId(projectConfigurationId); if (StringUtils.isBlank(projectId)) { // projectManager.bootstrapStack(projectConfiguration.getName(), projectConfiguration.getDefaultStackConfiguration().getName(), projectConfiguration.getDefaultStackConfiguration().getType()); Project project = projectManager.start(projectConfiguration); response.status(201); String projectIdStarted = projectStore.addProject(project, projectConfigurationId); return projectIdStarted; } else { halt(409, "Project already exist."); } } else { halt(403, "You have not right to start project configuration id " + projectConfigurationId + "."); } } return ""; })); get(BASE_API + "/project/:id", JSON_CONTENT_TYPE, ((request, response) -> { SimpleCredential credential = extractCredential(request); if (credential != null) { User currentUser = userStore.getUserByUsername(credential.getUsername()); String projectId = request.params(":id"); Project project = projectStore.getProjectByIdentifier(projectId); if (project == null) { halt(404); return ""; } ProjectConfiguration projectConfiguration = projectStore .getProjectConfigurationById(project.getProjectConfigurationIdentifier()); if (userStore.userIsAdminOfProjectConfiguration(currentUser.getUsername(), projectConfiguration)) { return new ProjectDto(project); } else { halt(403, "You have not right to lookup project id " + projectId + "."); } } return ""; }), jsonResponseTransformer); }
From source file:com.mirth.connect.plugins.httpauth.digest.DigestAuthenticator.java
@Override public AuthenticationResult authenticate(RequestInfo request) { DigestHttpAuthProperties properties = getReplacedProperties(request); List<String> authHeaderList = request.getHeaders().get(HttpHeader.AUTHORIZATION.asString()); Map<String, String> directives = new CaseInsensitiveMap<String, String>(); String nonceString = null;//from w w w . j ava 2s .c o m String nonceCountString = null; String nonceOpaque = ""; /* * This status is used to determine whether or not to send back a challenge. It's also used * to determine whether the nonce used by the client is stale (expired past the max nonce * age, or the max nonce count). */ Status status = Status.INVALID; if (CollectionUtils.isNotEmpty(authHeaderList)) { String authHeader = authHeaderList.iterator().next(); /* * This splits up the Authorization header into name-value pairs and puts them into the * directives map. */ QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(authHeader, "=, ", true, false); String directive = null; String lastToken = null; while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); char c; if (token.length() == 1 && ((c = token.charAt(0)) == '=' || c == ',' || c == ' ')) { if (c == '=') { directive = lastToken; } else if (c == ',') { directive = null; } } else { if (directive != null) { directives.put(directive, token); directive = null; } lastToken = token; } } nonceString = directives.get(NONCE); nonceCountString = directives.get(NONCE_COUNT); // The authentication attempt isn't valid without a nonce if (StringUtils.isNotBlank(nonceString)) { Nonce nonce = nonceMap.get(nonceString); if (nonce != null) { // Nonce was found nonceOpaque = nonce.getOpaque(); if (nonce.isExpired()) { status = Status.STALE; } else if (StringUtils.isNotBlank(nonceCountString)) { /* * Nonce count is supplied, so update the nonce with it. If the count is * less than or equal to the current counter, it's an invalid request. If * the count is greater than the max nonce count, the nonce is stale. */ try { status = nonce.updateCount(Long.parseLong(nonceCountString, 16)); } catch (NumberFormatException e) { // If an exception occurs parsing the nonce count, leave the status as invalid } } else { /* * If no nonce count was supplied, just increment the internal counter by 1. * If the count is greater than the max nonce count, the nonce is stale. */ status = nonce.incrementCount(); } } else { // Nonce has expired or never existed status = Status.STALE; } } } // Remove expired nonces from the cache cleanupNonces(); /* * If the status is valid or stale, attempt to calculate the digest and compare it to the * response hash. If the response hash is incorrect, the status should always be set to * invalid. If the response hash is correct but the nonce is stale, the stale directive * should be set to true in the response challenge. */ if (status != Status.INVALID) { try { // Retrieve directives from the map String username = directives.get(USERNAME); String realm = directives.get(REALM); String uri = directives.get(URI); String response = directives.get(RESPONSE); String clientNonceString = directives.get(CLIENT_NONCE); String qop = directives.get(QOP); String algorithm = directives.get(ALGORITHM); String opaque = StringUtils.trimToEmpty(directives.get(OPAQUE)); // Do some initial validation on required directives if (StringUtils.isBlank(username)) { throw new Exception("Username missing."); } else if (StringUtils.isBlank(realm)) { throw new Exception("Realm missing."); } else if (uri == null) { throw new Exception("URI missing."); } else if (StringUtils.isBlank(response)) { throw new Exception("Response digest missing."); } String requestURI = request.getRequestURI(); // Allow empty URI to match "/" if (StringUtils.isEmpty(uri) && StringUtils.equals(requestURI, "/")) { requestURI = ""; } if (!StringUtils.equalsIgnoreCase(properties.getRealm(), realm)) { throw new Exception("Realm \"" + realm + "\" does not match expected realm \"" + properties.getRealm() + "\"."); } else if (!StringUtils.equalsIgnoreCase(requestURI, uri)) { throw new Exception( "URI \"" + uri + "\" does not match the request URI \"" + requestURI + "\"."); } else if (!StringUtils.equals(opaque, nonceOpaque)) { throw new Exception("Opaque value \"" + opaque + "\" does not match the expected value \"" + properties.getOpaque() + "\"."); } String password = properties.getCredentials().get(username); if (password == null) { throw new Exception("Credentials for username " + username + " not found."); } /* * Calculate H(A1). * * Algorithm MD5: A1 = username:realm:password * * Algorithm MD5-sess: A1 = H(username:realm:password):nonce:cnonce */ String ha1; if (algorithm == null || (StringUtils.equalsIgnoreCase(algorithm, Algorithm.MD5.toString()) && properties.getAlgorithms().contains(Algorithm.MD5))) { ha1 = digest(username, realm, password); } else if (StringUtils.equalsIgnoreCase(algorithm, Algorithm.MD5_SESS.toString()) && properties.getAlgorithms().contains(Algorithm.MD5_SESS)) { if (StringUtils.isBlank(clientNonceString)) { throw new Exception("Client nonce missing."); } String credentialsDigest = digest(username, realm, password); ha1 = digest(credentialsDigest, nonceString, clientNonceString); } else { throw new Exception("Algorithm \"" + algorithm + "\" not supported."); } /* * Calculate H(A2). * * QOP undefined/auth: A2 = method:uri * * QOP auth-int: A2 = method:uri:H(entityBody) */ String ha2; if (qop == null || (StringUtils.equalsIgnoreCase(qop, QOPMode.AUTH.toString()) && properties.getQopModes().contains(QOPMode.AUTH))) { ha2 = digest(request.getMethod(), uri); } else if (StringUtils.equalsIgnoreCase(qop, QOPMode.AUTH_INT.toString()) && properties.getQopModes().contains(QOPMode.AUTH_INT)) { String entityDigest = digest(request.getEntityProvider().getEntity()); ha2 = digest(request.getMethod(), uri, entityDigest); } else { throw new Exception("Quality of protection mode \"" + qop + "\" not supported."); } /* * Calculate response. * * QOP undefined: response = H(H(A1):nonce:H(A2)) * * QOP auth/auth-int: response = H(H(A1):nonce:nc:cnonce:qop:H(A2)) */ String rsp; if (qop == null) { rsp = digest(ha1, nonceString, ha2); } else { if (StringUtils.isBlank(nonceCountString)) { throw new Exception("Nonce count missing."); } else if (StringUtils.isBlank(clientNonceString)) { throw new Exception("Client nonce missing."); } rsp = digest(ha1, nonceString, nonceCountString, clientNonceString, qop, ha2); } if (logger.isTraceEnabled()) { logger.trace("H(A1): " + ha1); logger.trace("H(A2): " + ha2); logger.trace("response: " + rsp); } if (StringUtils.equalsIgnoreCase(rsp, response)) { /* * If the status is valid, return a successful result. Otherwise, the status * will remain stale and a challenge will be reissued. */ if (status == Status.VALID) { return AuthenticationResult.Success(username, realm); } } else { throw new Exception( "Response digest \"" + response + "\" does not match expected digest \"" + rsp + "\"."); } } catch (Exception e) { logger.debug("Error validating digest response.", e); status = Status.INVALID; } } /* * If we got to this point, an authentication challenge will be sent back, with a new nonce. * If the status is stale, the stale directive will also be set to true. */ Nonce nonce = new Nonce(properties.getOpaque()); nonceMap.put(nonce.getValue(), nonce); String contextPath = "/"; try { contextPath = new URI(request.getRequestURI()).getPath(); } catch (URISyntaxException e) { } Map<String, String> responseDirectives = new HashMap<String, String>(); responseDirectives.put(REALM, properties.getRealm()); responseDirectives.put(DOMAIN, contextPath); responseDirectives.put(NONCE, nonce.getValue()); responseDirectives.put(ALGORITHM, StringUtils.join(properties.getAlgorithms(), ',')); if (CollectionUtils.isNotEmpty(properties.getQopModes())) { responseDirectives.put(QOP, StringUtils.join(properties.getQopModes(), ',')); } if (StringUtils.isNotBlank(nonce.getOpaque())) { responseDirectives.put(OPAQUE, nonce.getOpaque()); } if (status == Status.STALE) { responseDirectives.put(STALE, "true"); } /* * Build up the WWW-Authenticate header to be sent back in the response. */ StringBuilder digestBuilder = new StringBuilder("Digest "); for (Iterator<Entry<String, String>> it = responseDirectives.entrySet().iterator(); it.hasNext();) { Entry<String, String> entry = it.next(); digestBuilder.append(entry.getKey()); digestBuilder.append("=\""); digestBuilder.append(entry.getValue()); digestBuilder.append('"'); if (it.hasNext()) { digestBuilder.append(", "); } } return AuthenticationResult.Challenged(digestBuilder.toString()); }
From source file:io.kodokojo.service.aws.Route53DnsManager.java
@Override public void createOrUpdateDnsEntries(Set<DnsEntry> dnsEntries) { if (dnsEntries == null) { throw new IllegalArgumentException("dnsEntries must be defined."); }//from w w w. ja v a 2 s .c om HostedZone hostedZone = getHostedZone(); List<Change> changes = new ArrayList<>(); if (hostedZone != null) { for (DnsEntry dnsEntry : dnsEntries) { if (!containEntry(dnsEntry, true)) { List<ResourceRecord> resourceRecords = new ArrayList<>(); ResourceRecord resourceRecord = new ResourceRecord(); String value = dnsEntry.getValue(); resourceRecord.setValue( (dnsEntry.getType().equals(DnsEntry.Type.CNAME) ? valideDnsName(value) : value)); resourceRecords.add(resourceRecord); ResourceRecordSet resourceRecordSet = new ResourceRecordSet(); resourceRecordSet.setName(valideDnsName(dnsEntry.getName())); resourceRecordSet.setType(RRType.valueOf(dnsEntry.getType().toString())); resourceRecordSet.setTTL(300L); resourceRecordSet.setResourceRecords(resourceRecords); Change change = new Change(); change.setAction(dnsEntryExist(dnsEntry) ? ChangeAction.UPSERT : ChangeAction.CREATE); change.setResourceRecordSet(resourceRecordSet); changes.add(change); } } if (CollectionUtils.isNotEmpty(changes)) { ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(); ChangeBatch changeBatch = new ChangeBatch(); changeBatch.setChanges(changes); request.setChangeBatch(changeBatch); request.setHostedZoneId(getHostedZoneID(hostedZone)); //ChangeResourceRecordSetsResult result = try { client.changeResourceRecordSets(request); } catch (PriorRequestNotCompleteException e) { LOGGER.error("Unable to create or update follwing entry in Route53 {}.", StringUtils.join(dnsEntries, ",")); } } } }
From source file:io.cloudslang.lang.compiler.validator.matcher.DescriptionPatternMatcher.java
public String getStepName(String input) { List<String> matches = getData(stepStartLinePattern, input, Regex.STEP_START_LINE_DATA_GROUP_NR); if (CollectionUtils.isNotEmpty(matches)) { return matches.get(0); } else {//from w w w . j a v a 2 s.c o m return null; } }
From source file:co.runrightfast.vertx.orientdb.impl.embedded.EmbeddedOrientDBService.java
private void registerHandlers(final OServerConfiguration serverConfig) { if (CollectionUtils.isNotEmpty(config.getHandlers())) { serverConfig.handlers = config.getHandlers().stream().map(Supplier::get).collect(Collectors.toList()); }// ww w . j a v a 2s . c om }