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 */ 016package org.fcrepo.client.utils; 017 018import java.net.URI; 019 020import org.apache.http.HttpHeaders; 021import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 022 023/** 024 * HTTP copy 025 * 026 * @author sleroux 027 * @since 2015-06-03 028 **/ 029public class HttpCopy extends HttpEntityEnclosingRequestBase { 030 031 /** 032 * Create an HTTP COPY request. 033 * 034 * @param source 035 * Source URL. 036 * @param destination 037 * Destination URL. 038 **/ 039 public HttpCopy(final URI source, final URI destination) { 040 this.setHeader(HttpHeaders.DESTINATION, destination.toASCIIString()); 041 this.setURI(source); 042 } 043 044 /** 045 * Create an HTTP COPY request. 046 * 047 * @param source 048 * Source String URL. 049 * @param destination 050 * Destination String URL. 051 **/ 052 public HttpCopy(final String source, final String destination) { 053 this(URI.create(source), URI.create(destination)); 054 } 055 056 /** 057 * Returns the request method. 058 **/ 059 @Override 060 public String getMethod() { 061 return "COPY"; 062 } 063}