List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank
public static boolean isNotBlank(final CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
From source file:com.norconex.collector.core.pipeline.ChecksumStageUtil.java
private static boolean resolveChecksum(boolean isMeta, String newChecksum, BasePipelineContext ctx, Object subject) {/*from w w w. j a v a 2 s. c o m*/ BaseCrawlData crawlData = ctx.getCrawlData(); // Set new checksum on crawlData + metadata String type; if (isMeta) { crawlData.setMetaChecksum(newChecksum); type = "metadata"; } else { crawlData.setContentChecksum(newChecksum); type = "document"; } // Get old checksum from cache BaseCrawlData cachedCrawlData = ctx.getCachedCrawlData(); String oldChecksum = null; if (cachedCrawlData != null) { if (isMeta) { oldChecksum = cachedCrawlData.getMetaChecksum(); } else { oldChecksum = cachedCrawlData.getContentChecksum(); } } else { LOG.debug("ACCEPTED " + type + " checkum (new): Reference=" + crawlData.getReference()); return true; } // Compare checksums if (StringUtils.isNotBlank(newChecksum) && Objects.equals(newChecksum, oldChecksum)) { if (LOG.isDebugEnabled()) { LOG.debug("REJECTED " + type + " checkum (unmodified): Reference=" + crawlData.getReference()); } crawlData.setState(CrawlState.UNMODIFIED); ctx.fireCrawlerEvent(CrawlerEvent.REJECTED_UNMODIFIED, ctx.getCrawlData(), subject); return false; } crawlData.setState(CrawlState.MODIFIED); LOG.debug("ACCEPTED " + type + " checksum (modified): Reference=" + crawlData.getReference()); return true; }
From source file:de.micromata.genome.gwiki.controls.GWikiPluginsAdminActionBean.java
protected void initPlugins() { pluginRepo = wikiContext.getWikiWeb().getDaoContext().getPluginRepository(); for (GWikiPlugin plugin : pluginRepo.getPlugins().values()) { String category = StringUtils.isNotBlank(plugin.getDescriptor().getCategory()) ? plugin.getDescriptor().getCategory() : "General"; if (this.pluginMap.get(category) == null) { this.pluginMap.put(category, new ArrayList<GWikiPlugin>()); }/*w w w . j a va 2s.com*/ this.pluginMap.get(category).add(plugin); if (plugin.getDescriptor().getDescriptionPath() == null) { plugin.getDescriptor().setDescriptionPath( GWikiPluginDownloadActionBean.getDetailPage(wikiContext, plugin.getDescriptor())); } } }
From source file:au.csiro.casda.sodalint.SodaParameter.java
private SodaParameter(String ucd, String unit, String datatype, String arraysize, String xtype) { requiredAttribs = new HashMap<>(); if (StringUtils.isNotBlank(ucd)) { requiredAttribs.put("ucd", ucd); }//from ww w. j ava2s .c o m if (StringUtils.isNotBlank(unit)) { requiredAttribs.put("unit", unit); } if (StringUtils.isNotBlank(datatype)) { requiredAttribs.put("datatype", datatype); } if (StringUtils.isNotBlank(arraysize)) { requiredAttribs.put("arraysize", arraysize); } if (StringUtils.isNotBlank(xtype)) { requiredAttribs.put("xtype", xtype); } }
From source file:io.fabric8.maven.core.util.ResourceFileType.java
public static ResourceFileType fromFile(File file) { String ext = FilenameUtils.getExtension(file.getPath()); if (StringUtils.isNotBlank(ext)) { return fromExtension(ext); } else {/* w ww.j a v a2 s . c om*/ throw new IllegalArgumentException( String.format("Unsupported extension '%s' for file %s. Must be one of %s", ext, file, Arrays.asList(values()))); } }
From source file:com.netflix.genie.core.jpa.specifications.JpaClusterSpecs.java
/** * Generate a specification given the parameters. * * @param name The name of the cluster to find * @param statuses The statuses of the clusters to find * @param tags The tags of the clusters to find * @param minUpdateTime The minimum updated time of the clusters to find * @param maxUpdateTime The maximum updated time of the clusters to find * @return The specification/*w w w .jav a 2s . c o m*/ */ public static Specification<ClusterEntity> find(final String name, final Set<ClusterStatus> statuses, final Set<String> tags, final Date minUpdateTime, final Date maxUpdateTime) { return (final Root<ClusterEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ClusterEntity_.name), name)); } if (minUpdateTime != null) { predicates.add(cb.greaterThanOrEqualTo(root.get(ClusterEntity_.updated), minUpdateTime)); } if (maxUpdateTime != null) { predicates.add(cb.lessThan(root.get(ClusterEntity_.updated), maxUpdateTime)); } if (tags != null && !tags.isEmpty()) { predicates .add(cb.like(root.get(ClusterEntity_.tags), JpaSpecificationUtils.getTagLikeString(tags))); } if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = statuses.stream() .map(status -> cb.equal(root.get(ClusterEntity_.status), status)) .collect(Collectors.toList()); predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }
From source file:com.tdclighthouse.prototype.utils.EmailUtils.java
public static String[] parseToAddress(String to) { List<String> emails = new ArrayList<String>(); String[] split = to.split("(\\s*[;,]\\s*)+"); for (String email : split) { if (StringUtils.isNotBlank(email)) { emails.add(email);/*from w w w. j a v a2 s . c o m*/ } } return emails.toArray(new String[emails.size()]); }
From source file:mobile.controllers.MobileApp.java
@BodyParser.Of(value = BodyParser.Raw.class, maxLength = 5 * 1024 * 1024) public static Result uploadLog(String from, String comment) { if (request().body().isMaxSizeExceeded()) { return MobileResult.error("290001", "?5M").getResult(); }//from w w w. j a v a 2s . c o m if (StringUtils.isNotBlank(comment)) { try { comment = URLDecoder.decode(comment, "utf-8"); } catch (UnsupportedEncodingException e) { LOGGER.error("url?", e); } } File file = request().body().asRaw().asFile(); if (null == file || file.length() <= 0) { return MobileResult.error("100005", "?0").getResult(); } ClientLogService.uploadLog(from, file, comment); return MobileResult.success().getResult(); }
From source file:com.axibase.tsd.client.ClientConfigurationFactory.java
public static ClientConfigurationFactory createInstance() { String clientPropertiesFileName = DEFAULT_CLIENT_PROPERTIES_FILE_NAME; String sysPropertiesFileName = System.getProperty(AXIBASE_TSD_API_DOMAIN + ".client.properties"); if (StringUtils.isNotBlank(sysPropertiesFileName)) { clientPropertiesFileName = sysPropertiesFileName; }/*from w ww.j av a 2 s . c om*/ return createInstance(clientPropertiesFileName); }
From source file:com.thinkbiganalytics.metadata.jpa.support.QueryDslPathInspector.java
private static Object getObjectForField(BeanPath basePath, String field) throws IllegalAccessException { Map<String, Field> fieldSet = getFields(basePath.getClass()); if (StringUtils.isNotBlank(field)) { Field f = fieldSet.get(field); if (f != null) { Object o = f.get(basePath); return o; }// w w w . jav a 2 s.co m } return null; }
From source file:com.netflix.genie.web.data.repositories.jpa.specifications.JpaClusterSpecs.java
/** * Generate a specification given the parameters. * * @param name The name of the cluster to find * @param statuses The statuses of the clusters to find * @param tags The tags of the clusters to find * @param minUpdateTime The minimum updated time of the clusters to find * @param maxUpdateTime The maximum updated time of the clusters to find * @return The specification/*from w w w. j a va 2s . c o m*/ */ public static Specification<ClusterEntity> find(@Nullable final String name, @Nullable final Set<ClusterStatus> statuses, @Nullable final Set<TagEntity> tags, @Nullable final Instant minUpdateTime, @Nullable final Instant maxUpdateTime) { return (final Root<ClusterEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ClusterEntity_.name), name)); } if (minUpdateTime != null) { predicates.add(cb.greaterThanOrEqualTo(root.get(ClusterEntity_.updated), minUpdateTime)); } if (maxUpdateTime != null) { predicates.add(cb.lessThan(root.get(ClusterEntity_.updated), maxUpdateTime)); } if (tags != null && !tags.isEmpty()) { final Join<ClusterEntity, TagEntity> tagEntityJoin = root.join(ClusterEntity_.tags); predicates.add(tagEntityJoin.in(tags)); cq.groupBy(root.get(ClusterEntity_.id)); cq.having(cb.equal(cb.count(root.get(ClusterEntity_.id)), tags.size())); } if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array predicates.add( cb.or(statuses.stream().map(status -> cb.equal(root.get(ClusterEntity_.status), status)) .toArray(Predicate[]::new))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }