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 static org.fcrepo.client.FedoraHeaderConstants.DESTINATION;
020
021import java.net.URI;
022
023import org.apache.http.client.methods.HttpRequestBase;
024import org.apache.http.util.Args;
025
026/**
027 * Builds a request to move a resource (and its subtree) to a new location
028 * 
029 * @author bbpennel
030 */
031public class MoveBuilder extends RequestBuilder {
032
033    /**
034     * Instantiate builder
035     * 
036     * @param sourceUrl uri of the resource
037     * @param destinationUrl uri for the new path for the moved resource
038     * @param client the client
039     */
040    protected MoveBuilder(final URI sourceUrl, final URI destinationUrl, final FcrepoClient client) {
041        super(sourceUrl, client);
042        Args.notNull(destinationUrl, "Destination URL");
043        // Add the required destination header to the request
044        request.addHeader(DESTINATION, destinationUrl.toString());
045    }
046
047    @Override
048    protected HttpRequestBase createRequest() {
049        return HttpMethods.MOVE.createRequest(targetUri);
050    }
051}