Example usage for org.apache.commons.lang StringUtils isBlank

List of usage examples for org.apache.commons.lang StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isBlank.

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:com.cy.driver.file.action.GetFileName.java

@Override
public String exec() {
    String driverId = request.getParameter("driverId");
    String fileType = request.getParameter("fileType");
    String filePath = "";
    String fileName = "";
    try {//from w w  w .j  a v a 2s .c o  m
        if (StringUtils.isBlank(driverId)) {
            sendResponseToJson("-9", "??");
            return ERROR;
        }

        int accFlag = operationLogService.checkUser(driverId);
        if (accFlag == 1) {
            log.info("?");
            sendResponseToJson("-9", "?");
            return ERROR;
        } else if (accFlag == 11) {
            log.info("");
            sendResponseToJson("-9", "");
            return ERROR;
        }

        log2Db(driverId);

        if (StringUtils.isBlank(fileType)) {
            sendResponseToJson("-8", "?");
            return ERROR;
        }
        DriverUserInfoDomain domain = driverUserCargoInfoService.selectUserBasicInfo(driverId);
        if (domain != null) {
            if ("1".equals(fileType)) {
                if (domain.getIdentityLicenseNumFront() != null) {
                    filePath = domain.getIdentityLicenseNumFront();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "?????" + fileName,
                                fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            } else if ("2".equals(fileType)) {
                if (domain.getIdentityLicenseNumContrary() != null) {
                    filePath = domain.getIdentityLicenseNumContrary();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "???????" + fileName,
                                fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            } else if ("3".equals(fileType)) {
                if (domain.getDriversLicense() != null) {
                    filePath = domain.getDriversLicense();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "???" + fileName, fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            } else if ("4".equals(fileType)) {
                if (domain.getDrivingLicense() != null) {
                    filePath = domain.getDrivingLicense();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "???" + fileName, fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            } else if ("5".equals(fileType)) {
                if (domain.getOperatingLicense() != null) {
                    filePath = domain.getOperatingLicense();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "?????" + fileName, fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            } else if ("6".equals(fileType)) {
                if (domain.getHeadPortrait() != null) {
                    filePath = domain.getHeadPortrait();
                    fileName = getFileName(filePath);
                    if (StringUtils.isNotBlank(fileName)) {
                        sendResponseToJson("1", "???" + fileName, fileName);
                    } else {
                        sendResponseToJson("0", "");
                        return ERROR;
                    }
                } else {
                    sendResponseToJson("0", "");
                    return ERROR;
                }
            }
        } else {
            sendResponseToJson("0", "?");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        try {
            sendResponseToJson("-8", e.getMessage());
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        e.printStackTrace();
    }
    return SUCCESS;
}

From source file:com.beginner.core.utils.Base64Util.java

/**
 * Base64//ww w .j  a va2 s . c o  m
 * @param ciphertext    
 * @param encoding       ??
 * @return             
 */
public static String decrypt(String ciphertext, String encoding) {
    if (StringUtils.isBlank(ciphertext))
        return ciphertext;
    try {
        return new String(decodeBase64(ciphertext.getBytes(encoding)));
    } catch (UnsupportedEncodingException e) {
        return ciphertext;
    }
}

From source file:com.prowidesoftware.swift.model.field.Field93CTest.java

/**
 * :S//S/S/[c]N//from   www.j  av  a  2s  .co  m
 */
@Test
public void testField93CString() {
    Field93C f = null;

    f = new Field93C("");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":/");
    //assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C("://");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":///");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":////");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//EEEEEEEE");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//EEEEEEEE/");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//EEEEEEEE/FFFF");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//EEEEEEEE/FFFF/E");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertEquals("E", f.getComponent4());
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93C(":DDDD//EEEEEEEE/FFFF/E1234");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertEquals("E", f.getComponent4());
    assertEquals("1234", f.getComponent5());
}

From source file:com.sp2p.system.interceptor.AppInterceptor.java

public String intercept(ActionInvocation invocation) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    String auth = (String) request.getParameter("auth");
    System.out.println("auth===========>" + auth);
    String info = (String) request.getParameter("info");
    System.out.println("info===========>" + info);
    Map<String, String> jsonMap = new HashMap<String, String>();
    if (StringUtils.isBlank(auth)) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "????");
        JSONUtils.printObject(jsonMap);/*from w  w  w. ja  v a  2s  . c  o m*/
        return null;
    }
    Map<String, String> map = (Map<String, String>) JSONObject.toBean(JSONObject.fromObject(auth),
            HashMap.class);
    String crc = map.get("crc");
    System.out.println("crc==>" + crc);
    if (StringUtils.isBlank(crc)) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "????");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    if (StringUtils.isBlank(map.get("time_stamp"))) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "?");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    long curTime = new Date().getTime();
    long client = sDateFormat.parse(map.get("time_stamp")).getTime();
    if (curTime - client >= 1 * 60 * 1000) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    if (StringUtils.isBlank(map.get("imei"))) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "imei?");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    if (StringUtils.isBlank(map.get("uid"))) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "uid?");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    if (StringUtils.isBlank(map.get("uid"))) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "uid?");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    StringBuilder keys = new StringBuilder();
    keys.append(map.get("time_stamp"));
    keys.append(map.get("imei"));
    keys.append(map.get("uid"));
    keys.append(Encrypt.MD5(map.get("uid") + "").substring(9, 20));
    keys.append(info);
    keys.append(APP_KEY);
    System.out.println("keys==>" + keys.toString());
    String md5Crc = Md5Utils.md5(keys.toString());
    System.out.println("MD5CRC==>" + md5Crc);
    if (!crc.equals(md5Crc)) {
        jsonMap.put("error", "-2");
        jsonMap.put("msg", "????");
        JSONUtils.printObject(jsonMap);
        return null;
    }
    ////      License.update(request, IConstants.LICENSE);
    //      if (!License.getAndoridAllow(request)&&!License.getiOSAllow(request)) {
    //      jsonMap.put("error", "1");
    //      jsonMap.put("msg", "");
    //      JSONUtils.printObject(jsonMap);
    //      return null;
    //      }
    return invocation.invoke();
}

