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;
017
018import java.io.InputStream;
019import java.net.URI;
020
021/**
022 * Represents a response from a fedora repository using a {@link FcrepoClient}.
023 *
024 * @author Aaron Coburn
025 * @since October 20, 2014
026 */
027public class FcrepoResponse {
028
029    private URI url;
030
031    private int statusCode;
032
033    private URI location;
034
035    private InputStream body;
036
037    private String contentType;
038
039    /**
040     * Create a FcrepoResponse object from the http response
041     *
042     * @param url the requested URL
043     * @param statusCode the HTTP status code
044     * @param contentType the mime-type of the response
045     * @param location the location of a related resource
046     * @param body the response body stream
047     */
048    public FcrepoResponse(final URI url, final int statusCode,
049            final String contentType, final URI location, final InputStream body) {
050        this.setUrl(url);
051        this.setStatusCode(statusCode);
052        this.setLocation(location);
053        this.setContentType(contentType);
054        this.setBody(body);
055    }
056
057    /**
058     * url getter
059     *
060     * @return the requested URL
061     */
062    public URI getUrl() {
063        return url;
064    }
065
066    /**
067     * url setter
068     * 
069     * @param url the requested URL
070     */
071    public void setUrl(final URI url) {
072        this.url = url;
073    }
074
075    /**
076     * statusCode getter
077     *
078     * @return the HTTP status code
079     */
080    public int getStatusCode() {
081        return statusCode;
082    }
083
084    /**
085     * statusCode setter
086     * 
087     * @param statusCode the HTTP status code
088     */
089    public void setStatusCode(final int statusCode) {
090        this.statusCode = statusCode;
091    }
092
093    /**
094     * body getter
095     *
096     * @return the response body as a stream
097     */
098    public InputStream getBody() {
099        return body;
100    }
101
102    /**
103     * body setter
104     * 
105     * @param body the contents of the response body
106     */
107    public void setBody(final InputStream body) {
108        this.body = body;
109    }
110
111    /**
112     * location getter
113     * 
114     * @return the location of a related resource
115     */
116    public URI getLocation() {
117        return location;
118    }
119
120    /**
121     * location setter
122     * 
123     * @param location the value of a related resource
124     */
125    public void setLocation(final URI location) {
126        this.location = location;
127    }
128
129    /**
130     * contentType getter
131     *
132     * @return the mime-type of response
133     */
134    public String getContentType() {
135        return contentType;
136    }
137
138    /**
139     * contentType setter
140     *
141     * @param contentType the mime-type of the response
142     */
143    public void setContentType(final String contentType) {
144        this.contentType = contentType;
145    }
146}