List of usage examples for org.apache.commons.lang3 StringUtils isNoneBlank
public static boolean isNoneBlank(final CharSequence... css)
Checks if none of the CharSequences are blank ("") or null and whitespace only..
StringUtils.isNoneBlank(null) = false StringUtils.isNoneBlank(null, "foo") = false StringUtils.isNoneBlank(null, null) = false StringUtils.isNoneBlank("", "bar") = false StringUtils.isNoneBlank("bob", "") = false StringUtils.isNoneBlank(" bob ", null) = false StringUtils.isNoneBlank(" ", "bar") = false StringUtils.isNoneBlank("foo", "bar") = true
From source file:com.dipesan.miniatm.miniatm.services.BluetoothConnexionManager.java
public boolean isInitialized() { return StringUtils.isNoneBlank(deviceAddr); }
From source file:ch.cyberduck.core.sftp.auth.SFTPChallengeResponseAuthentication.java
@Override public Boolean authenticate(final Host bookmark, final HostPasswordStore keychain, final LoginCallback callback, final CancelCallback cancel) throws BackgroundException { if (log.isDebugEnabled()) { log.debug(String.format("Login using challenge response authentication for %s", bookmark)); }//w w w. j a va 2 s.c om try { session.getClient().auth(bookmark.getCredentials().getUsername(), new AuthKeyboardInteractive(new ChallengeResponseProvider() { private String name = StringUtils.EMPTY; private String instruction = StringUtils.EMPTY; @Override public List<String> getSubmethods() { return Collections.emptyList(); } @Override public void init(final Resource resource, final String name, final String instruction) { if (StringUtils.isNoneBlank(instruction)) { this.instruction = instruction; } if (StringUtils.isNoneBlank(name)) { this.name = name; } } @Override public char[] getResponse(final String prompt, final boolean echo) { // For each prompt, the corresponding echo field indicates whether the user input should be echoed as characters are typed if (log.isDebugEnabled()) { log.debug(String.format("Reply to challenge name %s with instruction %s", name, instruction)); } if (echo) { return EMPTY_RESPONSE; } if (PasswordResponseProvider.DEFAULT_PROMPT_PATTERN.matcher(prompt).matches()) { return bookmark.getCredentials().getPassword().toCharArray(); } else { final StringAppender message = new StringAppender().append(instruction) .append(prompt); // Properly handle an instruction field with embedded newlines. They should also // be able to display at least 30 characters for the name and prompts. final Credentials additional; try { final StringAppender title = new StringAppender().append(name).append( LocaleFactory.localizedString("Provide additional login credentials", "Credentials")); additional = callback.prompt(bookmark, bookmark.getCredentials().getUsername(), title.toString(), message.toString(), new LoginOptions(bookmark.getProtocol()).user(false).publickey(false) .keychain(false) .usernamePlaceholder(bookmark.getCredentials().getUsername())); } catch (LoginCanceledException e) { return EMPTY_RESPONSE; } // Responses are encoded in ISO-10646 UTF-8. return additional.getPassword().toCharArray(); } } @Override public boolean shouldRetry() { return false; } })); } catch (IOException e) { throw new SFTPExceptionMappingService().map(e); } return session.getClient().isAuthenticated(); }
From source file:io.github.swagger2markup.extensions.SpringRestDocsExtension.java
/** * Instantiate extension//from w ww . java 2s .c o m * @param extensionId the unique ID of the extension * @param snippetBaseUri base URI where the snippets are stored * @param extensionMarkupLanguage the MarkupLanguage of the snippets content */ public SpringRestDocsExtension(String extensionId, URI snippetBaseUri, MarkupLanguage extensionMarkupLanguage) { super(); Validate.notNull(extensionId); Validate.notNull(snippetBaseUri); if (StringUtils.isNoneBlank(extensionId)) { this.extensionId = extensionId; } this.snippetBaseUri = snippetBaseUri; this.extensionMarkupLanguage = extensionMarkupLanguage; }
From source file:com.norconex.collector.core.data.store.impl.mongo.MongoCrawlDataStore.java
protected static DB buildMongoDB(String crawlerId, MongoConnectionDetails connDetails) { String dbName = MongoUtil.getDbNameOrGenerate(connDetails.getDatabaseName(), crawlerId); int port = connDetails.getPort(); if (port <= 0) { port = ServerAddress.defaultPort(); }/*from ww w .j a v a2 s. c o m*/ try { ServerAddress server = new ServerAddress(connDetails.getHost(), port); List<MongoCredential> credentialsList = new ArrayList<MongoCredential>(); if (StringUtils.isNoneBlank(connDetails.getUsername())) { MongoCredential credential = MongoCredential.createMongoCRCredential(connDetails.getUsername(), dbName, connDetails.getPassword().toCharArray()); credentialsList.add(credential); } MongoClient client = new MongoClient(server, credentialsList); return client.getDB(dbName); } catch (UnknownHostException e) { throw new CrawlDataStoreException(e); } }
From source file:com.thinkbiganalytics.config.rest.controller.ConfigurationController.java
@GET @Path("/module-urls") @Produces(MediaType.APPLICATION_JSON)//from w w w .ja v a2 s .co m @ApiOperation("Gets the paths to the UI modules.") @ApiResponses({ @ApiResponse(code = 200, message = "Returns a mapping between the module name and the URL path.", response = Map.class) }) public Response moduleUrls() { final String contextPath = env.getProperty("server.contextPath"); final String url = StringUtils.isNoneBlank(contextPath) ? contextPath : ""; final Map<String, String> map = new HashMap<>(); map.put("opsMgr", url + "/ops-mgr/index.html"); map.put("feedMgr", url + "/feed-mgr/index.html"); return Response.ok(map).build(); }
From source file:ch.cyberduck.core.sftp.SFTPChallengeResponseAuthentication.java
public boolean authenticate(final Host host, final Credentials credentials, final LoginCallback controller) throws BackgroundException { if (StringUtils.isBlank(host.getCredentials().getPassword())) { return false; }//w ww .j av a 2 s. com if (log.isDebugEnabled()) { log.debug(String.format("Login using challenge response authentication with credentials %s", credentials)); } try { session.getClient().auth(credentials.getUsername(), new AuthKeyboardInteractive(new ChallengeResponseProvider() { /** * Password sent flag */ private final AtomicBoolean password = new AtomicBoolean(); private String name = StringUtils.EMPTY; private String instruction = StringUtils.EMPTY; @Override public List<String> getSubmethods() { return Collections.emptyList(); } @Override public void init(final Resource resource, final String name, final String instruction) { if (StringUtils.isNoneBlank(instruction)) { this.instruction = instruction; } if (StringUtils.isNoneBlank(name)) { this.name = name; } } @Override public char[] getResponse(final String prompt, final boolean echo) { if (log.isDebugEnabled()) { log.debug(String.format("Reply to challenge name %s with instruction %s", name, instruction)); } final String response; // For each prompt, the corresponding echo field indicates whether the user input should // be echoed as characters are typed if (!password.get() // Some servers ask for one-time passcode first && !StringUtils.contains(prompt, "Verification code")) { // In its first callback the server prompts for the password if (log.isDebugEnabled()) { log.debug("First callback returning provided credentials"); } response = credentials.getPassword(); password.set(true); } else { final StringAppender message = new StringAppender().append(instruction) .append(prompt); // Properly handle an instruction field with embedded newlines. They should also // be able to display at least 30 characters for the name and prompts. final Credentials additional = new Credentials(credentials.getUsername()) { @Override public String getPasswordPlaceholder() { return StringUtils.removeEnd(StringUtils.strip(prompt), ":"); } }; try { final StringAppender title = new StringAppender().append(name).append( LocaleFactory.localizedString("Provide additional login credentials", "Credentials")); controller.prompt(host, additional, title.toString(), message.toString(), new LoginOptions().user(false).keychain(false)); } catch (LoginCanceledException e) { return EMPTY_RESPONSE; } response = additional.getPassword(); } // Responses are encoded in ISO-10646 UTF-8. return response.toCharArray(); } @Override public boolean shouldRetry() { return false; } })); } catch (IOException e) { throw new SFTPExceptionMappingService().map(e); } return session.getClient().isAuthenticated(); }
From source file:com.dominion.salud.mpr.negocio.report.evaluaciones.impl.AcuEvalResReportImpl.java
/** * * @param parametros//from ww w .ja va 2 s . c o m * @return * @throws com.dominion.salud.mpr.negocio.service.exception.InformeSinDatosException * @throws com.dominion.salud.mpr.negocio.service.exception.InformeException */ @Override public String listadoAcuEvalResReport(Map<String, Object> parametros) throws InformeSinDatosException, InformeException { logger.debug("Generando el listado: " + MPR_LISTADO_RESULTADOS); logger.debug(" Parametros del listado: "); logger.debug(" idAcuerdo: " + parametros.get("idAcuerdo")); logger.debug(" txtAcuerdo: " + parametros.get("txtAcuerdo")); logger.debug(" idCentro: " + parametros.get("idCentro")); logger.debug(" txtCentro: " + parametros.get("txtCentro")); logger.debug(" fecIniEval: " + parametros.get("fecIniEval")); logger.debug(" fecFinEval: " + parametros.get("fecFinEval")); //CONVERSION DE PARAMETROS DE ENTRADA logger.debug(" Iniciando la conversion de parametros para el listado"); SimpleDateFormat ddmmyyyy = new SimpleDateFormat("dd/MM/yyyy"); Date fecIniEval = null; Date fecFinEval = null; try { if (StringUtils.isNoneBlank((String) parametros.get("fecIniEval"))) { logger.debug(" Iniciando la conversion de fecIniEval: " + (String) parametros.get("fecIniEval")); fecIniEval = ddmmyyyy.parse((String) parametros.get("fecIniEval")); logger.debug(" Conversion de fecIniEval: " + (String) parametros.get("fecIniEval") + " realizada correctamente: " + fecIniEval); } } catch (ParseException pe) { logger.warn("No se ha podido parsear fecIniEval: " + parametros.get("fecIniEval")); } try { if (StringUtils.isNoneBlank((String) parametros.get("fecFinEval"))) { logger.debug(" Iniciando la conversion de fecFinEval: " + (String) parametros.get("fecFinEval")); fecFinEval = ddmmyyyy.parse((String) parametros.get("fecFinEval")); logger.debug(" Conversion de fecFinEval: " + (String) parametros.get("fecFinEval") + " realizada correctamente: " + fecFinEval); } } catch (ParseException pe) { logger.warn("No se ha podido parsear fecFinEval: " + parametros.get("fecFinEval")); } Long idCentro = null; if (StringUtils.isNotBlank((String) parametros.get("idCentro"))) { logger.debug(" Iniciando la conversion de idCentro: " + (String) parametros.get("idCentro")); idCentro = NumberUtils.toLong((String) parametros.get("idCentro")); logger.debug(" Conversion de idCentro: " + (String) parametros.get("idCentro") + " realizada correctamente: " + idCentro); } Long idAcuerdo = null; if (StringUtils.isNotBlank((String) parametros.get("idAcuerdo"))) { logger.debug(" Iniciando la conversion de idAcuerdo: " + (String) parametros.get("idAcuerdo")); idAcuerdo = NumberUtils.toLong((String) parametros.get("idAcuerdo")); logger.debug(" Conversion de idAcuerdo: " + (String) parametros.get("idAcuerdo") + " realizada correctamente: " + idAcuerdo); } logger.debug(" Finaliza la conversion de parametros para el listado"); //OBTENCION DE DATOS PARA POBLAR EL LISTADO logger.debug(" Iniciando la obtencion de informacion para el listado"); List<AcuEvalRes> acuEvalReses = new ArrayList<>(); acuEvalReses = acuEvalResService.findListadoAcuEvalRes(idCentro, idAcuerdo, fecIniEval, fecFinEval); logger.debug(" Se han obtenido: " + acuEvalReses.size() + " resultados"); if (acuEvalReses.size() <= 0) { throw new InformeSinDatosException("No se han obtenido resultados"); } logger.debug(" Finaliza la obtencion de informacion para el listado"); //GENERACION DEL INFORME try { logger.debug(" Localizando la plantilla del listado: " + getClass().getClassLoader().getResource(MPR_LISTADO_RESULTADOS)); JasperReport reporte = (JasperReport) JRLoader .loadObject(getClass().getClassLoader().getResource(MPR_LISTADO_RESULTADOS)); logger.debug(" Plantilla del listado localizada correctamente"); logger.debug(" Completando los datos del listado"); JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, new JRBeanCollectionDataSource(acuEvalReses)); logger.debug(" Datos del listado completados correctamente"); logger.debug(" Generando el listado en la ubicacion: " + MPRConstantes._MPR_RESOURCES + new Date().getTime() + ".pdf"); String ruta = reportPDFtoFile(jasperPrint, MPRConstantes._MPR_RESOURCES + new Date().getTime() + ".pdf"); logger.debug(" Listado generado correctamente en la ubicacion: " + ruta); logger.debug("Listado: " + MPR_LISTADO_RESULTADOS + " generado correctamente"); return ruta; } catch (Exception e) { throw new InformeException(e); } }
From source file:com.dominion.salud.mpr.negocio.report.tratamientos.impl.DispensacionesReportImpl.java
/** * * @param parametros// w ww. j av a2 s . c o m * @return * @throws com.dominion.salud.mpr.negocio.service.exception.InformeSinDatosException * @throws com.dominion.salud.mpr.negocio.service.exception.InformeException */ @Override public String listadoDispensacionReport(Map<String, Object> parametros) throws InformeSinDatosException, InformeException { logger.debug("Generando el listado: " + MPR_LISTADO_DISPENSACIONES); logger.debug(" Parametros del listado: "); logger.debug(" idAcuerdo: " + parametros.get("idAcuerdo")); logger.debug(" txtAcuerdo: " + parametros.get("txtAcuerdo")); logger.debug(" idCentro: " + parametros.get("idCentro")); logger.debug(" txtCentro: " + parametros.get("txtCentro")); logger.debug(" fecIniDisp: " + parametros.get("fecIniDisp")); logger.debug(" fecFinDisp: " + parametros.get("fecFinDisp")); //CONVERSION DE PARAMETROS DE ENTRADA logger.debug(" Iniciando la conversion de parametros para el listado"); SimpleDateFormat ddmmyyyy = new SimpleDateFormat("dd/MM/yyyy"); Date fecIniDisp = null; Date fecFinDisp = null; try { if (StringUtils.isNoneBlank((String) parametros.get("fecIniDisp"))) { logger.debug(" Iniciando la conversion de fecIniDisp: " + (String) parametros.get("fecIniDisp")); fecIniDisp = ddmmyyyy.parse((String) parametros.get("fecIniDisp")); logger.debug(" Conversion de fecIniDisp: " + (String) parametros.get("fecIniDisp") + " realizada correctamente: " + fecIniDisp); } } catch (ParseException pe) { logger.warn("No se ha podido parsear fecIniDisp: " + parametros.get("fecIniDisp")); } try { if (StringUtils.isNoneBlank((String) parametros.get("fecFinDisp"))) { logger.debug(" Iniciando la conversion de fecFinDisp: " + (String) parametros.get("fecFinDisp")); fecFinDisp = ddmmyyyy.parse((String) parametros.get("fecFinDisp")); logger.debug(" Conversion de fecFinDisp: " + (String) parametros.get("fecFinDisp") + " realizada correctamente: " + fecFinDisp); } } catch (ParseException pe) { logger.warn("No se ha podido parsear fecFinDisp: " + parametros.get("fecFinDisp")); } Long idCentro = null; if (StringUtils.isNotBlank((String) parametros.get("idCentro"))) { logger.debug(" Iniciando la conversion de idCentro: " + (String) parametros.get("idCentro")); idCentro = NumberUtils.toLong((String) parametros.get("idCentro")); logger.debug(" Conversion de idCentro: " + (String) parametros.get("idCentro") + " realizada correctamente: " + idCentro); } Long idAcuerdo = null; if (StringUtils.isNotBlank((String) parametros.get("idAcuerdo"))) { logger.debug(" Iniciando la conversion de idAcuerdo: " + (String) parametros.get("idAcuerdo")); idAcuerdo = NumberUtils.toLong((String) parametros.get("idAcuerdo")); logger.debug(" Conversion de idAcuerdo: " + (String) parametros.get("idAcuerdo") + " realizada correctamente: " + idAcuerdo); } logger.debug(" Finaliza la conversion de parametros para el listado"); //OBTENCION DE DATOS PARA POBLAR EL LISTADO logger.debug(" Iniciando la obtencion de informacion para el listado"); List<Dispensaciones> dispensacioneses = new ArrayList<>(); dispensacioneses = dispensacionesService.findListadoDispensaciones(idCentro, idAcuerdo, fecIniDisp, fecFinDisp); logger.debug(" Se han obtenido: " + dispensacioneses.size() + " resultados"); if (dispensacioneses.size() <= 0) { throw new InformeSinDatosException("No se han obtenido resultados"); } logger.debug(" Finaliza la obtencion de informacion para el listado"); //GENERACION DEL INFORME try { logger.debug(" Localizando la plantilla del listado: " + getClass().getClassLoader().getResource(MPR_LISTADO_DISPENSACIONES)); JasperReport reporte = (JasperReport) JRLoader .loadObject(getClass().getClassLoader().getResource(MPR_LISTADO_DISPENSACIONES)); logger.debug(" Plantilla del listado localizada correctamente"); logger.debug(" Completando los datos del listado"); JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, new JRBeanCollectionDataSource(dispensacioneses)); logger.debug(" Datos del listado completados correctamente"); logger.debug(" Generando el listado en la ubicacion: " + MPRConstantes._MPR_RESOURCES + new Date().getTime() + ".pdf"); String ruta = reportPDFtoFile(jasperPrint, MPRConstantes._MPR_RESOURCES + new Date().getTime() + ".pdf"); logger.debug(" Listado generado correctamente en la ubicacion: " + ruta); logger.debug("Listado: " + MPR_LISTADO_DISPENSACIONES + " generado correctamente"); return ruta; } catch (Exception e) { throw new InformeException(e); } }
From source file:net.riezebos.thoth.renderers.util.CustomHtmlSerializer.java
protected void writeBookmarks(HeaderNode node) { // Headers might be tokenized; so we need to append them together. String combinedName = ""; for (Node child : node.getChildren()) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; String text = textNode.getText(); if (text != null && text.trim().length() > 0) { combinedName += text.trim(); }//w w w . j a v a2 s . com } } if (StringUtils.isNoneBlank(combinedName)) { String ref = ThothUtil.encodeBookmark(combinedName, false); writeBookmark(ref); // Also add a bookmark that excludes any (potentially) generated numbers as a prefix of the title int idx = 0; for (int i = 0; i < ref.length(); i++, idx++) { if (!Character.isDigit(ref.charAt(i)) && ref.charAt(i) != '.') break; } if (idx != 0) { String alternate = ref.substring(idx).trim(); writeBookmark(alternate); } } }
From source file:com.frank.search.solr.server.support.HttpSolrClientFactoryBean.java
private void createCloudClient() { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections);// 1000 params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost);// 5000 params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, timeout); params.set(HttpClientUtil.PROP_SO_TIMEOUT, timeout); HttpClient client = HttpClientUtil.createClient(params); LBHttpSolrClient lbHttpSolrClient = new LBHttpSolrClient(client); CloudSolrClient cloudSolrClient = new CloudSolrClient(url, lbHttpSolrClient); if (zkClientTimeout != null) { cloudSolrClient.setZkClientTimeout(zkClientTimeout.intValue()); }//ww w. j av a 2 s . c o m if (zkConnectTimeout != null) { cloudSolrClient.setZkConnectTimeout(zkConnectTimeout.intValue()); } if (StringUtils.isNoneBlank(collection)) { cloudSolrClient.setDefaultCollection(collection); } cloudSolrClient.connect(); this.setSolrClient(cloudSolrClient); }