001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.http.api; 019 020import com.google.common.annotations.VisibleForTesting; 021import org.fcrepo.kernel.api.models.FedoraResource; 022import org.slf4j.Logger; 023import org.springframework.context.annotation.Scope; 024 025import javax.ws.rs.DELETE; 026import javax.ws.rs.Path; 027import javax.ws.rs.PathParam; 028import javax.ws.rs.core.Response; 029 030import static javax.ws.rs.core.Response.noContent; 031import static org.slf4j.LoggerFactory.getLogger; 032 033/** 034 * CRUD operations on Fedora tombstones 035 * 036 * @author cbeer 037 */ 038@Scope("request") 039@Path("/{path: .*}/fcr:tombstone") 040public class FedoraTombstones extends FedoraBaseResource { 041 042 private static final Logger LOGGER = getLogger(FedoraTombstones.class); 043 044 @PathParam("path") protected String externalPath; 045 046 /** 047 * Default JAX-RS entry point 048 */ 049 public FedoraTombstones() { 050 super(); 051 } 052 053 /** 054 * Create a new FedoraNodes instance for a given path 055 * @param externalPath the external path 056 */ 057 @VisibleForTesting 058 public FedoraTombstones(final String externalPath) { 059 this.externalPath = externalPath; 060 } 061 062 063 /** 064 * Delete a tombstone resource (freeing the original resource to be reused) 065 * @return the free resource 066 */ 067 @DELETE 068 public Response delete() { 069 LOGGER.info("Delete tombstone: {}", resource()); 070 resource().delete(); 071 session.commit(); 072 return noContent().build(); 073 } 074 075 protected FedoraResource resource() { 076 return translator().convert(translator().toDomain(externalPath)); 077 } 078}