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.message.MessageTypeEnum; 024import org.apache.directory.api.ldap.model.name.Dn; 025import org.apache.directory.server.core.api.CoreSession; 026import org.apache.directory.server.core.api.OperationEnum; 027 028 029/** 030 * A Entry context used for Interceptors. It contains all the informations 031 * needed for the hasEntry operation, and used by all the interceptors 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class HasEntryOperationContext extends AbstractOperationContext 036{ 037 /** 038 * Creates a new instance of HasEntryOperationContext. 039 * 040 * @param session The session to use 041 */ 042 public HasEntryOperationContext( CoreSession session ) 043 { 044 super( session ); 045 046 if ( session != null ) 047 { 048 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.HAS_ENTRY ) ); 049 } 050 } 051 052 053 /** 054 * Creates a new instance of HasEntryOperationContext. 055 * 056 * @param session The session to use 057 * @param entryDn The Entry Dn we want to know if it exists 058 */ 059 public HasEntryOperationContext( CoreSession session, Dn entryDn ) 060 { 061 super( session, entryDn ); 062 063 if ( session != null ) 064 { 065 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.HAS_ENTRY ) ); 066 } 067 } 068 069 070 /** 071 * @return the operation name 072 */ 073 public String getName() 074 { 075 return MessageTypeEnum.ADD_REQUEST.name(); 076 } 077 078 079 /** 080 * @see Object#toString() 081 */ 082 public String toString() 083 { 084 return "HasEntryContext for Dn '" + getDn().getName() + "'"; 085 } 086}