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.sugaronrest.restapicalls.methodcalls.GetEntry.java

/**
 *  Gets entry [SugarCRM REST method - get_entry].
 *
 * @param url REST API Url./*from  w ww  .j  av  a2 s.  c o  m*/
 * @param sessionId Session identifier.
 * @param moduleName SugarCRM module name.
 * @param identifier The entity identifier.
 * @param selectFields Selected field list.
 * @return
 */
public static ReadEntryResponse run(String url, String sessionId, String moduleName, String identifier,
        List<String> selectFields) {

    ReadEntryResponse readEntryResponse = null;
    ErrorResponse errorResponse = null;

    String jsonRequest = new String();
    String jsonResponse = new String();

    ObjectMapper mapper = JsonObjectMapper.getMapper();

    try {
        Map<String, Object> requestData = new LinkedHashMap<String, Object>();
        requestData.put("session", sessionId);
        requestData.put("module_name", moduleName);
        requestData.put("id", identifier);
        requestData.put("select_fields", selectFields);
        requestData.put("link_name_to_fields_array", StringUtils.EMPTY);
        requestData.put("track_view", false);

        String jsonRequestData = mapper.writeValueAsString(requestData);

        Map<String, Object> request = new LinkedHashMap<String, Object>();
        request.put("method", "get_entry");
        request.put("input_type", "json");
        request.put("response_type", "json");
        request.put("rest_data", requestData);

        jsonRequest = mapper.writeValueAsString(request);

        request.put("rest_data", jsonRequestData);

        HttpResponse response = Unirest.post(url).fields(request).asString();

        if (response == null) {
            readEntryResponse = new ReadEntryResponse();
            errorResponse = ErrorResponse.format("An error has occurred!", "No data returned.");
            readEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            readEntryResponse.setError(errorResponse);
        } else {

            jsonResponse = response.getBody().toString();

            if (StringUtils.isNotBlank(jsonResponse)) {
                // First check if we have an error
                errorResponse = ErrorResponse.fromJson(jsonResponse);
                if (errorResponse == null) {
                    readEntryResponse = mapper.readValue(jsonResponse, ReadEntryResponse.class);
                }
            }

            if (readEntryResponse == null) {
                readEntryResponse = new ReadEntryResponse();
                readEntryResponse.setError(errorResponse);

                readEntryResponse.setStatusCode(HttpStatus.SC_OK);
                if (errorResponse == null) {
                    errorResponse.setStatusCode(errorResponse.getStatusCode());
                }
            } else {
                readEntryResponse.setStatusCode(HttpStatus.SC_OK);
            }
        }
    } catch (Exception exception) {
        readEntryResponse = new ReadEntryResponse();
        errorResponse = ErrorResponse.format(exception, exception.getMessage());
        readEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        readEntryResponse.setError(errorResponse);
    }

    readEntryResponse.setJsonRawRequest(jsonRequest);
    readEntryResponse.setJsonRawResponse(jsonResponse);

    return readEntryResponse;
}

From source file:info.magnolia.cms.gui.inline.ButtonEdit.java

public void setDefaultOnclick(HttpServletRequest request) {
    String nodeCollectionName = this.getNodeCollectionName();
    if (nodeCollectionName == null) {
        nodeCollectionName = StringUtils.EMPTY;
    }//from w  w w  .  j a  v a 2 s .  co m
    String nodeName = this.getNodeName();
    if (nodeName == null) {
        nodeName = StringUtils.EMPTY;
    }
    // todo: dynamic repository
    String repository = ContentRepository.WEBSITE;
    this.setOnclick("mgnlOpenDialog('" //$NON-NLS-1$
            + this.getPath() + "','" //$NON-NLS-1$
            + nodeCollectionName + "','" //$NON-NLS-1$
            + nodeName + "','" //$NON-NLS-1$
            + this.getParagraph() + "','" //$NON-NLS-1$
            + repository + "');"); //$NON-NLS-1$
}

From source file:com.hortonworks.streamline.streams.common.StreamlineEventImplTest.java

