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.services; 017 018import javax.jcr.Node; 019import javax.jcr.Session; 020 021/** 022 * @author bbpennel 023 * @author barmintor 024 * @since Feb 21, 2014 025 */ 026public interface Service<T> { 027 /** 028 * Test whether T exists at the given path in the 029 * repository 030 * 031 * @param path 032 * @return whether T exists at the given path 033 */ 034 public boolean exists(final Session session, final String path); 035 /** 036 * Retrieve an existing T instance by session and path 037 * 038 * @param path jcr path to the node 039 * @return retrieved T 040 */ 041 public T find(final Session session, final String path); 042 /** 043 * Retrieve a T instance by session and path 044 * 045 * @param path jcr path to the node 046 * @return retrieved T 047 */ 048 public T findOrCreate(final Session session, final String path); 049 /** 050 * Retrieve a T instance from a node 051 * 052 * @param node 053 * @return node as T 054 */ 055 public T cast(Node node); 056}