Example usage for org.apache.commons.validator GenericValidator isBlankOrNull

List of usage examples for org.apache.commons.validator GenericValidator isBlankOrNull

Introduction

In this page you can find the example usage for org.apache.commons.validator GenericValidator isBlankOrNull.

Prototype

public static boolean isBlankOrNull(String value) 

Source Link

Document

Checks if the field isn't null and length of the field is greater than zero not including whitespace.

Usage

From source file:com.raven.loginn.service.AccountService.java

public Account loginByUserName(String userName, String password) throws Exception {
    if (GenericValidator.isBlankOrNull(userName)) {
        throw new WarningMessageException("Kullanc ad bo olamaz.");
    }//www  .  j av a2  s.  c  om
    if (GenericValidator.isBlankOrNull(password)) {
        throw new WarningMessageException("ifre boolamaz");
    }
    Account account = findAccountByUserName(userName);
    if (account == null) {
        throw new WarningMessageException("Bu kullanc ad ile kaytl kimse bulunamad");
    }
    if (!account.getUserName().equalsIgnoreCase(password)) {
        throw new WarningMessageException("ifre hatal");
    }
    return account;
}

From source file:de.hybris.platform.order.strategies.paymentinfo.impl.DefaultCreditCardNumberHelper.java

private boolean checkCardNumberAgainstRegexp(final String patternForCard, final String cardNumber) {
    if (GenericValidator.isBlankOrNull(patternForCard) || GenericValidator.isBlankOrNull(cardNumber)) {
        return false;
    } else {/*from ww  w.j  ava  2  s  .  c  om*/
        final Pattern compiledPattern = getOrCreateCachedCardPattern(patternForCard);
        return compiledPattern.matcher(cardNumber).matches();
    }
}

From source file:de.codecentric.janus.plugin.jira.JiraConfiguration.java

public static FormValidation doCheckPassword(@QueryParameter String value) {
    if (GenericValidator.isBlankOrNull(value)) {
        return FormValidation.error("Please provide a password.");
    }//w ww  . j  av a2  s .co  m

    return FormValidation.ok();
}

From source file:com.bia.monitor.service.EmailService.java

/**
 * 
 * @param subject cannot be empty
 * @return 
 */
private boolean isValidSubject(String subject) {
    return !GenericValidator.isBlankOrNull(subject);
}

From source file:com.sapienter.jbilling.server.user.validator.NoUserInfoInPasswordValidator.java

/**
 * Struts validator. This method retrieves the parameters necessary for
 * validating the password passed and calls basicValidation() to verify
 * the value. As such, it only represents a struts wrapper to
 * the core validation routine.// w  w w  . j a v a2s. c om
 * @return
 */
public static boolean validateNoUserInfo(Object bean, ValidatorAction va, Field field, ActionErrors errors,
        HttpServletRequest request, ServletContext application) {

    boolean retVal = true;

    try {

        String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

        if (!GenericValidator.isBlankOrNull(value)) {
            IUserSessionBean user = (IUserSessionBean) Context.getBean(Context.Name.USER_SESSION);
            ContactDTOEx dto = user.getPrimaryContactDTO(
                    (Integer) request.getSession().getAttribute(Constants.SESSION_USER_ID));
            if (dto != null) {
                retVal = basicValidation(dto, value);
            }
        }

    } catch (Exception e) {
        retVal = false;
    }
    if (retVal == false) {
        errors.add(field.getKey(), Resources.getActionError(request, va, field));
    }
    return retVal;
}

From source file:com.raven.loginn.service.AccountService.java

