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.kernel.api.services; 019 020import org.fcrepo.kernel.api.RdfStream; 021import org.fcrepo.kernel.api.identifiers.FedoraId; 022import org.fcrepo.kernel.api.models.FedoraResource; 023 024/** 025 * Service to retrieve references to repository resources. 026 * @author whikloj 027 * @since 6.0.0 028 */ 029public interface ReferenceService { 030 031 /** 032 * Return a RDF stream of statements referring to the provided resource. 033 * 034 * @param txId the transaction ID or null if no transaction. 035 * @param resource the resource to get inbound references for. 036 * @return RDF stream of inbound reference triples. 037 */ 038 RdfStream getInboundReferences(final String txId, final FedoraResource resource); 039 040 /** 041 * Delete all references from a resource to any other resource. 042 * 043 * @param txId the transaction ID 044 * @param resourceId the ID of the resource referencing others. 045 */ 046 void deleteAllReferences(final String txId, final FedoraId resourceId); 047 048 /** 049 * Parse the stream of triples for references, add any new ones and remove any missing ones. 050 * @param txId the transaction ID 051 * @param resourceId the subject ID of the triples. 052 * @param userPrincipal the user who's action is updating references. 053 * @param rdfStream the RDF stream. 054 */ 055 void updateReferences(final String txId, final FedoraId resourceId, final String userPrincipal, 056 final RdfStream rdfStream); 057 058 /** 059 * Commit any pending references. 060 * @param txId the transaction id. 061 */ 062 void commitTransaction(final String txId); 063 064 /** 065 * Rollback any pending references. 066 * @param txId the transaction id. 067 */ 068 void rollbackTransaction(final String txId); 069 070 /** 071 * Truncates the reference index. This should only be called when rebuilding the index. 072 */ 073 void reset(); 074}