@Test
public void testGetId() throws Exception {
    Map<String, Object> map = new HashMap<>();
    map.put("a", "aval");
    map.put("b", "bval");

    StreamlineEvent event = new StreamlineEventImpl(map, org.apache.commons.lang.StringUtils.EMPTY);

    assertNotNull(UUID.fromString(event.getId()));
}

From source file:jp.co.opentone.bsol.framework.core.validation.constraints.impl.MinByteLengthValidator.java

@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
    if (value == null || StringUtils.EMPTY.equals(value)) {
        return true;
    }//  w  w  w .jav  a2  s  .co  m

    int length = getByteLength(value);
    if (min != 0 && length < min) {
        return false;
    }
    return true;
}

From source file:com.zb.app.web.controller.site.SiteController.java

/**
 * /*from   w w w  .ja va  2 s.  c  o  m*/
 * 
 * @param siteId
 * @return
 */
@RequestMapping(value = "/modifySite.htm", produces = "application/json")
@ResponseBody
public JsonResult modifySite(Long siteId) {
    if (Argument.isNotPositive(siteId)) {
        return JsonResultUtils.error("?!");
    }
    cookieManager.set(CookieKeyEnum.site_id, siteId + StringUtils.EMPTY);
    cookieManager.set(CookieKeyEnum.chugang_id, StringUtils.EMPTY);
    return JsonResultUtils.success();
}

From source file:com.microsoft.alm.plugin.external.commands.DeleteWorkspaceCommand.java

/**
 * There is no useful output from this command unless there is an error. This method parses the error and throws if
 * one exists./*from   w  w  w .j a  v a2  s  .co  m*/
 */
@Override
public String parseOutput(final String stdout, final String stderr) {
    // First check stderr for "not found" message
    if (StringUtils.containsIgnoreCase(stderr, "could not be found")) {
        // No workspace existed, so ignore the error
        return StringUtils.EMPTY;
    }
    // Throw if there was any other error
    super.throwIfError(stderr);

    // There is no useful output on success
    return StringUtils.EMPTY;
}

From source file:at.pagu.soldockr.core.query.CriteriaTest.java

@Test(expected = IllegalArgumentException.class)
public void testCriteriaForNullFieldName() {
    new Criteria(new SimpleField(StringUtils.EMPTY));
}

From source file:com.sugaronrest.SugarRestRequest.java

/**
 * Initializes a new instance of the SugarRestRequest class.
 *///from   w  ww .ja v a  2  s.c om
public SugarRestRequest() {
    this.setOptions(new Options());
    this.validationMessage = StringUtils.EMPTY;
}

From source file:com.laex.cg2d.model.model.ResourceFile.java

/**
 * Instantiates a new resource file.
 */
private ResourceFile() {
    this.resourceFile = StringUtils.EMPTY;
    this.resourceFileAbsolute = StringUtils.EMPTY;
}

From source file:jenkins.plugins.coverity.CoverityTool.CovImportMsvscaCommandTest.java

@Test
public void addMsvscaOutputFilesTest() throws IOException, InterruptedException {

    File analysisLog1 = new File("CodeAnalysisLog1.xml");
    File analysisLog2 = new File("CodeAnalysisLog2.xml");
    File[] outputFiles = new File[] { analysisLog1, analysisLog2 };

    setCoverityUtils_listFilesAsArray(outputFiles);

    FilePath workspace = new FilePath(new File("."));

    InvocationAssistance invocationAssistance = new InvocationAssistanceBuilder().withCSharpMsvsca(true)
            .build();// w w w .j a va  2 s  . c  o  m
    CoverityPublisher publisher = new CoverityPublisherBuilder().withInvocationAssistance(invocationAssistance)
            .build();

    Command covImportMsvscaCommand = new CovImportMsvscaCommand(build, launcher, listener, publisher,
            StringUtils.EMPTY, envVars, workspace);
    setExpectedArguments(new String[] { "cov-import-msvsca", "--dir", "TestDir", "--append",
            analysisLog1.getAbsolutePath(), analysisLog2.getAbsolutePath() });
    covImportMsvscaCommand.runCommand();
    consoleLogger.verifyLastMessage(
            "[Coverity] cov-import-msvsca command line arguments: " + actualArguments.toString());
}