001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * 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, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.core.api; 021 022 023import java.util.concurrent.locks.ReadWriteLock; 024 025import org.apache.directory.api.ldap.model.entry.Entry; 026import org.apache.directory.api.ldap.model.exception.LdapException; 027import org.apache.directory.server.core.api.filtering.EntryFilteringCursor; 028import org.apache.directory.server.core.api.interceptor.context.AddOperationContext; 029import org.apache.directory.server.core.api.interceptor.context.BindOperationContext; 030import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext; 031import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext; 032import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext; 033import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext; 034import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext; 035import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext; 036import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext; 037import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext; 038import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext; 039import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext; 040import org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext; 041 042 043/** 044 * An interface used by the DirectoryService to isolate operations that can be 045 * performed on it. 046 * 047 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 048 */ 049public interface OperationManager 050{ 051 /** 052 * Add an entry into the backend, going through the interceptor chain 053 * 054 * @param addContext The context containing the information to process the addition 055 * @throws LdapException If the addition can't be processed successfully 056 */ 057 void add( AddOperationContext addContext ) throws LdapException; 058 059 060 /** 061 * Get the RooDse entry. 062 * 063 * @param getRootDseContext The getRootDse() context 064 * @return The rootDse if found 065 * @throws LdapException If we can't get back the rootDse entry 066 */ 067 Entry getRootDse( GetRootDseOperationContext getRootDseContext ) throws LdapException; 068 069 070 /** 071 * TODO document after determining if this method should be here. 072 * 073 * @param compareContext The Compare operation context 074 * @return <tt>true</tt> if the comparison is successful 075 * @throws LdapException If the compare failed 076 */ 077 boolean compare( CompareOperationContext compareContext ) throws LdapException; 078 079 080 /** 081 * TODO document after determining if this method should be here. 082 * 083 * @param deleteContext The Delete operation context 084 * @throws LdapException If the delete failed 085 */ 086 void delete( DeleteOperationContext deleteContext ) throws LdapException; 087 088 089 /** 090 * TODO document after determining if this method should be here. 091 * 092 * @param modifyContext The Modify operation context 093 * @throws LdapException If the modify failed 094 */ 095 void modify( ModifyOperationContext modifyContext ) throws LdapException; 096 097 098 /** 099 * TODO document after determining if this method should be here. 100 * 101 * @param searchContext The Search operation context 102 * @return The cursor on the found entries 103 * @throws LdapException If the search failed 104 */ 105 EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException; 106 107 108 /** 109 * TODO document after determining if this method should be here. 110 * 111 * @param lookupContext The Lookup operation context 112 * @return The found entry 113 * @throws LdapException If the lookup failed 114 */ 115 Entry lookup( LookupOperationContext lookupContext ) throws LdapException; 116 117 118 /** 119 * TODO document after determining if this method should be here. 120 * 121 * @param hasEntryContext The HasEntry operation context 122 * @return <tt>true</tt> if the entry exists 123 * @throws LdapException If the hasEntry failed 124 */ 125 boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException; 126 127 128 /** 129 * TODO document after determining if this method should be here. 130 * 131 * @param renameContext The Rename operation context 132 * @throws LdapException If the rename failed 133 */ 134 void rename( RenameOperationContext renameContext ) throws LdapException; 135 136 137 /** 138 * TODO document after determining if this method should be here. 139 * 140 * @param moveContext The Move operation context 141 * @throws LdapException If the move failed 142 */ 143 void move( MoveOperationContext moveContext ) throws LdapException; 144 145 146 /** 147 * TODO document after determining if this method should be here. 148 * 149 * @param moveAndRenameContext The MoveAndRename operation context 150 * @throws LdapException If the moveAndRename failed 151 */ 152 void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException; 153 154 155 /** 156 * TODO document after determining if this method should be here. 157 * 158 * @param bindContext The Bind operation context 159 * @throws LdapException If the bind failed 160 */ 161 void bind( BindOperationContext bindContext ) throws LdapException; 162 163 164 /** 165 * TODO document after determining if this method should be here. 166 * 167 * @param unbindContext The Unbind operation context 168 * @throws LdapException If the unbind failed 169 */ 170 void unbind( UnbindOperationContext unbindContext ) throws LdapException; 171 172 173 /** 174 * Acquires a WriteLock 175 */ 176 void lockWrite(); 177 178 179 /** 180 * Releases a WriteLock 181 */ 182 void unlockWrite(); 183 184 185 /** 186 * Acquires a ReadLock 187 */ 188 void lockRead(); 189 190 191 /** 192 * Releases a ReadLock 193 */ 194 void unlockRead(); 195 196 197 /** 198 * @return the OperationManager R/W lock 199 */ 200 ReadWriteLock getRWLock(); 201}