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

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

Introduction

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

Prototype

String EMPTY

To view the source code for org.apache.commons.lang StringUtils EMPTY.

Click Source Link

Document

The empty String "".

Usage

From source file:com.envision.envservice.rest.UserCasePriseResource.java

@POST
@Consumes(MediaType.APPLICATION_JSON)//from  w w  w .j  a  v a 2s  .  c o  m
@Produces(MediaType.APPLICATION_JSON)
public Response prise(UserCasePriseBo userCasePrise) throws Exception {
    HttpStatus status = HttpStatus.CREATED;
    String response = StringUtils.EMPTY;

    if (!checkParam(userCasePrise)) {
        status = HttpStatus.BAD_REQUEST;
        response = FailResult.toJson(Code.PARAM_ERROR, "?");
    } else {
        userCasePriseService.prise(userCasePrise);
    }

    return Response.status(status.value()).entity(response).build();
}

From source file:com.fengduo.spark.commons.component.ComponentController.java

@ExceptionHandler(Throwable.class)
public ModelAndView handleIOException(Throwable e) throws Throwable {

    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;//w ww .j  a  v a2 s  .  co  m
    }

    if (request == null && response == null) {
        throw e;
    }

    if (request == null && response != null) {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "utf-8"));
        pw.println("{\"code\":1,\"msg\":\",?!\",\"data\":\"\"}");
        pw.flush();
        pw.close();
    }

    ModelAndView mav = new ModelAndView();
    // if (InvokeTypeTools.isAjax(request)) {
    // return createJsonMav("server exceptin or error", ResultCode.ERROR, e.getMessage());
    // }

    mav.addObject("exception", e.getCause() == null ? StringUtils.EMPTY : e.getCause().toString());
    mav.addObject("msg", StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage());
    mav.addObject("stackTrace", e.getStackTrace().toString());
    if (request.getRequestURI() != null) {
        mav.addObject("url", request.getRequestURI().toString());
    }
    mav.setViewName("error");
    return mav;
}

From source file:hudson.plugins.debt.parser.DebtMessages.java

public String getMessage(final String ruleSetName, final String ruleName) {
    //        if (rules.containsKey(ruleSetName)) {
    //            RuleSet ruleSet = rules.get(ruleSetName);
    //            Rule rule = ruleSet.getRuleByName(ruleName);
    //            if (rule != null) {
    //                return createMessage(rule);
    //            }
    //        }/*from  w ww . j  av a 2s.  c  o m*/
    //        return "this is the message";
    return StringUtils.EMPTY;
}

From source file:au.org.ala.delta.intkey.ui.UIUtils.java

public static String getResourceString(String key, Object... arguments) {
    try {//from www .  j  a v a2 s  .  c  om
        Application app = Application.getInstance();
        String str = app.getContext().getResourceMap().getString(key);
        if (str == null) {
            return key;
        } else {
            return MessageFormat.format(str, arguments);
        }
    } catch (IllegalStateException ex) {
        // To help with unit testing, return empty string if the Swing
        // Application
        // Framework's Application
        // singleton is not
        // launched.
        return StringUtils.EMPTY;
    }
}

From source file:com.amalto.core.load.action.DefaultLoadAction.java

@Override
public void load(InputStream stream, XSDKey keyMetadata, XmlServer server, SaverSession session) {
    try {/* w  w w.  j a  v a 2 s .c  om*/
        SaverContextFactory contextFactory = session.getContextFactory();
        // If you wish to debug content sent to server evaluate 'IOUtils.toString(request.getInputStream())'
        XMLStreamTokenizer xmlStreamTokenizer = new XMLStreamTokenizer(stream, "UTF-8"); //$NON-NLS-1$
        while (xmlStreamTokenizer.hasMoreElements()) {
            String xmlData = xmlStreamTokenizer.nextElement();
            if (xmlData != null && xmlData.trim().length() > 0) {
                // Note: in case you wish to change the "replace" behavior, also check
                // com.amalto.core.save.context.BulkLoadContext.isReplace()
                DocumentSaverContext context = contextFactory.create(dataClusterName, dataModelName,
                        StringUtils.EMPTY, new ByteArrayInputStream(xmlData.getBytes("UTF-8")), //$NON-NLS-1$
                        true, // Always replace in this case (bulk load).
                        needValidate, false, false,
                        XSystemObjects.DC_PROVISIONING.getName().equals(dataClusterName)); // Enforce
                                                                                                                       // auto
                                                                                                                       // commit
                                                                                                                       // for
                                                                                                                       // users
                                                                                                                       // (for
                                                                                                                       // license
                                                                                                                       // checks).
                context.createSaver().save(session, context);
            }
        }
    } catch (Exception e) {
        try {
            session.abort();
        } catch (Exception rollbackException) {
            LOGGER.error("Exception occurred during transaction rollback.", rollbackException);
        }
        throw new RuntimeException(e);
    }
}