public Account loginByEmail(String email, String password) throws Exception {
    if (GenericValidator.isBlankOrNull(email)) {
        throw new WarningMessageException("Email bo olamaz");
    }//w  ww . ja v  a 2 s.  c  o  m
    if (!EmailValidator.getInstance().isValid(email)) {
        throw new WarningMessageException("Email format hatal.");
    }
    if (GenericValidator.isBlankOrNull(password)) {
        throw new WarningMessageException("ifre bo olamaz");
    }
    Account account = findAccountByEmail(email);
    if (account == null) {
        throw new WarningMessageException("Bu e-mail ile kaytl kimse bulunamad");
    }
    if (!account.getPassword().equalsIgnoreCase(password)) {
        throw new WarningMessageException("ifre hatal");
    }
    return account;
}

From source file:com.aoindustries.website.clientarea.accounting.AddCreditCardAction.java

@Override
public ActionForward executePermissionGranted(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response, SiteSettings siteSettings, Locale locale,
        Skin skin, AOServConnector aoConn) throws Exception {
    AddCreditCardForm addCreditCardForm = (AddCreditCardForm) form;

    String accounting = addCreditCardForm.getAccounting();
    if (GenericValidator.isBlankOrNull(accounting)) {
        // Redirect back to credit-card-manager it no accounting selected
        return mapping.findForward("credit-card-manager");
    }//w  w  w .j av  a 2s .c  o  m

    // Populate the initial details from the selected accounting code or authenticated user
    Business business = aoConn.getBusinesses().get(AccountingCode.valueOf(accounting));
    if (business == null)
        throw new SQLException("Unable to find Business: " + accounting);
    BusinessProfile profile = business.getBusinessProfile();
    if (profile != null) {
        addCreditCardForm.setFirstName(getFirstName(profile.getBillingContact(), locale));
        addCreditCardForm.setLastName(getLastName(profile.getBillingContact(), locale));
        addCreditCardForm.setCompanyName(profile.getName());
        addCreditCardForm.setStreetAddress1(profile.getAddress1());
        addCreditCardForm.setStreetAddress2(profile.getAddress2());
        addCreditCardForm.setCity(profile.getCity());
        addCreditCardForm.setState(profile.getState());
        addCreditCardForm.setPostalCode(profile.getZIP());
        addCreditCardForm.setCountryCode(profile.getCountry().getCode());
    } else {
        BusinessAdministrator thisBA = aoConn.getThisBusinessAdministrator();
        addCreditCardForm.setFirstName(getFirstName(thisBA.getName(), locale));
        addCreditCardForm.setLastName(getLastName(thisBA.getName(), locale));
        addCreditCardForm.setStreetAddress1(thisBA.getAddress1());
        addCreditCardForm.setStreetAddress2(thisBA.getAddress2());
        addCreditCardForm.setCity(thisBA.getCity());
        addCreditCardForm.setState(thisBA.getState());
        addCreditCardForm.setPostalCode(thisBA.getZIP());
        addCreditCardForm.setCountryCode(thisBA.getCountry() == null ? "" : thisBA.getCountry().getCode());
    }

    initRequestAttributes(request, getServlet().getServletContext());

    return mapping.findForward("success");
}

From source file:com.aoindustries.website.signup.ServerConfirmationCompletedActionHelper.java

/**
 * Stores to the database, if possible.  Sets request attributes "pkey" and "statusKey", both as String type.
 *///from w w  w.j a  va2  s  .  c o m
