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;
022
023/**
024 * Service used to manage membership properties of resources
025 *
026 * @author bbpennel
027 */
028public interface MembershipService {
029
030    /**
031     * Return an RdfStream of membership relations of which the provided resource is the subject.
032     *
033     * @param txId transaction id
034     * @param fedoraId the resource to get membership relations for.
035     * @return RdfStream of membership relations.
036     */
037    RdfStream getMembership(final String txId, final FedoraId fedoraId);
038
039    /**
040     * Update membership properties based on the creation of the specified resource
041     *
042     * @param txId transaction id
043     * @param fedoraId ID of the object created
044     */
045    void resourceCreated(final String txId, final FedoraId fedoraId);
046
047    /**
048     * Update membership properties based on the modification of the specified resource
049     *
050     * @param txId transaction id
051     * @param fedoraId ID of the object modified
052     */
053    void resourceModified(final String txId, final FedoraId fedoraId);
054
055    /**
056     * Update membership properties based on the deletion of the specified resource
057     *
058     * @param txId transaction id
059     * @param fedoraId ID of the object deleted
060     */
061    void resourceDeleted(final String txId, final FedoraId fedoraId);
062
063    /**
064     * Regenerate the membership history for specified Direct or Indirect container.
065     *
066     * @param txId transaction id
067     * @param containerId ID of the container
068     */
069    void populateMembershipHistory(final String txId, final FedoraId containerId);
070
071    /**
072     * Commit any pending membership changes.
073     * @param txId the transaction id.
074     */
075    void commitTransaction(final String txId);
076
077    /**
078     * Rollback any pending membership changes.
079     * @param txId the transaction id.
080     */
081    void rollbackTransaction(final String txId);
082
083    /**
084     * Truncates the membership index. This should only be called when rebuilding the index.
085     */
086    void reset();
087}