Example usage for java.net HttpURLConnection HTTP_NO_CONTENT

List of usage examples for java.net HttpURLConnection HTTP_NO_CONTENT

Introduction

In this page you can find the example usage for java.net HttpURLConnection HTTP_NO_CONTENT.

Prototype

int HTTP_NO_CONTENT

To view the source code for java.net HttpURLConnection HTTP_NO_CONTENT.

Click Source Link

Document

HTTP Status-Code 204: No Content.

Usage

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

/**
 * {@inheritDoc}/*from w  w  w . j ava2s. c  om*/
 *
 * @deprecated Use {@link #postShare(String, String, String, String, VisibilityType, boolean)}
 */
@Override
@Deprecated
public void updateCurrentStatus(String statusText, boolean postToTwitter) {
    if (isNullOrEmpty(statusText)) {
        deleteCurrentStatus();
    } else {
        LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.POST_STATUS);
        if (postToTwitter) {
            builder.withParameter(ParameterNames.TWITTER_POST, "true");
        }
        String apiUrl = builder.buildUrl();
        Object status = OBJECT_FACTORY.createCurrentStatus(statusText);

        callApiMethod(apiUrl, marshallObject(status), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.PUT,
                HttpURLConnection.HTTP_NO_CONTENT);
    }
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

/**
 * {@inheritDoc}/* w w  w  .  ja va  2 s .com*/
 */
@Override
public void deleteCurrentStatus() {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.POST_STATUS);
    String apiUrl = builder.buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void unbookmarkJob(String jobId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.UNBOOKMARK_JOB);
    String apiUrl = builder.withField(ParameterNames.ID, jobId).buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:org.openecomp.sdnc.sli.aai.AAIService.java

@Override
protected boolean deleteRelationshipList(URL httpReqUrl, String json_text) throws AAIServiceException {
    if (httpReqUrl == null) {
        throw new NullPointerException();
    }//from w  ww .j  av  a2 s .  co  m

    boolean response = false;
    InputStream inputStream = null;

    try {
        HttpURLConnection con = getConfiguredConnection(httpReqUrl, HttpMethod.DELETE);

        //            SSLSocketFactory sockFact = CTX.getSocketFactory();
        //            con.setSSLSocketFactory( sockFact );
        OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
        osw.write(json_text);
        osw.flush();
        osw.close();

        LOGwriteFirstTrace("DELETE", httpReqUrl.toString());
        LOGwriteDateTrace("data", json_text);

        // Check for errors
        int responseCode = con.getResponseCode();
        if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
            inputStream = con.getInputStream();
        } else {
            inputStream = con.getErrorStream();
        }

        // Process the response
        LOG.debug("HttpURLConnection result:" + responseCode);
        if (inputStream == null)
            inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String line = null;

        ObjectMapper mapper = getObjectMapper();

        if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
            StringBuilder stringBuilder = new StringBuilder();

            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            LOGwriteEndingTrace(responseCode, "SUCCESS", stringBuilder.toString());
            response = true;
        } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
            LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", "Entry does not exist.");
            response = false;
        } else {
            ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
            LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
            throw new AAIServiceException(responseCode, errorresponse);
        }

    } catch (AAIServiceException aaiexc) {
        throw aaiexc;
    } catch (Exception exc) {
        LOG.warn("deleteRelationshipList", exc);
        throw new AAIServiceException(exc);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (Exception exc) {

            }
        }
    }
    return response;
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void unfollowCompany(String id) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.UNFOLLOW_COMPANY);
    String apiUrl = builder.withField(ParameterNames.ID, id).buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void deleteGroupSuggestion(String groupId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.DELETE_GROUP_SUGGESTION);
    String apiUrl = builder.withField(ParameterNames.ID, groupId).buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void deletePost(String postId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.DELETE_POST);
    String apiUrl = builder.withField(ParameterNames.ID, postId).buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void deletePostComment(String commentId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.DELETE_POST_COMMENT);
    String apiUrl = builder.withField(ParameterNames.ID, commentId).buildUrl();

    callApiMethod(apiUrl, null, null, HttpMethod.DELETE, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void followPost(String postId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.FOLLOW_POST);
    String apiUrl = builder.withField(ParameterNames.ID, postId).buildUrl();

    callApiMethod(apiUrl, "<is-following>true</is-following>", ApplicationConstants.CONTENT_TYPE_XML,
            HttpMethod.PUT, HttpURLConnection.HTTP_NO_CONTENT);
}

From source file:com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.java

@Override
public void likeGroupPost(String postId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.LIKE_POST);
    String apiUrl = builder.withField(ParameterNames.ID, postId).buildUrl();

    callApiMethod(apiUrl, "<is-liked>true</is-liked>", ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.PUT,
            HttpURLConnection.HTTP_NO_CONTENT);
}