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.camel; 017 018import java.net.URI; 019 020import org.apache.camel.CamelException; 021 022/** 023 * Represents a failure of the underlying HTTP client's interaction with fedora. 024 * 025 * @author Aaron Coburn 026 * @since January 8, 2015 027 */ 028public class FcrepoOperationFailedException extends CamelException { 029 030 private final URI url; 031 private final int statusCode; 032 private final String statusText; 033 034 /** 035 * Create an FcrepoOperationFailedException 036 * 037 * @param url the requested url 038 * @param statusCode the HTTP response code 039 * @param statusText the response message 040 */ 041 public FcrepoOperationFailedException(final URI url, final int statusCode, final String statusText) { 042 super("HTTP operation failed invoking " + (url != null ? url.toString() : "[null]") + 043 " with statusCode: " + statusCode + " and message: " + statusText); 044 this.url = url; 045 this.statusCode = statusCode; 046 this.statusText = statusText; 047 } 048 049 /** 050 * Return the requested url 051 * 052 * @return the requested URL 053 */ 054 public URI getUrl() { 055 return url; 056 } 057 058 /** 059 * Get the status code 060 * 061 * @return the HTTP status code 062 */ 063 public int getStatusCode() { 064 return statusCode; 065 } 066 067 /** 068 * Get the status text 069 * 070 * @return the status text for the error 071 */ 072 public String getStatusText() { 073 return statusText; 074 } 075}