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

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

Introduction

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

Prototype

public static boolean isNotEmpty(String str) 

Source Link

Document

Checks if a String is not empty ("") and not null.

Usage

From source file:com.gson.oauth.Group.java

/**
 * /* w w w.java 2 s  .c o m*/
 * @param accessToken
 * @param name ??30
 * @return
 * @throws Exception
 */
public JSONObject create(String accessToken, String name) throws Exception {
    Map<String, Object> group = new HashMap<String, Object>();
    Map<String, Object> nameObj = new HashMap<String, Object>();
    nameObj.put("name", name);
    group.put("group", nameObj);
    String post = JSONObject.toJSONString(group);
    String reslut = HttpKit.post(GROUP_CREATE_URI.concat(accessToken), post);
    if (StringUtils.isNotEmpty(reslut)) {
        return JSONObject.parseObject(reslut);
    }
    return null;
}

From source file:eionet.cr.dto.DeliveryFilterDTO.java

/**
 * Returns displayable label of the filter.
 *
 * @return/*from  ww  w  .j  ava2  s  . c o m*/
 */
public String getLabel() {
    List<String> list = new ArrayList<String>();
    if (StringUtils.isNotEmpty(obligationLabel)) {
        list.add(obligationLabel);
    }
    if (StringUtils.isNotEmpty(localityLabel)) {
        list.add(localityLabel);
    }
    if (StringUtils.isNotEmpty(year)) {
        list.add(year);
    }

    return StringUtils.join(list, ", ");
}

From source file:io.servicecomb.loadbalance.RuleClassNameExtentionsFactory.java

@Override
public boolean isSupport(String key, String value) {
    return ACCEPT_KEYS.contains(key) && StringUtils.isNotEmpty(value);
}

From source file:com.glaf.core.web.resource.WebResource.java

public static String getWebResourceRegin() {
    String contextPath = com.glaf.core.context.ApplicationContext.getContextPath();
    if (contextPath == null) {
        contextPath = "glaf";
    }/*  w  w w .ja v a 2s  .  co m*/
    if (contextPath.startsWith("/")) {
        contextPath = contextPath.substring(1);
    }
    if (StringUtils.isNotEmpty(conf.get("web.resource.region"))) {
        return contextPath + "_" + conf.get("web.resource.region");
    }
    return contextPath + "_" + WEB_RESOURCE_REGION;
}

From source file:demo.repository.UserSearchCriteriaGenerator.java

/**
 * {@inheritDoc}/*www.j  a  v a  2  s .co m*/
 */
@Override
protected CriteriaSpecification createCriteria(QueryMethodParameterInfo qmpi, //
        HibernateQueryExecutionContext context) {
    String firstname = qmpi.getParameterByParamName("fn", String.class);
    String lastname = qmpi.getParameterByParamName("ln", String.class);

    DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
    if (StringUtils.isNotEmpty(firstname)) {
        criteria.add(Restrictions.eq("firstname", firstname));
    }
    if (StringUtils.isNotEmpty(lastname)) {
        criteria.add(Restrictions.eq("lastname", lastname));
    }
    return criteria;
}

From source file:au.org.ala.delta.directives.ListingFile.java

protected void startFile(DeltaContext context) {

    OutputFileSelector fileManager = context.getOutputFileSelector();
    String credits = context.getCredits();
    if (StringUtils.isNotEmpty(credits)) {
        fileManager.listMessage(credits);
    }/*from   w  ww.j a v  a2  s.com*/
    String heading = context.getHeading(HeadingType.HEADING);
    if (heading != null) {
        fileManager.listMessage(heading);
    }

    heading = context.getHeading(HeadingType.SHOW);
    if (heading != null) {
        fileManager.listMessage(heading);
    }
}

From source file:com.haulmont.cuba.desktop.gui.data.DesktopContainerHelper.java