From source file:eu.trentorise.game.task.GeneralClassificationTask.java

public GeneralClassificationTask(TaskSchedule schedule, String itemType, String classificationName) {
    super(classificationName, schedule);
    if (StringUtils.isBlank(itemType)) {
        throw new IllegalArgumentException("itemType cannot be null or empty");
    }// ww  w.  j ava  2s  .  c om
    this.itemType = itemType;
}

From source file:com.daimler.spm.b2bacceleratoraddon.forms.validation.PaymentTypeFormValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    if (object instanceof PaymentTypeForm) {
        final PaymentTypeForm paymentTypeForm = (PaymentTypeForm) object;

        if (CheckoutPaymentType.ACCOUNT.getCode().equals(paymentTypeForm.getPaymentType())
                && StringUtils.isBlank(paymentTypeForm.getCostCenterId())) {
            errors.rejectValue("costCenterId", "general.required");
        }//  www  .  j av a2s  . c  o  m
    }
}

From source file:com.haulmont.timesheets.global.TimeParser.java

public HoursAndMinutes parseToHoursAndMinutes(String time) {
    HoursAndMinutes result = new HoursAndMinutes();
    try {//from   w ww. j  a va 2s .  c  om
        if (StringUtils.isBlank(time)) {
            return new HoursAndMinutes();
        }

        if (time.contains(":")) {
            String[] parts = time.split(":");
            result.addHours(Integer.parseInt(parts[0]));
            result.addMinutes(Integer.parseInt(parts[1]));
            return result;
        }

        if (time.matches("[0-9]{1,2} +[0-9]{1,2}")) {
            String[] parts = time.split(" ");
            result.addHours(Integer.parseInt(parts[0]));
            result.addMinutes(Integer.parseInt(parts[1]));
            return result;
        }

        if (StringUtils.isNumeric(time)) {
            result.addHours(Integer.parseInt(time));
            return result;
        }

        result.addHours(findHours(time));
        result.addMinutes(findMinutes(time));

        return result;
    } catch (NumberFormatException e) {
        return result;
    }
}

From source file:io.kamax.mxisd.config.KeyConfig.java

@PostConstruct
public void build() {
    if (StringUtils.isBlank(getPath())) {
        throw new ConfigurationException("key.path");
    }/*  w  w  w. j a  v a  2  s . co  m*/
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilter.java

static List<IssuePattern> loadPatterns(final Configuration configuration) {
    if (configuration == null) {
        return Collections.emptyList();
    }/*from w  w w . ja v a  2 s .  c o  m*/

    final String fileLocation = configuration.getString(CONFIG_FILE);
    if (StringUtils.isBlank(fileLocation)) {
        LOGGER.info("no ignore file configured for property: {}", CONFIG_FILE);
        return Collections.emptyList();
    }

    final File ignoreFile = new File(fileLocation);
    if (!ignoreFile.isFile()) {
        LOGGER.error("could not find ignore file: {}", ignoreFile);
        return Collections.emptyList();
    }

    FileInputStream fis = null;
    try {
        fis = new FileInputStream(ignoreFile);
        final List<IssuePattern> patterns = IssuePattern.parse(fis);
        LOGGER.info("loaded {} violation ignores from {}", patterns.size(), ignoreFile);
        return patterns;
    } catch (final Exception e) {
        throw new SonarException("could not load ignores for file: " + ignoreFile, e);
    } finally {
        IOUtils.closeQuietly(fis);
    }
}

From source file:meta.paquete.base.PaqueteBase.java

@Override
public void setAlias(String alias) {
    String apodo = StringUtils.isBlank(alias) ? getClass().getSimpleName() : StringUtils.capitalize(alias);
    TipoModuloBase tipo = getTipo();//  w  ww.ja  va2 s .co  m
    String prefijo = tipo == null ? null : StringUtils.capitalize(tipo.name().toLowerCase());
    String mote = tipo == null || StringUtils.startsWithIgnoreCase(apodo, prefijo) ? apodo : prefijo + apodo;
    super.setAlias(mote);
}