From source file:info.magnolia.cms.util.MetaDataUtil.java

/**
 * <p/>//from   w w w . j  a va2  s.  c  om
 * Returns the representation of the value as a String:
 * </p>
 *
 * @return String
 */
public String getPropertyValueString(String propertyName, String dateFormat) {
    try {
        if (propertyName.equals(MetaData.CREATION_DATE) || propertyName.equals(MetaData.LAST_MODIFIED)
                || propertyName.equals(MetaData.LAST_ACTION)) {
            Date date = this.getContent().getMetaData().getDateProperty(propertyName).getTime();
            return new DateUtil().getFormattedDate(date, dateFormat);
        } else if (propertyName.equals(MetaData.ACTIVATED)) {
            return Boolean.toString(this.getContent().getMetaData().getBooleanProperty(propertyName));
        } else {
            return this.getContent().getMetaData().getStringProperty(propertyName);
        }
    } catch (Exception e) {
        if (log.isDebugEnabled())
            log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$
    }
    return StringUtils.EMPTY;
}

From source file:io.cloudslang.worker.management.WorkerRegistration.java

protected String getLocalHostName() {
    String hostName = StringUtils.EMPTY;
    try {/*from   w w  w  .ja v a 2 s  .c  o m*/
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        // on Mac OS X with Java 7 calling 'getLocalHost()' can throw UnknownHostException
        // see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7180557
    }
    return hostName;
}

From source file:eu.europa.esig.dss.client.http.proxy.ProxyPreferenceManager.java

/**
 * Get list of excluded hosts of the HTTPS proxy
 *
 * @return comma separated list of hosts
 *//* ww  w .  ja  va2 s  . co  m*/
public String getHttpsExcludedHosts() {
    ProxyPreference preference = getProxyDao().get(ProxyKey.HTTPS_EXCLUDE);
    return preference != null ? preference.getValue() : StringUtils.EMPTY;
}

From source file:jenkins.plugins.coverity.CoverityBuildAction.java

/**
 * The data for the defects that were captured for this build.
 *//*  w  w  w  .j  a  v  a  2  s  .co  m*/
public List<CoverityDefect> getDefects() {

    // use defectIds field if specified to support older builds (pre-1.9.0 plugin)
    if (defectIds != null && !defectIds.isEmpty()) {
        List<CoverityDefect> covDefects = new ArrayList<>();
        for (Long defectId : defectIds) {
            covDefects.add(new CoverityDefect(defectId, "---", "View in Coverity Connect", StringUtils.EMPTY));
        }
        return covDefects;
    } else {
        return defects != null ? defects : new ArrayList<CoverityDefect>();
    }
}

From source file:info.magnolia.cms.beans.runtime.MultipartForm.java

public void addDocument(String atomName, String fileName, String type, File file) {
    if (StringUtils.isEmpty(fileName)) {
        return;//from  w w  w  .  jav  a 2 s.c  om
    }
    Document document = new Document();
    document.setAtomName(atomName);
    document.setType(type);
    document.setFile(file);
    if (!StringUtils.contains(fileName, ".")) { //$NON-NLS-1$
        document.setExtention(StringUtils.EMPTY);
        document.setFileName(fileName);
    } else {
        document.setExtention(StringUtils.substringAfterLast(fileName, ".")); //$NON-NLS-1$
        document.setFileName(StringUtils.substringBeforeLast(fileName, ".")); //$NON-NLS-1$
    }
    this.documents.put(atomName, document);
}