public static boolean hasExternalContextHelp(Component component) {
    if (component instanceof HasContextHelp) {
        final String contextHelp = ((HasContextHelp) component).getContextHelpText();
        return StringUtils.isNotEmpty(contextHelp) || component instanceof HasContextHelpClickHandler
                && ((HasContextHelpClickHandler) component).getContextHelpIconClickHandler() != null;
    }/*w ww .j av a 2 s . com*/
    return false;
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.DatePickerLoader.java

protected void loadResolution(DatePicker resultComponent, Element element) {
    final String resolution = element.attributeValue("resolution");
    if (StringUtils.isNotEmpty(resolution)) {
        DatePicker.Resolution res = DatePicker.Resolution.valueOf(resolution);
        resultComponent.setResolution(res);
    }//from  w  w  w.ja  v  a  2 s.co  m
}

From source file:com.clican.pluto.dataprocess.engine.processes.ParamProcessor.java

public void process(ProcessorContext context) throws DataProcessException {
    try {//  ww  w .jav a2 s. com
        if (paramBeanList != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            for (ParamBean pb : paramBeanList) {
                ParamType pt = ParamType.convert(pb.getType());
                Object value = null;
                if (pt == ParamType.STRING) {
                    value = pb.getParamValue();
                } else if (pt == ParamType.CLAZZ) {
                    value = Class.forName(pb.getParamValue());
                } else if (pt == ParamType.DATE) {
                    if (StringUtils.isNotEmpty(pb.getPattern())) {
                        value = new SimpleDateFormat(pb.getPattern()).parse(pb.getParamValue());
                    } else {
                        value = sdf.parse(pb.getParamValue());
                    }
                } else if (pt == ParamType.DOUBLE) {
                    value = Double.parseDouble(pb.getParamValue());
                } else if (pt == ParamType.LONG) {
                    value = Long.parseLong(pb.getParamValue());
                } else if (pt == ParamType.INTEGER) {
                    value = Integer.parseInt(pb.getParamValue());
                } else if (pt == ParamType.BOOLEAN) {
                    value = Boolean.parseBoolean(pb.getParamValue());
                } else if (pt == ParamType.LIST) {
                    List<String> list = new ArrayList<String>();
                    for (String s : pb.getParamValue().split(",")) {
                        list.add(s.trim());
                    }
                    value = list;
                } else {
                    throw new DataProcessException("?");
                }
                if (pb.isOverride()) {
                    context.setAttribute(pb.getParamName(), value);
                } else {
                    if (!context.contains(pb.getParamName())) {
                        context.setAttribute(pb.getParamName(), value);
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new DataProcessException("??", e);
    }

}

From source file:com.evolveum.midpoint.report.impl.ReportNodeUtils.java

public static InputStream executeOperation(String host, String fileName, String intraClusterHttpUrlPattern,
        String operation) throws CommunicationException, SecurityViolationException, ObjectNotFoundException,
        ConfigurationException, IOException {
    fileName = fileName.replaceAll("\\s", SPACE);
    InputStream inputStream = null;
    InputStream entityContent = null;
    LOGGER.trace("About to initiate connection with {}", host);
    try {/*ww  w .  j a v a2 s .c  o  m*/
        if (StringUtils.isNotEmpty(intraClusterHttpUrlPattern)) {
            LOGGER.trace("The cluster uri pattern: {} ", intraClusterHttpUrlPattern);
            URI requestUri = buildURI(intraClusterHttpUrlPattern, host, fileName);
            fileName = URLDecoder.decode(fileName, ReportTypeUtil.URLENCODING);

            LOGGER.debug("Sending request to the following uri: {} ", requestUri);
            HttpRequestBase httpRequest = buildHttpRequest(operation);
            httpRequest.setURI(requestUri);
            httpRequest.setHeader("User-Agent", ReportTypeUtil.HEADER_USERAGENT);
            HttpClient client = HttpClientBuilder.create().build();
            try (CloseableHttpResponse response = (CloseableHttpResponse) client.execute(httpRequest)) {
                HttpEntity entity = response.getEntity();
                Integer statusCode = response.getStatusLine().getStatusCode();

                if (statusCode == HttpStatus.SC_OK) {
                    LOGGER.debug("Response OK, the file successfully returned by the cluster peer. ");
                    if (entity != null) {
                        entityContent = entity.getContent();
                        ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
                        byte[] buffer = new byte[1024];
                        int len;
                        while ((len = entityContent.read(buffer)) > -1) {
                            arrayOutputStream.write(buffer, 0, len);
                        }
                        arrayOutputStream.flush();
                        inputStream = new ByteArrayInputStream(arrayOutputStream.toByteArray());
                    }
                } else if (statusCode == HttpStatus.SC_NO_CONTENT) {
                    if (HttpDelete.METHOD_NAME.equals(operation)) {
                        LOGGER.info("Deletion of the file {} was successful.", fileName);
                    }
                } else if (statusCode == HttpStatus.SC_FORBIDDEN) {
                    LOGGER.error("The access to the report with the name {} is forbidden.", fileName);
                    String error = "The access to the report " + fileName + " is forbidden.";
                    throw new SecurityViolationException(error);
                } else if (statusCode == HttpStatus.SC_NOT_FOUND) {
                    String error = "The report file " + fileName
                            + " was not found on the originating nodes filesystem.";
                    throw new ObjectNotFoundException(error);
                }
            } catch (ClientProtocolException e) {
                String error = "An exception with the communication protocol has occurred during a query to the cluster peer. "
                        + e.getLocalizedMessage();
                throw new CommunicationException(error);
            }
        } else {
            LOGGER.error(
                    "Cluster pattern parameters is empty, please refer to the documentation and set up the parameter value accordingly");
            throw new ConfigurationException(
                    "Cluster pattern parameters is empty, please refer to the documentation and set up the parameter value accordingly");
        }
    } catch (URISyntaxException e1) {
        throw new CommunicationException("Invalid uri syntax: " + e1.getLocalizedMessage());
    } catch (UnsupportedEncodingException e) {
        LOGGER.error("Unhandled exception when listing nodes");
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", e);
    } finally {
        IOUtils.closeQuietly(entityContent);
    }

    return inputStream;
}