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:edu.usu.sdl.openstorefront.common.util.TimeUtil.java
public static Date fromString(String value) { Date newDate = null;//from w ww . j a v a 2 s .co m if (StringUtils.isNotBlank(value)) { SimpleDateFormat sdf = new SimpleDateFormat(OMP_DATE_FORMAT); newDate = sdf.parse(value, new ParsePosition(0)); } return newDate; }
From source file:com.moviejukebox.model.enumerations.WatchedWithLocation.java
/** * Convert a string into an Enum type//from w ww . j av a2 s . co m * * @param location * @return * @throws IllegalArgumentException If type is not recognised * */ public static WatchedWithLocation fromString(String location) { if (StringUtils.isNotBlank(location)) { for (final WatchedWithLocation withLocation : EnumSet.allOf(WatchedWithLocation.class)) { if (location.equalsIgnoreCase(withLocation.toString())) { return withLocation; } } } // We've not found the type, so reutrn CUSTOM return CUSTOM; }
From source file:com.mirth.connect.connectors.dimse.DICOMConfigurationUtil.java
public static void configureDcmRcv(MirthDcmRcv dcmrcv, DICOMReceiver connector, DICOMReceiverProperties connectorProperties, String[] protocols) throws Exception { if (!StringUtils.equals(connectorProperties.getTls(), "notls")) { if (connectorProperties.getTls().equals("without")) { dcmrcv.setTlsWithoutEncyrption(); } else if (connectorProperties.getTls().equals("3des")) { dcmrcv.setTls3DES_EDE_CBC(); } else if (connectorProperties.getTls().equals("aes")) { dcmrcv.setTlsAES_128_CBC();/*from www. j a va 2 s.c om*/ } String trustStore = connector.getReplacer().replaceValues(connectorProperties.getTrustStore(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(trustStore)) { dcmrcv.setTrustStoreURL(trustStore); } String trustStorePW = connector.getReplacer().replaceValues(connectorProperties.getTrustStorePW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(trustStorePW)) { dcmrcv.setTrustStorePassword(trustStorePW); } String keyPW = connector.getReplacer().replaceValues(connectorProperties.getKeyPW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyPW)) { dcmrcv.setKeyPassword(keyPW); } String keyStore = connector.getReplacer().replaceValues(connectorProperties.getKeyStore(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyStore)) { dcmrcv.setKeyStoreURL(keyStore); } String keyStorePW = connector.getReplacer().replaceValues(connectorProperties.getKeyStorePW(), connector.getChannelId(), connector.getChannel().getName()); if (StringUtils.isNotBlank(keyStorePW)) { dcmrcv.setKeyStorePassword(keyStorePW); } dcmrcv.setTlsNeedClientAuth(connectorProperties.isNoClientAuth()); protocols = ArrayUtils.clone(protocols); if (connectorProperties.isNossl2()) { if (ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.remove("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } } else if (!ArrayUtils.contains(protocols, "SSLv2Hello")) { List<String> protocolsList = new ArrayList<String>(Arrays.asList(protocols)); protocolsList.add("SSLv2Hello"); protocols = protocolsList.toArray(new String[protocolsList.size()]); } dcmrcv.setTlsProtocol(MirthSSLUtil.getEnabledHttpsProtocols(protocols)); dcmrcv.initTLS(); } }
From source file:com.omertron.themoviedbapi.enumeration.PeopleMethod.java
/** * Convert a string into an Enum type/*from www . jav a 2s . c o m*/ * * @param method * @return * @throws IllegalArgumentException If type is not recognised * */ public static PeopleMethod fromString(String method) { if (StringUtils.isNotBlank(method)) { try { return PeopleMethod.valueOf(method.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Method " + method + " does not exist.", ex); } } throw new IllegalArgumentException("Method must not be null"); }
From source file:net.packet.pojo.Error.java
public String getAllErrors() { String allErrors = StringUtils.join(errors, ",\n"); if (StringUtils.isNotBlank(error)) { allErrors = error + ",\n" + allErrors; }//from www .java 2 s .c o m return allErrors; }
From source file:com.alibaba.datax.plugin.reader.odpsreader.util.IdAndKeyUtil.java
public static Configuration parseAccessIdAndKey(Configuration originalConfig) { String accessId = originalConfig.getString(Key.ACCESS_ID); String accessKey = originalConfig.getString(Key.ACCESS_KEY); // ?? accessId,accessKey ????? accessid/accessKey if (StringUtils.isNotBlank(accessId) || StringUtils.isNotBlank(accessKey)) { LOG.info("Try to get accessId/accessKey from your config."); //???//w ww .j a v a 2s . c o m accessId = originalConfig.getNecessaryValue(Key.ACCESS_ID, OdpsReaderErrorCode.REQUIRED_VALUE); accessKey = originalConfig.getNecessaryValue(Key.ACCESS_KEY, OdpsReaderErrorCode.REQUIRED_VALUE); //?? return originalConfig; } else { Map<String, String> envProp = System.getenv(); return getAccessIdAndKeyFromEnv(originalConfig, envProp); } }
From source file:com.alibaba.datax.plugin.writer.odpswriter.util.IdAndKeyUtil.java
public static Configuration parseAccessIdAndKey(Configuration originalConfig) { String accessId = originalConfig.getString(Key.ACCESS_ID); String accessKey = originalConfig.getString(Key.ACCESS_KEY); // ?? accessId,accessKey ????? accessid/accessKey if (StringUtils.isNotBlank(accessId) || StringUtils.isNotBlank(accessKey)) { LOG.info("Try to get accessId/accessKey from your config."); //???/*from w ww . java2 s . c om*/ accessId = originalConfig.getNecessaryValue(Key.ACCESS_ID, OdpsWriterErrorCode.REQUIRED_VALUE); accessKey = originalConfig.getNecessaryValue(Key.ACCESS_KEY, OdpsWriterErrorCode.REQUIRED_VALUE); //?? return originalConfig; } else { Map<String, String> envProp = System.getenv(); return getAccessIdAndKeyFromEnv(originalConfig, envProp); } }
From source file:com.hybris.mobile.lib.commerce.utils.JsonUtils.java
/** * Build Message to inform about an malfunctioning, mistake, inconsistency or anomaly * * @param errorMessage String of character providing information about malfunctioning, mistake, inconsistency or anomaly * @param errorType Kind of message// w w w . j a va2 s . c o m * @return Message to inform about an malfunctioning, mistake, inconsistency or anomaly */ public static String createErrorMessageFromOCC(String errorMessage, String errorType) { errorMessage = StringEscapeUtils.escapeEcmaScript(errorMessage); return ERROR_MESSAGE_JSON.replace(MSG_TO_REPLACE, StringUtils.isNotBlank(errorMessage) ? errorMessage : "") .replace(TYPE_TO_REPLACE, StringUtils.isNotBlank(errorType) ? errorType : ""); }
From source file:com.omertron.themoviedbapi.enumeration.TVMethod.java
/** * Convert a string into an Enum type//from w ww.j a va 2s . c om * * @param method * @return * @throws IllegalArgumentException If type is not recognised * */ public static TVMethod fromString(String method) { if (StringUtils.isNotBlank(method)) { try { return TVMethod.valueOf(method.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Method " + method + " does not exist.", ex); } } throw new IllegalArgumentException("Method must not be null"); }
From source file:controllers.api.v1.SchemaHistory.java
public static Result getPagedDatasets() { ObjectNode result = Json.newObject(); String name = request().getQueryString("name"); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from w w w . j ava 2 s. c o m*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("SchemaHistory Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage()); page = 1; } } Long datasetId = 0L; String datasetIdStr = request().getQueryString("datasetId"); if (StringUtils.isNotBlank(datasetIdStr)) { try { datasetId = Long.parseLong(datasetIdStr); } catch (NumberFormatException e) { datasetId = 0L; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("SchemaHistory Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", SchemaHistoryDAO.getPagedSchemaDataset(name, datasetId, page, size)); return ok(result); }