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.entry.Entry; 024import org.apache.directory.api.ldap.model.message.DeleteRequest; 025import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 026import org.apache.directory.api.ldap.model.message.controls.ManageDsaIT; 027import org.apache.directory.api.ldap.model.name.Dn; 028import org.apache.directory.server.core.api.CoreSession; 029import org.apache.directory.server.core.api.OperationEnum; 030 031 032/** 033 * A Delete context used for Interceptors. It contains all the informations 034 * needed for the delete operation, and used by all the interceptors 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public class DeleteOperationContext extends AbstractChangeOperationContext 039{ 040 /** 041 * Creates a new instance of DeleteOperationContext. 042 * 043 * @param session The session to use 044 */ 045 public DeleteOperationContext( CoreSession session ) 046 { 047 super( session ); 048 049 if ( session != null ) 050 { 051 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.DELETE ) ); 052 } 053 } 054 055 056 /** 057 * Creates a new instance of DeleteOperationContext. 058 * 059 * @param session The session to use 060 * @param deleteDn The entry Dn to delete 061 */ 062 public DeleteOperationContext( CoreSession session, Dn deleteDn ) 063 { 064 super( session, deleteDn ); 065 066 if ( session != null ) 067 { 068 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.DELETE ) ); 069 } 070 } 071 072 073 /** 074 * Creates a new instance of DeleteOperationContext. 075 * 076 * @param session The session to use 077 * @param deleteRequest The Delete operation to process 078 */ 079 public DeleteOperationContext( CoreSession session, DeleteRequest deleteRequest ) 080 { 081 super( session, deleteRequest.getName() ); 082 083 if ( session != null ) 084 { 085 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.DELETE ) ); 086 } 087 088 requestControls = deleteRequest.getControls(); 089 090 if ( requestControls.containsKey( ManageDsaIT.OID ) ) 091 { 092 ignoreReferral(); 093 } 094 else 095 { 096 throwReferral(); 097 } 098 } 099 100 101 /** 102 * @return the operation name 103 */ 104 public String getName() 105 { 106 return MessageTypeEnum.DEL_REQUEST.name(); 107 } 108 109 110 /** 111 * @see Object#toString() 112 */ 113 public String toString() 114 { 115 return "DeleteContext for Dn '" + getDn().getName() + "'"; 116 } 117 118 119 /** 120 * @param entry the entry to set 121 */ 122 public void setEntry( Entry entry ) 123 { 124 this.entry = entry; 125 } 126}