Example usage for java.net HttpURLConnection HTTP_CREATED

List of usage examples for java.net HttpURLConnection HTTP_CREATED

Introduction

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

Prototype

int HTTP_CREATED

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

Click Source Link

Document

HTTP Status-Code 201: Created.

Usage

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

@Override
public void likePost(String networkUpdateId) {
    assertNotNullOrEmpty("network update id", networkUpdateId);

    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.NETWORK_UPDATE_LIKE);
    String apiUrl = builder.withField(ParameterNames.UPDATE_KEY, networkUpdateId).buildUrl();
    Object share = OBJECT_FACTORY.createIsLiked(true);

    callApiMethod(apiUrl, marshallObject(share), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.PUT,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void postShare(String commentText, String title, String description, String url, String imageUrl,
        VisibilityType visibilityType, boolean postToTwitter) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.POST_SHARE);
    if (postToTwitter) {
        builder.withParameter(ParameterNames.TWITTER_POST, "true");
    }/*from w  w  w  .j a va 2s .c o  m*/
    String apiUrl = builder.buildUrl();
    Share share = OBJECT_FACTORY.createShare();
    share.setComment(commentText);
    Content content = OBJECT_FACTORY.createContent();
    content.setSubmittedUrl(url);
    content.setSubmittedImageUrl(imageUrl);
    content.setTitle(title);
    content.setDescription(description);
    share.setContent(content);
    Visibility visibility = OBJECT_FACTORY.createVisibility();
    visibility.setCode(visibilityType);
    share.setVisibility(visibility);

    callApiMethod(apiUrl, marshallObject(share), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void reShare(String shareId, String commentText, VisibilityType visibilityType) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.RE_SHARE);
    String apiUrl = builder.buildUrl();
    Share share = OBJECT_FACTORY.createShare();
    share.setComment(commentText);/*from w w w  .j  a  va  2  s . c om*/
    Attribution attribution = OBJECT_FACTORY.createAttribution();
    Share refShare = OBJECT_FACTORY.createShare();
    refShare.setId(shareId);
    attribution.setShare(refShare);
    share.setAttribution(attribution);
    Visibility visibility = OBJECT_FACTORY.createVisibility();
    visibility.setCode(visibilityType);
    share.setVisibility(visibility);

    callApiMethod(apiUrl, marshallObject(share), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void unlikePost(String networkUpdateId) {
    assertNotNullOrEmpty("network update id", networkUpdateId);

    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.NETWORK_UPDATE_LIKE);
    String apiUrl = builder.withField(ParameterNames.UPDATE_KEY, networkUpdateId).buildUrl();
    Object share = OBJECT_FACTORY.createIsLiked(false);

    callApiMethod(apiUrl, marshallObject(share), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.PUT,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void bookmarkJob(String jobId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.BOOKMARK_JOB);
    String apiUrl = builder.buildUrl();
    JobBookmark bookmark = OBJECT_FACTORY.createJobBookmark();
    Job job = OBJECT_FACTORY.createJob();
    job.setId(jobId);//from  w w w.  j  a  v a2s  . com
    bookmark.setJob(job);
    callApiMethod(apiUrl, marshallObject(bookmark), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void followCompany(String id) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.FOLLOW_COMPANY);
    String apiUrl = builder.buildUrl();
    Company company = OBJECT_FACTORY.createCompany();
    company.setId(id);//  w  w w  .  j a va  2 s  . c o m
    callApiMethod(apiUrl, marshallObject(company), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void addPostComment(String postId, String commentText) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.ADD_POST_COMMENT);
    String apiUrl = builder.withField(ParameterNames.ID, postId).buildUrl();
    Comment comment = OBJECT_FACTORY.createComment();

    comment.setText(commentText);//from   w  w w.jav a  2  s.c  o m

    callApiMethod(apiUrl, marshallObject(comment), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void createPost(String groupId, String title, String summary) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.CREATE_POST);
    String apiUrl = builder.withField(ParameterNames.ID, groupId).buildUrl();
    Post post = OBJECT_FACTORY.createPost();
    post.setTitle(title);/*from  w ww .jav  a2 s. c  o  m*/
    post.setSummary(summary);

    callApiMethod(apiUrl, marshallObject(post), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void createPost(String groupId, String title, String summary, String submittedUrl, String postTitle,
        String postDescription, String thumbnailUrl) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.CREATE_POST);
    String apiUrl = builder.withField(ParameterNames.ID, groupId).buildUrl();
    Post post = OBJECT_FACTORY.createPost();
    post.setTitle(title);//w  w  w.  ja v  a2  s .c o m
    post.setSummary(summary);
    Content content = OBJECT_FACTORY.createContent();
    content.setSubmittedUrl(submittedUrl);
    content.setTitle(postTitle);
    content.setDescription(postDescription);
    content.setSubmittedImageUrl(thumbnailUrl);
    post.setContent(content);

    callApiMethod(apiUrl, marshallObject(post), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.POST,
            HttpURLConnection.HTTP_CREATED);
}

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

@Override
public void joinGroup(String groupId) {
    LinkedInApiUrlBuilder builder = createLinkedInApiUrlBuilder(LinkedInApiUrls.JOIN_GROUP);
    String apiUrl = builder.withField(ParameterNames.ID, groupId).buildUrl();
    GroupMembership membership = OBJECT_FACTORY.createGroupMembership();
    MembershipState state = OBJECT_FACTORY.createMembershipState();
    state.setCode(MembershipStateCode.MEMBER);
    membership.setMembershipState(state);

    callApiMethod(apiUrl, marshallObject(membership), ApplicationConstants.CONTENT_TYPE_XML, HttpMethod.PUT,
            HttpURLConnection.HTTP_CREATED);
}