001/**
002 * Copyright 2014 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.kernel.exception;
017
018import org.fcrepo.kernel.models.FedoraResource;
019
020/**
021 * Exception when a Tombstone object is used where a real object is expected
022 *
023 * @author cabeer
024 * @since 10/16/14
025 */
026public class TombstoneException extends RepositoryRuntimeException {
027
028    private static final long serialVersionUID = 1L;
029
030    private final FedoraResource fedoraResource;
031    private final String uri;
032
033    /**
034     * Construct a new tombstone exception for a resource
035     * @param fedoraResource
036     */
037    public TombstoneException(final FedoraResource fedoraResource) {
038        this(fedoraResource, null);
039    }
040
041    /**
042     * Create a new tombstone exception with a URI to the tombstone resource
043     * @param fedoraResource
044     * @param uri
045     */
046    public TombstoneException(final FedoraResource fedoraResource, final String uri) {
047        super("Discovered tombstone resource at " + fedoraResource);
048        this.fedoraResource = fedoraResource;
049        this.uri = uri;
050    }
051
052    /**
053     * Get the tombstone resource
054     * @return
055     */
056    public FedoraResource getResource() {
057        return fedoraResource;
058    }
059
060    /**
061     * Get a URI to the tombstone resource
062     * @return
063     */
064    public String getURI() {
065        return uri;
066    }
067}