001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006 007package org.fcrepo.kernel.api.cache; 008 009import java.net.URI; 010import java.util.List; 011import java.util.function.Supplier; 012 013import org.fcrepo.kernel.api.RdfStream; 014import org.fcrepo.kernel.api.identifiers.FedoraId; 015 016/** 017 * Cache of user RDF types. This cache has two levels. Types are cached at the session level as well as globally. 018 * This is necessary to support long-running transactions that can span multiple requests. 019 * 020 * @author pwinckles 021 */ 022public interface UserTypesCache { 023 024 /** 025 * Gets the user RDF types for the specified resource from the cache. First, the session's cache is checked. 026 * If the types were not found, then the global cache is checked. If not in either cache, then the rdfProvider 027 * is called to load the resource's RDF from which the types are parsed, cached, and returned. 028 * 029 * This method should NOT be called on binary resources. 030 * 031 * @param resourceId the id of the resource 032 * @param sessionId the id of the current session 033 * @param rdfProvider the provider that is called, if needed, to load the resource's rdf 034 * @return the resource's user RDF types 035 */ 036 List<URI> getUserTypes(final FedoraId resourceId, 037 final String sessionId, 038 final Supplier<RdfStream> rdfProvider); 039 040 /** 041 * Extracts the user RDF types from the RDF and caches them in the session level cache. 042 * 043 * @param resourceId the id of the resource 044 * @param rdf the resource's RDF 045 * @param sessionId the session to cache the types in 046 */ 047 void cacheUserTypes(final FedoraId resourceId, 048 final RdfStream rdf, 049 final String sessionId); 050 051 /** 052 * Caches the user RDF types in the session level cache. 053 * 054 * @param resourceId the id of the resource 055 * @param userTypes the resource's types 056 * @param sessionId the session to cache the types in 057 */ 058 void cacheUserTypes(final FedoraId resourceId, 059 final List<URI> userTypes, 060 final String sessionId); 061 062 /** 063 * Merges the session level cache into the global cache. 064 * 065 * @param sessionId the id of the session to merge 066 */ 067 void mergeSessionCache(final String sessionId); 068 069 /** 070 * Drops a session level cache without merging it into the global cache. 071 * 072 * @param sessionId the id of the session cache to drop 073 */ 074 void dropSessionCache(final String sessionId); 075 076}