Example usage for org.apache.commons.lang3 StringUtils isEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isEmpty.

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.hybris.integration.controller.TmcMessageController.java

/**
 * @param integrationId/*w ww  . j  av a  2s  .  co m*/
 * @param request
 * @return String result
 * @throws Exception
 */
@RequestMapping(value = "/openlistener/{integrationId}")
@OpenWriteBackOperation
public TmallAppResponse openListener(@PathVariable("integrationId") final String integrationId,
        @RequestBody final TmcMessageRequest request) throws Exception {

    if (request == null || StringUtils.isEmpty(request.getStatus())) {
        throw new TmallAppException(ResponseCode.MISSING_REQUIRED_PARAMS.getCode(), "Missing parameters.");
    }

    msgHanlder.setIntegrationId(integrationId);
    msgHanlder.setTmcMessageRequest(request);
    msgHanlder.execute();

    return new TmallAppResponse();
}

From source file:cz.muni.fi.editor.webapp.formatters.OrganizationFormatter.java

@Override
public OrganizationForm parse(String s, Locale locale) throws ParseException {
    if (StringUtils.isEmpty(s)) {
        throw new ParseException("Passed empty text", 0);
    } else {//from  www  . j a  va  2s.  co  m
        OrganizationForm of = new OrganizationForm();
        of.setId(Long.valueOf(s));

        return of;
    }
}

From source file:com.navercorp.pinpoint.collector.manage.controller.AuthInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    if (!isActive) {
        throwAuthException("not activating rest api for admin.");
    }/*from  w ww  .ja  v a2  s  . c o  m*/

    if (StringUtils.isEmpty(password)) {
        throwAuthException("not activating rest api for admin.");
    }

    String password = request.getParameter("password");
    if (!this.password.equals(password)) {
        throwAuthException("not matched admin password.");
    }

    return true;
}

From source file:app.controller.CollectionController.java

@PostMapping("/post")
public BaseResponse postCollection(@RequestHeader(value = "token") String token, @RequestBody Collection col) {
    String uid = mAuthService.checkIfAuthBind(token);
    if (StringUtils.isEmpty(uid)) {
        return ResultCode.error(ResultCode.USER_AUTH_FAILED);
    }//from   w w w  .  j av a2 s  .c o  m

    logger.info("collection: {}", col);
    mColService.postCollection(uid, col);
    return new BaseResponse();
}

From source file:com.hybris.mobile.lib.b2b.data.product.Product.java

public String getImageThumbnailUrl() {

    String thumbnail = super.getImageThumbnailUrl();

    if (StringUtils.isEmpty(thumbnail)) {
        thumbnail = getFirstVariantImage();
    }//from w w w.  j  a v  a2 s.c  o m

    return thumbnail;

}

From source file:com.hybris.integration.controller.ProductController.java

/**
 * @param integrationId/*  w w  w .  ja va 2  s  . c om*/
 * @param productId
 * @param num
 * @throws Exception
 */
@RequestMapping(value = "/productlisting", method = RequestMethod.POST)
public TmallAppResponse listing(final HttpServletRequest request) throws Exception {

    final String requestBody = IOUtils.toString(request.getInputStream(), "utf-8");
    if (StringUtils.isEmpty(requestBody)) {
        throw new TmallAppException(ResponseCode.REQUEST_BODY_IS_EMPTY.getCode(),
                ResponseCode.REQUEST_BODY_IS_EMPTY.getValue());
    }
    final JsonElement jsonElement = new JsonParser().parse(requestBody);
    final JsonObject jo = jsonElement.getAsJsonObject();

    if (jo.get("integrationId") == null || jo.get("productId") == null || jo.get("num") == null) {
        throw new TmallAppException(ResponseCode.MISSING_REQUIRED_PARAMS.getCode(),
                ResponseCode.MISSING_REQUIRED_PARAMS.getValue());
    }

    final String integrationId = jo.get("integrationId").getAsString();

    final String productId = jo.get("productId").getAsString();

    final Long num = jo.get("num").getAsLong();

    productService.listing(integrationId, productId, num);

    return new TmallAppResponse();
}

From source file:com.glaf.jbpm.factory.JbpmActionHandlerTypes.java

static Map<String, Class<?>> initializeHandlerTypes() {
    Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>();
    String resource = SystemProperties.getString("jbpm.actions");
    if (StringUtils.isEmpty(resource)) {
        resource = DEFAULT_CONFIG;//from   w ww .  j av  a  2s .  com
    }
    if (StringUtils.isNotEmpty(resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    String ext_resource = CustomProperties.getString("jbpm.actions");
    if (StringUtils.isNotEmpty(ext_resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    return types;
}

From source file:ch.cyberduck.core.identity.DefaultCredentialsIdentityConfiguration.java

@Override
public Credentials getCredentials(final String username) {
    // Ignore user but use username from host credentials
    final String user = host.getCredentials().getUsername();
    final String password = store.getPassword(host.getProtocol().getScheme(), host.getPort(),
            host.getHostname(), user);//from  w  w w.j  a  v a 2  s.  c o m
    if (StringUtils.isEmpty(password)) {
        return null;
    }
    return new Credentials(user, password);
}

From source file:com.evolveum.midpoint.web.component.prism.PrismHeaderPanel.java

protected void initHeaderLabel() {
    String displayName = getLabel();
    if (StringUtils.isEmpty(displayName)) {
        displayName = "displayName.not.set";
    }//from w w w  .j av a  2 s . c o  m
    StringResourceModel headerLabelModel = createStringResource(displayName);
    add(new Label(ID_LABEL, headerLabelModel));
}

From source file:net.ostis.scpdev.builder.scg.SCgContour.java

@Override
protected void encodeImpl(SCsWriter writer) throws IOException {
    String headerComment;//w ww  .j  a  va 2 s . c  o m
    if (identity.hasIdtf()) {
        headerComment = String.format("<contour idtf=\"%s\">", identity.getIdtf());
    } else {
        headerComment = String.format("<contour id=\"%s\">", systemId);
    }

    writer.comment(headerComment);
    writer.incTab();

    // May be this object is global and already writed
    if (StringUtils.isEmpty(identity.getMainId())) {
        String mainId = writer.node(identity.getIdtf(), SCsWriter.SC_CONST);
        identity.setMainId(mainId);
    }

    if (childs != null) {
        for (SCgObject child : childs) {
            writer.comment("<child>");
            writer.incTab();

            child.encode(writer);

            writer.arc(identity.getMainId(), null, SCsWriter.ARC_CONST_POS, child.getIdentity().getMainId());

            List<String> childIds = child.getGeneratedIds();
            if (childIds != null) {
                for (String childId : childIds) {
                    if (childId.equals("1_")) {
                        if (has1_) {
                            continue;
                        } else {
                            has1_ = true;
                        }
                    }

                    if (childId.equals("2_")) {
                        if (has2_) {
                            continue;
                        } else {
                            has2_ = true;
                        }
                    }

                    writer.arc(identity.getMainId(), null, SCsWriter.ARC_CONST_POS, childId);
                }
            }

            writer.decTab();
            writer.comment("</child>");
        }
    }

    writer.decTab();
    writer.comment("</contour>");
}