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.interceptor.context; 021 022 023import org.apache.directory.api.ldap.model.name.Dn; 024import org.apache.directory.server.core.api.CoreSession; 025import org.apache.directory.server.core.api.OperationEnum; 026 027 028/** 029 * A context for tracking lookup operations. Lookup operations will return a 030 * cloned server entry. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class LookupOperationContext extends FilteringOperationContext 035{ 036 /** flag to indicate if this search is done for replication */ 037 private boolean syncreplLookup; 038 039 /** 040 * Creates a new instance of LookupOperationContext. 041 * 042 * @param session The session to use 043 */ 044 public LookupOperationContext( CoreSession session ) 045 { 046 super( session ); 047 048 if ( session != null ) 049 { 050 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.LOOKUP ) ); 051 } 052 } 053 054 055 /** 056 * Creates a new instance of LookupOperationContext. 057 * 058 * @param session The session to use 059 * @param dn The Entry's Dn we are looking for 060 */ 061 public LookupOperationContext( CoreSession session, Dn dn ) 062 { 063 super( session, dn ); 064 065 if ( session != null ) 066 { 067 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.LOOKUP ) ); 068 } 069 } 070 071 072 /** 073 * Creates a new instance of LookupOperationContext. 074 * 075 * @param session The session to use 076 * @param returningAttributes The attributes to return 077 */ 078 public LookupOperationContext( CoreSession session, String... returningAttributes ) 079 { 080 super( session, returningAttributes ); 081 082 if ( session != null ) 083 { 084 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.LOOKUP ) ); 085 } 086 } 087 088 089 /** 090 * Creates a new instance of LookupOperationContext. 091 * 092 * @param session The session to use 093 * @param dn The Entry's Dn we are looking for 094 * @param returningAttributes The attributes to return 095 */ 096 public LookupOperationContext( CoreSession session, Dn dn, String... returningAttributes ) 097 { 098 super( session, dn, returningAttributes ); 099 100 if ( session != null ) 101 { 102 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.LOOKUP ) ); 103 } 104 } 105 106 107 /** 108 * @return the operation name 109 */ 110 public String getName() 111 { 112 return "Lookup"; 113 } 114 115 116 /** 117 * @return true if this is a syncrepl specific search 118 */ 119 public boolean isSyncreplLookup() 120 { 121 return syncreplLookup; 122 } 123 124 125 /** 126 * sets the flag to indicate if this is a synrepl specific search or not 127 * 128 * @param syncreplLookup <tt>true</tt> if it's a syncrepl search 129 */ 130 public void setSyncreplLookup( boolean syncreplLookup ) 131 { 132 this.syncreplLookup = syncreplLookup; 133 } 134}