public static void storeToDatabase(ActionServlet servlet, HttpServletRequest request, AOServConnector rootConn,
        PackageDefinition packageDefinition, SignupBusinessForm signupBusinessForm,
        SignupTechnicalForm signupTechnicalForm, SignupBillingInformationForm signupBillingInformationForm,
        Map<String, String> options) {
    // Store to the database
    int pkey;
    String statusKey;
    try {
        CountryCode businessCountry = rootConn.getCountryCodes().get(signupBusinessForm.getBusinessCountry());
        CountryCode baCountry = GenericValidator.isBlankOrNull(signupTechnicalForm.getBaCountry()) ? null
                : rootConn.getCountryCodes().get(signupTechnicalForm.getBaCountry());

        pkey = rootConn.getSignupRequests().addSignupRequest(
                rootConn.getThisBusinessAdministrator().getUsername().getPackage().getBusiness().getBrand(),
                InetAddress.valueOf(request.getRemoteAddr()), packageDefinition,
                signupBusinessForm.getBusinessName(), signupBusinessForm.getBusinessPhone(),
                signupBusinessForm.getBusinessFax(), signupBusinessForm.getBusinessAddress1(),
                signupBusinessForm.getBusinessAddress2(), signupBusinessForm.getBusinessCity(),
                signupBusinessForm.getBusinessState(), businessCountry, signupBusinessForm.getBusinessZip(),
                signupTechnicalForm.getBaName(), signupTechnicalForm.getBaTitle(),
                signupTechnicalForm.getBaWorkPhone(), signupTechnicalForm.getBaCellPhone(),
                signupTechnicalForm.getBaHomePhone(), signupTechnicalForm.getBaFax(),
                signupTechnicalForm.getBaEmail(), signupTechnicalForm.getBaAddress1(),
                signupTechnicalForm.getBaAddress2(), signupTechnicalForm.getBaCity(),
                signupTechnicalForm.getBaState(), baCountry, signupTechnicalForm.getBaZip(),
                UserId.valueOf(signupTechnicalForm.getBaUsername()),
                signupBillingInformationForm.getBillingContact(),
                signupBillingInformationForm.getBillingEmail(),
                signupBillingInformationForm.getBillingUseMonthly(),
                signupBillingInformationForm.getBillingPayOneYear(), signupTechnicalForm.getBaPassword(),
                signupBillingInformationForm.getBillingCardholderName(),
                signupBillingInformationForm.getBillingCardNumber(),
                signupBillingInformationForm.getBillingExpirationMonth(),
                signupBillingInformationForm.getBillingExpirationYear(),
                signupBillingInformationForm.getBillingStreetAddress(),
                signupBillingInformationForm.getBillingCity(), signupBillingInformationForm.getBillingState(),
                signupBillingInformationForm.getBillingZip(), options);
        statusKey = "serverConfirmationCompleted.success";
    } catch (RuntimeException err) {
        servlet.log("Unable to store signup", err);
        pkey = -1;
        statusKey = "serverConfirmationCompleted.error";
    } catch (ValidationException err) {
        servlet.log("Unable to store signup", err);
        pkey = -1;
        statusKey = "serverConfirmationCompleted.error";
    } catch (IOException err) {
        servlet.log("Unable to store signup", err);
        pkey = -1;
        statusKey = "serverConfirmationCompleted.error";
    } catch (SQLException err) {
        servlet.log("Unable to store signup", err);
        pkey = -1;
        statusKey = "serverConfirmationCompleted.error";
    }

    request.setAttribute("statusKey", statusKey);
    request.setAttribute("pkey", Integer.toString(pkey));
}

From source file:com.aoindustries.website.signup.SignupBusinessForm.java

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = super.validate(mapping, request);
    if (errors == null)
        errors = new ActionErrors();
    if (GenericValidator.isBlankOrNull(businessName))
        errors.add("businessName", new ActionMessage("signupBusinessForm.businessName.required"));
    if (GenericValidator.isBlankOrNull(businessPhone))
        errors.add("businessPhone", new ActionMessage("signupBusinessForm.businessPhone.required"));
    if (GenericValidator.isBlankOrNull(businessAddress1))
        errors.add("businessAddress1", new ActionMessage("signupBusinessForm.businessAddress1.required"));
    if (GenericValidator.isBlankOrNull(businessCity))
        errors.add("businessCity", new ActionMessage("signupBusinessForm.businessCity.required"));
    if (GenericValidator.isBlankOrNull(businessCountry))
        errors.add("businessCountry", new ActionMessage("signupBusinessForm.businessCountry.required"));
    return errors;
}

From source file:com.surveypanel.form.validation.RequiredValidator.java

private boolean checkEmptyString(String value) {
    return GenericValidator.isBlankOrNull(value);
}