Example usage for org.apache.commons.httpclient HttpStatus SC_CREATED

List of usage examples for org.apache.commons.httpclient HttpStatus SC_CREATED

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_CREATED.

Prototype

int SC_CREATED

To view the source code for org.apache.commons.httpclient HttpStatus SC_CREATED.

Click Source Link

Document

<tt>201 Created</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:net.sf.sail.webapp.dao.sds.impl.SdsOfferingCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#generateRequest()
 *///from  w w  w  .  ja  v  a 2 s  .  c  om
@SuppressWarnings("unchecked")
public HttpPostRequest generateRequest() {
    final SdsOffering sdsOffering = this.getSdsOffering();
    final String bodyData = "<offering><name>" + sdsOffering.getName() + "</name><curnit-id>"
            + sdsOffering.getSdsCurnit().getSdsObjectId() + "</curnit-id><jnlp-id>"
            + sdsOffering.getSdsJnlp().getSdsObjectId() + "</jnlp-id></offering>";
    final String url = "/offering";
    return new HttpPostRequest(REQUEST_HEADERS_CONTENT, EMPTY_STRING_MAP, bodyData, url, HttpStatus.SC_CREATED);
}

From source file:com.epam.jaxb.XMLExternalEntityExpansionTest.java

@Test
public void testXXEAttackProtection() throws IOException {
    final Response response = wsSecuredRequestBuilder.grantClientCredentials().path("/sample/dto").build()
            .accept(MediaType.APPLICATION_XML)
            .post(Entity.xml("<!DOCTYPE user[<!ENTITY xxe SYSTEM \"" + xxeFile.getAbsolutePath()
                    + "\" >]><sampleWSDTO><value>value &xxe;</value></sampleWSDTO>"));

    if (response.getStatus() == HttpStatus.SC_CREATED) {
        final String wsdto = response.readEntity(String.class);
        Assert.doesNotContain(wsdto, "xxeAttackSuccessful");
    } else {/*from  w ww.ja  va 2 s.c  o m*/
        WebservicesAssert.assertResponse(Status.BAD_REQUEST, response);
    }

}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsWorkgroupUpdateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#generateRequest()
 *//*www . j av a 2  s.c  om*/
public HttpPutRequest generateRequest() {
    final SdsWorkgroup workgroup = this.getSdsWorkgroup();
    final String bodyData = "<workgroup><name>" + workgroup.getName() + "</name><offering-id>"
            + workgroup.getSdsOffering().getSdsObjectId() + "</offering-id></workgroup>";
    final String url = "/workgroup/" + workgroup.getSdsObjectId();
    return new HttpPutRequest(REQUEST_HEADERS_CONTENT, bodyData, url, HttpStatus.SC_CREATED);
}

From source file:com.bbva.arq.devops.ae.mirrorgate.jenkins.plugin.listener.MirrorGateListenerHelper.java

public void sendBuildFromJob(Job job, TaskListener listener) {
    if (job != null && job.getLastBuild() != null) {
        BuildStatus status = job.isBuildable() ? (job.getLastBuild().getResult() != null
                ? BuildStatus.fromString(job.getLastBuild().getResult().toString())
                : BuildStatus.InProgress) : BuildStatus.Deleted;
        BuildBuilder builder = new BuildBuilder(job.getLastBuild(), status);
        MirrorGateResponse response = getMirrorGateService().publishBuildData(builder.getBuildData());

        String msg;/* w ww  .j  av  a  2s.  c o  m*/
        Level level;
        if (response.getResponseCode() == HttpStatus.SC_CREATED) {
            msg = "MirrorGate: Published Build Complete Data. " + response.toString();
            level = Level.FINE;
        } else {
            msg = "MirrorGate: Build Status could not been sent to MirrorGate. Please contact with "
                    + "MirrorGate Team for further information (mirrorgate.group@bbva.com).";
            level = Level.WARNING;
        }

        if (listener != null && level == Level.FINE) {
            listener.getLogger().println("Follow this project's builds progress at: "
                    + createMirrorgateLink(builder.getBuildData().getProjectName()));

            listener.getLogger().println(msg);
        }
        LOG.log(level, msg);

        sendBuildExtraData(builder, listener);
    }
}

From source file:com.zimbra.cs.store.http.HttpStoreManager.java

