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:org.apache.reef.javabridge.FailedTaskBridge.java
private byte[] generateFailedTaskSerializedAvro() throws IOException { AvroFailedTask avroFailedTask = null; if (jfailedTask.getData() != null && jfailedTask.getData().isPresent()) { // Deserialize what was passed in from C#. try (final ByteArrayInputStream fileInputStream = new ByteArrayInputStream( jfailedTask.getData().get())) { final JsonDecoder decoder = DecoderFactory.get().jsonDecoder(AvroFailedTask.getClassSchema(), fileInputStream);//from w w w . j a v a 2 s. co m final SpecificDatumReader<AvroFailedTask> reader = new SpecificDatumReader<>(AvroFailedTask.class); avroFailedTask = reader.read(null, decoder); } } else { // This may result from a failed Evaluator. avroFailedTask = AvroFailedTask.newBuilder().setIdentifier(jfailedTask.getId()) .setCause(ByteBuffer.wrap(new byte[0])).setData(ByteBuffer.wrap(new byte[0])).setMessage("") .build(); } // Overwrite the message if Java provides a message and C# does not. // Typically the case for failed Evaluators. if (StringUtils.isNoneBlank(jfailedTask.getMessage()) && StringUtils.isBlank(avroFailedTask.getMessage().toString())) { avroFailedTask.setMessage(jfailedTask.getMessage()); } final DatumWriter<AvroFailedTask> datumWriter = new SpecificDatumWriter<>(AvroFailedTask.class); try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { final JsonEncoder encoder = EncoderFactory.get().jsonEncoder(avroFailedTask.getSchema(), outputStream); datumWriter.write(avroFailedTask, encoder); encoder.flush(); outputStream.flush(); return outputStream.toByteArray(); } }
From source file:org.apache.rocketmq.console.service.impl.TopicServiceImplTest.java
@Test public void sendTopicMessageRequest() throws Exception { SendTopicMessageRequest sendTopicMessageRequest = new SendTopicMessageRequest(); sendTopicMessageRequest.setTopic(TEST_CONSOLE_TOPIC); sendTopicMessageRequest.setMessageBody("sendTopicMessageRequestMessageBody"); sendTopicMessageRequest.setKey("sendTopicMessageRequestKey"); sendTopicMessageRequest.setTag("sendTopicMessageRequestTag"); SendResult sendResult = topicService.sendTopicMessageRequest(sendTopicMessageRequest); Assert.assertNotNull(sendResult);/*from w ww . j a v a2 s . c o m*/ Assert.assertTrue(StringUtils.isNoneBlank(sendResult.getMsgId())); }
From source file:org.craftercms.studio.impl.repository.mongodb.internal.exception.ErrorManager.java
public static <T extends StudioException> T createError(final Class<T> type, final ErrorCode errorCode, final Throwable cause, final String... args) { final Constructor<T> ctor; T errorEx = (T) new StudioException(ErrorCode.UNKNOW_ERROR, "Unable to generate error message", cause); try {// ww w .j av a 2 s .c o m ctor = type.getConstructor(ErrorCode.class, String.class, Throwable.class); } catch (NoSuchMethodException ex) { return errorEx; } try { if (instance != null) { Map<String, ResourceBundle> errorMap = instance.getErrorMap(); if (errorMap != null) { ResourceBundle messageBundle = errorMap.get(errorCode.getModuleId()); if (messageBundle == null) { logger.error("Module Error is not register"); return errorEx; } final String msg = messageBundle.getString(errorCode.getCode()); if (StringUtils.isNoneBlank(msg)) { String message; if (args != null || args.length > 0) { message = String.format(msg, (Object[]) args); } else { message = msg; } return ctor.newInstance(errorCode, message, cause); } else { logger.error("Message for error code {} is not found", errorCode.getCode()); return errorEx; } } else { logger.error("Error while generating the exception"); return ctor.newInstance(ErrorCode.UNKNOW_ERROR, "Unable to generate proper error message", cause); } } else { return errorEx; } } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) { return errorEx; } }
From source file:org.csstudio.diirt.util.core.preferences.DIIRTPreferences.java
/** * Export the current DIIRT configuration creating the relative files. * * @param diirtHome The DIIRT configuration directory. * @throws JAXBException If there were some marshalling problems. * @throws IOException If an error occurred writing the configuration. *///from ww w . java 2 s . co m public void toFiles(File diirtHome) throws IOException { if (diirtHome == null || !diirtHome.exists() || !diirtHome.isDirectory()) { return; } new DataSources(this).toFile(diirtHome); new ChannelAccess(this).toFile(diirtHome); String confDir = getString(PREF_CONFIGURATION_DIRECTORY); if (StringUtils.isNoneBlank(confDir)) { File confFile = new File(confDir); if (confFile.exists() && confFile.isDirectory()) { copyFiles(confFile, diirtHome, Arrays.asList(new File(DataSources.DATASOURCES_DIR, DataSources.DATASOURCES_FILE), new File(new File(DataSources.DATASOURCES_DIR, ChannelAccess.CA_DIR), ChannelAccess.CA_FILE))); } } }
From source file:org.egov.ptis.actions.common.PropertyTaxBaseAction.java
public void populateUsages(final String propertyCategory) { List<PropertyUsage> usageList = propertyUsageService.getAllActiveMixedPropertyUsages(); // Loading property usages based on property category if (StringUtils.isNoneBlank(propertyCategory)) if (propertyCategory.equals(CATEGORY_MIXED)) usageList = propertyUsageService.getAllActiveMixedPropertyUsages(); else if (propertyCategory.equals(CATEGORY_RESIDENTIAL)) usageList = propertyUsageService.getResidentialPropertyUsages(); else if (propertyCategory.equals(CATEGORY_NON_RESIDENTIAL)) usageList = propertyUsageService.getNonResidentialPropertyUsages(); addDropdownData("UsageList", usageList); }
From source file:org.egov.ptis.actions.modify.ModifyPropertyAction.java
@Override public void prepare() { super.prepare(); setUserInfo();//from ww w. j av a2s .c om setUserDesignations(); propertyByEmployee = propService.isEmployee(securityUtils.getCurrentUser()) && !ANONYMOUS_USER.equalsIgnoreCase(securityUtils.getCurrentUser().getName()); citizenPortalUser = propService.isCitizenPortalUser(securityUtils.getCurrentUser()); if (getModelId() != null && !getModelId().isEmpty()) prepareWorkflowPropInfo(); else if (indexNumber != null && !indexNumber.trim().isEmpty()) { setBasicProp((BasicProperty) getPersistenceService().findByNamedQuery(QUERY_BASICPROPERTY_BY_UPICNO, indexNumber)); preparePropertyTaxDetails(basicProp.getProperty()); } documentTypes = propService.getDocumentTypesForTransactionType(TransactionType.MODIFY); populateDropdowns(); if (getBasicProp() != null) setPropAddress(getBasicProp().getAddress().toString()); if (propWF != null) prepareOwnerDetails(); populateUsages(StringUtils.isNoneBlank(propertyCategory) ? propertyCategory : propertyModel.getPropertyDetail().getCategoryType()); setBoundaryDetailsFlag(basicProp); }
From source file:org.egov.ptis.domain.service.property.VacancyRemissionService.java
public ReportRequest generateVRReportRequest(VacancyRemission vacancyRemission, String noticeNo, HttpServletRequest request, final String approvedUser) { ReportRequest reportInput = null;/*from www . ja v a 2 s .c om*/ CFinancialYear financialYear; if (vacancyRemission != null) { final BasicPropertyImpl basicProperty = vacancyRemission.getBasicProperty(); final Map<String, Object> reportParams = new HashMap<>(); final SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); final String cityName = request.getSession().getAttribute("citymunicipalityname").toString(); final String cityGrade = request.getSession().getAttribute("cityGrade") != null ? request.getSession().getAttribute("cityGrade").toString() : null; Boolean isCorporation; if (StringUtils.isNoneBlank(cityGrade) && CITY_GRADE_CORPORATION.equalsIgnoreCase(cityGrade)) isCorporation = true; else isCorporation = false; final Address ownerAddress = basicProperty.getAddress(); final PropertyID propertyId = basicProperty.getPropertyID(); reportParams.put("isCorporation", isCorporation); reportParams.put("cityName", cityName); reportParams.put("userSignature", securityUtils.getCurrentUser().getSignature() != null ? new ByteArrayInputStream(securityUtils.getCurrentUser().getSignature()) : ""); reportParams.put("loggedInUsername", approvedUser); reportParams.put("approvedDate", formatter.format(vacancyRemission.getState().getCreatedDate())); reportParams.put("approverName", userService.getUserById(ApplicationThreadLocals.getUserId()).getName()); reportParams.put("applicationDate", formatter.format(vacancyRemission.getCreatedDate())); reportParams.put("currentDate", formatter.format(new Date())); reportParams.put("noticeNo", noticeNo); reportParams.put("ownerName", basicProperty.getFullOwnerName()); reportParams.put("houseNo", ownerAddress.getHouseNoBldgApt()); reportParams.put("assessmentNo", basicProperty.getUpicNo()); reportParams.put("locality", propertyId.getLocality().getName()); reportParams.put("vrFromDate", formatter.format(vacancyRemission.getVacancyFromDate())); reportParams.put("vrToDate", formatter.format(vacancyRemission.getVacancyToDate())); final int noOfMonths = DateUtils.noOfMonthsBetween(vacancyRemission.getVacancyFromDate(), new DateTime(vacancyRemission.getVacancyToDate()).plusDays(1).toDate()); reportParams.put("totalMonths", noOfMonths); final Map<String, BigDecimal> currentDemand = ptDemandDAO .getDemandCollMap(vacancyRemission.getBasicProperty().getProperty()); BigDecimal halfYearTax = currentDemand.get(CURR_SECONDHALF_DMD_STR); BigDecimal newTax = BigDecimal.ZERO; financialYear = propertyTaxUtil.getFinancialYearforDate(new Date()); final Map<String, Installment> installmentMap = propertyTaxUtil.getInstallmentsForCurrYear( vacancyRemission.getVacancyRemissionApproval().get(0).getApprovalDate()); final Installment installmentFirstHalf = installmentMap.get(CURRENTYEAR_FIRST_HALF); final Installment installmentSecondHalf = installmentMap.get(CURRENTYEAR_SECOND_HALF); Ptdemand currPtDemand = getCurrentPTDemand(installmentFirstHalf, vacancyRemission.getBasicProperty().getActiveProperty().getPtDemandSet()); if (isApprovedInFirstHalf(vacancyRemission, installmentFirstHalf)) { halfYearTax = currentDemand.get(CURR_FIRSTHALF_DMD_STR); newTax = getNewTax(currPtDemand, newTax, installmentFirstHalf); } else { newTax = getNewTax(currPtDemand, newTax, installmentSecondHalf); } reportParams.put("financialYear", financialYear.getFinYearRange()); reportParams.put("halfYearTax", halfYearTax.toString()); reportParams.put("newTax", newTax.toString()); reportInput = new ReportRequest(VR_SPECIALNOTICE_TEMPLATE, vacancyRemission, reportParams); } if (reportInput != null) { reportInput.setPrintDialogOnOpenReport(true); reportInput.setReportFormat(ReportFormat.PDF); } return reportInput; }
From source file:org.fcrepo.integration.http.api.ExternalContentHandlerIT.java
private void checkExternalDataStreamResponseHeader(final HttpUriRequest req, final String contenLocation, final String shaValue) throws IOException { try (final CloseableHttpResponse response = execute(req)) { assertEquals(OK.getStatusCode(), response.getStatusLine().getStatusCode()); assertTrue(response.getHeaders(DIGEST).length > 0); if (StringUtils.isNoneBlank(contenLocation)) { assertEquals(contenLocation, getContentLocation(response)); }//from w ww .java2 s.co m final String digesterHeaderValue = response.getHeaders(DIGEST)[0].getValue(); assertTrue("Fixity Checksum doesn't match", digesterHeaderValue.equals(shaValue)); } }
From source file:org.jasig.cas.util.DefaultUniqueTicketIdGenerator.java
/** * Creates an instance of DefaultUniqueTicketIdGenerator with a specified * maximum length for the random portion. * * @param numericGenerator the numeric generator * @param randomStringGenerator the random string generator * @param suffix the value to append at the end of the unique id to ensure * uniqueness across JVMs./* w w w.j a v a 2 s.c o m*/ * @since 4.1.0 */ public DefaultUniqueTicketIdGenerator(final NumericGenerator numericGenerator, final RandomStringGenerator randomStringGenerator, final String suffix) { this.randomStringGenerator = randomStringGenerator; this.numericGenerator = numericGenerator; this.suffix = StringUtils.isNoneBlank(suffix) ? "-" + suffix : null; }
From source file:org.jbb.members.web.base.logic.AccountEditor.java
public boolean editAccountWithSuccess(EditMemberForm form, BindingResult bindingResult, Member member) { AccountDataToChange accountDataToChange = AccountDataToChange.builder().build(); if (!member.getEmail().getValue().equals(form.getEmail())) { Email email = Email.builder().value(form.getEmail()).build(); accountDataToChange.setEmail(Optional.of(email)); }//from www . jav a2 s . c o m if (StringUtils.isNoneBlank(form.getNewPassword())) { if (!form.getNewPassword().equals(form.getNewPasswordAgain())) { bindingResult.rejectValue("newPassword", "NP", "Passwords don't match"); return false; } Password password = Password.builder().value(form.getNewPassword().toCharArray()).build(); accountDataToChange.setNewPassword(Optional.of(password)); } try { memberService.updateAccount(member.getId(), accountDataToChange); } catch (AccountException e) { log.debug("Problem with updating account for username {} with data to change: {}", member.getUsername(), accountDataToChange, e); errorsBindingMapper.map(e.getConstraintViolations(), bindingResult); return false; } return true; }