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.kernel.impl; 017 018import org.fcrepo.kernel.models.Tombstone; 019import org.fcrepo.kernel.exception.RepositoryRuntimeException; 020import org.slf4j.Logger; 021 022import javax.jcr.Node; 023import javax.jcr.RepositoryException; 024 025import static org.slf4j.LoggerFactory.getLogger; 026 027/** 028 * @author cabeer 029 * @since 10/16/14 030 */ 031public class TombstoneImpl extends FedoraResourceImpl implements Tombstone { 032 033 private static final Logger LOGGER = getLogger(TombstoneImpl.class); 034 035 /** 036 * Construct a {@link org.fcrepo.kernel.models.FedoraResource} from an existing JCR Node 037 * @param node an existing JCR node to treat as an fcrepo object 038 */ 039 public TombstoneImpl(final Node node) { 040 super(node); 041 } 042 043 044 /** 045 * Check if the node has a fedora:tombstone mixin 046 * @param node 047 * @return true if the node has the fedora object mixin 048 */ 049 public static boolean hasMixin(final Node node) { 050 try { 051 return node.isNodeType(FEDORA_TOMBSTONE); 052 } catch (final RepositoryException e) { 053 throw new RepositoryRuntimeException(e); 054 } 055 } 056 057 @Override 058 public void delete() { 059 try { 060 node.remove(); 061 } catch (final RepositoryException e) { 062 throw new RepositoryRuntimeException(e); 063 } 064 } 065}