@Override
public String writeStreamToStore(InputStream in, long actualSize, Mailbox mbox)
        throws IOException, ServiceException {
    MessageDigest digest;/*from w w w .  java  2 s .co m*/
    try {
        digest = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
        throw ServiceException.FAILURE("SHA-256 digest not found", e);
    }
    ByteUtil.PositionInputStream pin = new ByteUtil.PositionInputStream(new DigestInputStream(in, digest));

    HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
    PostMethod post = new PostMethod(getPostUrl(mbox));
    try {
        HttpClientUtil.addInputStreamToHttpMethod(post, pin, actualSize, "application/octet-stream");
        int statusCode = HttpClientUtil.executeMethod(client, post);
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED
                || statusCode == HttpStatus.SC_NO_CONTENT) {
            return getLocator(post, ByteUtil.encodeFSSafeBase64(digest.digest()), pin.getPosition(), mbox);
        } else {
            throw ServiceException.FAILURE("error POSTing blob: " + post.getStatusText(), null);
        }
    } finally {
        post.releaseConnection();
    }
}

From source file:net.bryansaunders.jee6divelog.service.rest.UserAccountApiIT.java

/**
 * Test registerUser with Valid User.//  w w w  . j  a  va  2s  .  co m
 */
@Test
@UsingDataSet("Empty.yml")
public void ifUserValidThenRegister() {
    final UserAccount newUser = new UserAccount();
    newUser.setFirstName("Test");
    newUser.setLastName("Testerson");
    newUser.setEmail("ifUserValidThenRegister@test.com");
    newUser.setPassword(VALID_PASSWORD);
    newUser.setPermissions(new LinkedHashSet<Permission>());
    newUser.setCreated(new Date());
    newUser.setUpdated(new Date());

    given().contentType(ContentType.JSON).body(newUser).expect().statusCode(HttpStatus.SC_CREATED).when()
            .post(RestApiTest.URL_ROOT + "/user/register/");
}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsWorkgroupCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#generateRequest()
 *//*from  w ww  . ja  va 2  s.co m*/
public HttpPostRequest generateRequest() {
    final SdsWorkgroup workgroup = this.getWorkgroup();
    final String bodyData = "<workgroup><name>" + workgroup.getName() + "</name><offering-id>"
            + workgroup.getSdsOffering().getSdsObjectId() + "</offering-id></workgroup>";
    final String url = "/workgroup";
    return new HttpPostRequest(REQUEST_HEADERS_CONTENT, EMPTY_STRING_MAP, bodyData, url, HttpStatus.SC_CREATED);
}

From source file:com.owncloud.android.operations.RestoreFileVersionOperation.java

private boolean isSuccess(int status) {
    return status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT;
}

From source file:com.hp.alm.ali.idea.services.AttachmentService.java

public String createAttachment(String filename, IndicatingInputStream is, long length, EntityRef parent) {
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/octet-stream");
    headers.put("Slug", filename);
    MyResultInfo result = new MyResultInfo();
    if (restService.post(new MyInputData(is, length, headers), result, "{0}s/{1}/attachments", parent.type,
            parent.id) != HttpStatus.SC_CREATED) {
        errorService.showException(new RestException(result.getBodyAsString(), result.getLocation()));
        return null;
    } else {//from   w  ww  .j a  v  a2  s. c o m
        EntityList list = EntityList.create(result.getBodyAsStream(), true);
        if (!list.isEmpty()) {
            Entity entity = list.get(0);
            entityService.fireEntityLoaded(entity, EntityListener.Event.CREATE);
            return entity.getPropertyValue("name");
        } else {
            return null;
        }
    }
}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsWorkgroupMemberCreateCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#generateRequest()
 *//*from w  w  w  .  jav  a2 s  .co  m*/
public HttpPostRequest generateRequest() {
    final SdsWorkgroup workgroup = this.getWorkgroup();
    final Set<SdsUser> membersList = workgroup.getMembers();
    String membersString = "";
    System.out.println(membersList.size());
    SdsUser sdsUser = membersList.iterator().next();
    System.out.println(sdsUser);
    System.out.println(sdsUser.getFirstName());
    for (SdsUser member : membersList) {
        membersString += "<workgroup-membership><sail-user-id>" + member.getSdsObjectId()
                + "</sail-user-id></workgroup-membership>";
    }
    final String bodyData = "<workgroup-memberships>" + membersString + "</workgroup-memberships>";
    final String url = "/workgroup/" + workgroup.getSdsObjectId() + "/membership";
    return new HttpPostRequest(REQUEST_HEADERS_CONTENT, EMPTY_STRING_MAP, bodyData, url, HttpStatus.SC_CREATED);
}