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.kixeye.chassis.transport.websocket.WebSocketPskFrameProcessor.java
/** * @param cipherProvider/*from w w w . ja v a 2s .c om*/ * @param cipherTransformation * @param secretKeyProvider * @param secretKeyAlgorithm * @param secretKeyData * @param secretKeyPath * @param enabled * @param secretKey */ @Autowired public WebSocketPskFrameProcessor(@Value("${websocket.crypto.cipherProvider:}") String cipherProvider, @Value("${websocket.crypto.cipherTransformation:}") String cipherTransformation, @Value("${websocket.crypto.secretKeyAlgorithm:}") String secretKeyAlgorithm, @Value("${websocket.crypto.secretKeyData:}") String secretKeyData, @Value("${websocket.crypto.secretKeyPath:}") String secretKeyPath, @Value("${websocket.crypto.enabled:false}") boolean enabled) throws Exception { if (enabled) { byte[] secretKey = null; if (StringUtils.isNoneBlank(secretKeyData)) { secretKey = BaseEncoding.base16().decode(secretKeyData); } else if (StringUtils.isNoneBlank(secretKeyPath)) { Resource secretKeyFile = RESOURCE_LOADER.getResource(secretKeyPath); secretKey = IOUtils.toByteArray(secretKeyFile.getInputStream()); } else { throw new IllegalArgumentException("Neither secret key data nor path were provided."); } cipher = new SymmetricKeyCipher(cipherProvider, cipherTransformation, secretKeyAlgorithm, secretKey); } else { cipher = null; } }
From source file:com.qq.tars.service.config.ConfigService.java
@Transactional(rollbackFor = Exception.class) public ConfigFile addConfigFile(AddConfigFile params) { int level = params.getLevel(); Preconditions.checkState(level >= 1 && level <= 5); ConfigFile configFile = new ConfigFile(); configFile.setLevel(level == 5 ? 2 : 1); String server;/*w ww . jav a 2s . c o m*/ if (configFile.getLevel() == 1) { Preconditions.checkState(StringUtils.isNoneBlank(params.getApplication())); server = params.getApplication(); } else { Preconditions.checkState(StringUtils.isNoneBlank(params.getApplication(), params.getServerName())); server = String.format("%s.%s", params.getApplication(), params.getServerName()); } configFile.setServerName(server); if (StringUtils.isNotBlank(params.getSetName())) { configFile.setSetName(params.getSetName()); } if (StringUtils.isNotBlank(params.getSetArea())) { configFile.setSetArea(params.getSetArea()); } if (StringUtils.isNotBlank(params.getSetGroup())) { configFile.setSetGroup(params.getSetGroup()); } Preconditions.checkState(StringUtils.isNotBlank(params.getFilename())); configFile.setFilename(params.getFilename()); configFile.setConfig(StringUtils.trimToEmpty(params.getConfig())); configFile.setPosttime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); configMapper.insertConfigFile(configFile); ConfigFileHistory history = new ConfigFileHistory(); history.setConfigId(configFile.getId()); history.setReason("?"); history.setContent(configFile.getConfig()); history.setPosttime(configFile.getPosttime()); configMapper.insertConfigFileHistory(history); // ?? if (configFile.getLevel() == 2) { boolean enableSet = StringUtils.isNoneBlank(params.getSetName(), params.getSetArea(), params.getSetGroup()); addDefaultNodeConfigFile(params.getApplication(), params.getServerName(), enableSet, params.getSetName(), params.getSetArea(), params.getSetGroup(), params.getFilename()); } return configFile; }
From source file:io.ecarf.core.cloud.task.processor.analyze.ExtractAndCountTermsTask.java
@Override public void run() throws IOException { Stopwatch stopwatch = Stopwatch.createStarted(); log.info("START: ExtractAndCountTermsTask task" + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB"); EcarfGoogleCloudService cloudService = (EcarfGoogleCloudService) this.getCloudService(); TermCounter counter = null;//w w w. ja v a 2s. c o m if (StringUtils.isNoneBlank(this.schemaTermsFile)) { log.info("Downloading schema terms file: " + schemaTermsFile); Set<String> schemaTerms = cloudService.getSetFromCloudStorageFile(schemaTermsFile, bucket); counter = new TermCounter(); counter.setTermsToCount(schemaTerms); } Set<String> filesSet = ObjectUtils.csvToSet(files); log.info("Processing files: " + filesSet); for (final String file : filesSet) { Stopwatch stopwatch1 = Stopwatch.createStarted(); log.info("Downloading file: " + file + ", timer: 0s"); String localFile = Utils.TEMP_FOLDER + file; cloudService.downloadObjectFromCloudStorage(file, localFile, sourceBucket); log.info("Processing file: " + localFile + ", timer: " + stopwatch1); NxGzipProcessor processor = new NxGzipProcessor(localFile); ExtractTermsCallback callback = new ExtractTermsCallback(); callback.setCounter(counter); processor.read(callback); Set<String> terms = callback.getResources(); terms.addAll(callback.getBlankNodes()); log.info("Finished processing file: " + localFile + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB" + ", timer: " + stopwatch1); log.info("Number of unique URIs: " + callback.getResources().size()); log.info("Number of blank nodes: " + callback.getBlankNodes().size()); log.info("Number of literals: " + callback.getLiteralCount()); String termsFile = Utils.TEMP_FOLDER + file + Constants.DOT_SER + Constants.GZIP_EXT; Utils.objectToFile(termsFile, terms, true); log.info("Serialized terms file: " + termsFile + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB" + ", timer: " + stopwatch1); cloudService.uploadFileToCloudStorage(termsFile, bucket); log.info("Uploaded terms file: " + termsFile + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB" + ", timer: " + stopwatch1); } // write term stats to file and upload if (counter != null) { log.info("Saving terms stats"); String countStatsFile = Utils.TEMP_FOLDER + cloudService.getInstanceId() + Constants.DOT_JSON; FileUtils.objectToJsonFile(countStatsFile, counter.getCount()); cloudService.uploadFileToCloudStorage(countStatsFile, bucket); } log.info("TIMER# All files are processed successfully, elapsed time: " + stopwatch); }
From source file:cn.afterturn.easypoi.view.EasypoiPDFTemplateView.java
@Override @SuppressWarnings("unchecked") protected final void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { String fileName = ""; ByteArrayOutputStream baos = createTemporaryOutputStream(); PdfExportParams entity = (PdfExportParams) model.get(PDFTemplateConstants.PARAMS); Class<?> pojoClass = (Class<?>) model.get(PDFTemplateConstants.CLASS); Collection<?> dataSet = (Collection<?>) model.get(PDFTemplateConstants.DATA_LIST); List<ExcelExportEntity> entityList = (List<ExcelExportEntity>) model.get(PDFTemplateConstants.ENTITY_LIST); if (entityList == null) { PdfExportUtil.exportPdf(entity, pojoClass, dataSet, baos); } else {//from w w w . j a va 2s .c o m PdfExportUtil.exportPdf(entity, entityList, (Collection<? extends Map<?, ?>>) dataSet, baos); } String userFileName = (String) model.get(PDFTemplateConstants.FILE_NAME); if (StringUtils.isNoneBlank(userFileName)) { fileName = userFileName; } // ??RFC 5987??header, UA response.setHeader("content-disposition", WebFilenameUtils.disposition(fileName + ".pdf")); writeToResponse(response, baos); }
From source file:com.github.lburgazzoli.quickfixj.osgi.ConfigAdminSessionSettingsBuilder.java
/** * * @param prop/* w w w. j a va 2s.c o m*/ * @return */ private boolean validate(Dictionary<String, Object> prop) { return StringUtils.isNoneBlank((String) prop.get(SessionSettings.BEGINSTRING)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.SENDERCOMPID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.SENDERSUBID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.SENDERLOCID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.TARGETCOMPID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.TARGETSUBID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.TARGETLOCID)) && StringUtils.isNoneBlank((String) prop.get(SessionSettings.SESSION_QUALIFIER)) && StringUtils.isNoneBlank((String) prop.get(SessionFactory.INITIATOR_CONNECTION_TYPE)); }
From source file:io.ecarf.core.cloud.task.processor.old.ProcessLoadTaskOld.java
@Override public void run() throws IOException { log.info("START: processing files for bigquery import"); //String bucket = metadata.getBucket(); // get the schema terms if provided //String schemaTermsFile = metadata.getSchemaTermsFile(); EcarfGoogleCloudService cloudService = (EcarfGoogleCloudService) this.getCloudService(); TermCounter counter = null;//from ww w.j a v a 2 s. c o m if (StringUtils.isNoneBlank(schemaTermsFile)) { // convert from JSON Set<String> schemaTerms = cloudService.getSetFromCloudStorageFile(schemaTermsFile, bucket); counter = new TermCounter(); counter.setTermsToCount(schemaTerms); } //Set<String> files = metadata.getFiles(); Set<String> filesSet = ObjectUtils.csvToSet(files); log.info("Loading files: " + filesSet); for (final String file : filesSet) { String localFile = Utils.TEMP_FOLDER + file; log.info("Downloading file: " + file); cloudService.downloadObjectFromCloudStorage(file, localFile, bucket); // all downloaded, carryon now, process the files log.info("Processing file: " + localFile); String outFile = cloudService.prepareForBigQueryImport(localFile, counter, false); // once the processing is done then delete the local file FileUtils.deleteFile(localFile); // now upload the files again log.info("Uploading file: " + outFile); cloudService.uploadFileToCloudStorage(outFile, bucket); // now delete all the locally processed files FileUtils.deleteFile(outFile); } // write term stats to file and upload if (counter != null) { log.info("Saving terms stats"); String countStatsFile = Utils.TEMP_FOLDER + cloudService.getInstanceId() + Constants.DOT_JSON; FileUtils.objectToJsonFile(countStatsFile, counter.getCount()); cloudService.uploadFileToCloudStorage(countStatsFile, bucket); } log.info("FINISH: All files are processed and uploaded successfully"); }
From source file:io.github.swagger2markup.extensions.SchemaExtension.java
/** * Instantiate extension//from ww w . java 2 s . co m * @param extensionId the unique ID of the extension * @param schemaBaseUri base URI where the schemas are stored */ public SchemaExtension(String extensionId, URI schemaBaseUri) { super(); Validate.notNull(schemaBaseUri); if (StringUtils.isNoneBlank(extensionId)) { this.extensionId = extensionId; } this.schemaBaseUri = schemaBaseUri; }
From source file:com.chessix.vas.actors.ClerkActor.java
@Override public void onReceive(final Object message) throws Exception { log.debug("Received message: {}", message); if (message instanceof CreateClas.Request) { final CreateClas.Request request = (CreateClas.Request) message; createClas(request);/* w w w .j a va 2s . co m*/ getSender().tell(new CreateClas.ResponseBuilder(true).build(), getSender()); } else if (message instanceof CreateAccount.Request) { final CreateAccount.Request request = (CreateAccount.Request) message; final String accountId = createAccount(request); if (StringUtils.isNoneBlank(accountId)) { getSender().tell(new CreateAccount.ResponseBuilder(true).clasId(request.getClasId()) .accountId(accountId).build(), getSelf()); journalActor.tell(new JournalMessage.AccountCreatedBuilder(clasId, accountId).build(), getSelf()); } else { getSender().tell(new CreateAccount.ResponseBuilder(false).clasId(request.getClasId()) .message("Account does already exist").build(), getSelf()); } } else if (message instanceof Transfer.Request) { final Transfer.Request request = (Transfer.Request) message; if (transfer(request)) { getSender().tell(new Transfer.ResponseBuilder(true).message("Ok").build(), getSelf()); journalActor.tell(new JournalMessage.TransferBuilder(clasId, request.getFrom(), request.getTo(), request.getAmount()).build(), getSelf()); } else { getSender().tell(new Transfer.ResponseBuilder(false).message("Accounts do not exist").build(), getSelf()); } } else if (message instanceof Balance.Request) { final Integer balance = balance((Balance.Request) message); getSender().tell(new Balance.ResponseBuilder(balance != null).amount(balance).build(), getSelf()); } else if (message instanceof Clean.Request) { final Clean.Request request = (Clean.Request) message; clean(request); getSender().tell(new Clean.ResponseBuilder(true).clasId(request.getClasId()).message("Ok").build(), getSelf()); } else if (message instanceof Count.Request) { final Request request = (Request) message; final Long count = count(request); getSender().tell( new Count.ResponseBuilder(count != null).clasId(request.getClasId()).count(count).build(), getSelf()); } else if (message instanceof Validate.Request) { final Validate.Request request = (Validate.Request) message; getSender().tell(new Validate.ResponseBuilder(validate()).clasId(request.getClasId()).build(), getSelf()); } else { unhandled(message); } }
From source file:io.github.swagger2markup.extensions.DynamicOverviewDocumentExtension.java
/** * Instantiate extension// www.ja v a 2s .c o m * @param extensionId the unique ID of the extension * @param contentPath the base Path where the content is stored * @param extensionMarkupLanguage the MarkupLanguage of the extension content */ public DynamicOverviewDocumentExtension(String extensionId, Path contentPath, MarkupLanguage extensionMarkupLanguage) { super(); Validate.notNull(extensionMarkupLanguage); Validate.notNull(contentPath); if (StringUtils.isNoneBlank(extensionId)) { this.extensionId = extensionId; } this.contentPath = contentPath; this.extensionMarkupLanguage = extensionMarkupLanguage; }
From source file:cz.lbenda.dataman.db.handler.ExportTableWithTemplateHandler.java
@Override public void handle(ActionEvent event) { if (sqlQueryRowsObjectProperty.getValue() == null) { return;/*ww w. ja v a 2 s .c o m*/ } templateExportConfig = ChooseExportTemplateFrmController.openDialog(templateExportConfig); if (templateExportConfig != null && StringUtils.isNoneBlank(templateExportConfig.getFile()) && StringUtils.isNoneBlank(templateExportConfig.getTemplateFile())) { SQLQueryRows sqlQueryRows = sqlQueryRowsObjectProperty.getValue(); try (FileOutputStream fos = new FileOutputStream(templateExportConfig.getFile())) { ExportTableData.writeSqlQueryRows(templateExportConfig.getTemplateFormat(), sqlQueryRows, templateExportConfig.getTemplateFile(), fos); } catch (IOException e) { LOG.error("Problem with write files", e); ExceptionMessageFrmController.showException("Problem with write files", e); } } }