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