001/** 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.fcrepo.client; 018 019import java.io.File; 020import java.io.IOException; 021import java.io.InputStream; 022import java.net.URI; 023 024import org.apache.http.client.methods.HttpRequestBase; 025 026/** 027 * Builds a PUT request for interacting with the Fedora HTTP API in order to create a resource with a specified path, 028 * or replace the triples associated with a resource with the triples provided in the request body. 029 * 030 * @author bbpennel 031 */ 032public class PutBuilder extends BodyRequestBuilder { 033 034 /** 035 * Instantiate builder 036 * 037 * @param uri uri of the resource this request is being made to 038 * @param client the client 039 */ 040 public PutBuilder(final URI uri, final FcrepoClient client) { 041 super(uri, client); 042 } 043 044 @Override 045 protected HttpRequestBase createRequest() { 046 return HttpMethods.PUT.createRequest(targetUri); 047 } 048 049 @Override 050 public PutBuilder body(final InputStream stream, final String contentType) { 051 return (PutBuilder) super.body(stream, contentType); 052 } 053 054 @Override 055 public PutBuilder body(final File file, final String contentType) throws IOException { 056 return (PutBuilder) super.body(file, contentType); 057 } 058 059 @Override 060 public PutBuilder body(final InputStream stream) { 061 return (PutBuilder) super.body(stream); 062 } 063 064 @Override 065 public PutBuilder ifMatch(final String etag) { 066 return (PutBuilder) super.ifMatch(etag); 067 } 068 069 @Override 070 public PutBuilder ifUnmodifiedSince(final String modified) { 071 return (PutBuilder) super.ifUnmodifiedSince(modified); 072 } 073 074 @Override 075 public PutBuilder digest(final String digest) { 076 return (PutBuilder) super.digest(digest); 077 } 078}