1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.server.core.interceptor.context; 21 22 23 import org.apache.directory.server.core.CoreSession; 24 import org.apache.directory.server.core.entry.ClonedServerEntry; 25 import org.apache.directory.shared.ldap.message.DeleteRequest; 26 import org.apache.directory.shared.ldap.message.MessageTypeEnum; 27 import org.apache.directory.shared.ldap.name.LdapDN; 28 29 30 /** 31 * A Delete context used for Interceptors. It contains all the informations 32 * needed for the delete operation, and used by all the interceptors 33 * 34 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 35 * @version $Rev$, $Date$ 36 */ 37 public class DeleteOperationContext extends AbstractChangeOperationContext 38 { 39 /** 40 * An optimization added to prevent redundant lookups of the deleted 41 * entry. 42 */ 43 private ClonedServerEntry entry; 44 45 46 /** 47 * Creates a new instance of DeleteOperationContext. 48 */ 49 public DeleteOperationContext( CoreSession session ) 50 { 51 super( session ); 52 } 53 54 55 /** 56 * Creates a new instance of DeleteOperationContext. 57 * 58 * @param deleteDn The entry DN to delete 59 */ 60 public DeleteOperationContext( CoreSession session, LdapDN deleteDn ) 61 { 62 super( session, deleteDn ); 63 } 64 65 66 public DeleteOperationContext( CoreSession session, DeleteRequest deleteRequest ) 67 { 68 super( session, deleteRequest.getName() ); 69 this.requestControls = deleteRequest.getControls(); 70 } 71 72 73 /** 74 * @return the operation name 75 */ 76 public String getName() 77 { 78 return MessageTypeEnum.DEL_REQUEST.name(); 79 } 80 81 82 /** 83 * @see Object#toString() 84 */ 85 public String toString() 86 { 87 return "DeleteContext for DN '" + getDn().getUpName() + "'"; 88 } 89 90 91 /** 92 * @param entry the entry to set 93 */ 94 public void setEntry( ClonedServerEntry entry ) 95 { 96 this.entry = entry; 97 } 98 99 100 /** 101 * Gets the deleted entry if cached. Must be called before deleting the 102 * entry when the entry member is null or this call will fail. 103 * 104 * @return the entry 105 */ 106 public ClonedServerEntry getEntry() 107 { 108 return entry; 109 } 110 }