View Javadoc

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  package org.apache.directory.server.core.entry;
20  
21  
22  import javax.naming.NamingException;
23  import javax.naming.directory.InvalidAttributeValueException;
24  
25  import org.apache.directory.shared.ldap.entry.EntryAttribute;
26  import org.apache.directory.shared.ldap.entry.client.ClientAttribute;
27  import org.apache.directory.shared.ldap.schema.AttributeType;
28  
29  
30  /**
31   * The server specific interface extending the EntryAttribute interface. It adds
32   * three more methods which are Server side.
33   *
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   * @version $Rev$, $Date$
36   */
37  public interface ServerAttribute extends ClientAttribute
38  {
39      /**
40       * Get the attribute type associated with this ServerAttribute.
41       *
42       * @return the attributeType associated with this entry attribute
43       */
44      AttributeType getAttributeType();
45  
46      
47      /**
48       * <p>
49       * Set the attribute type associated with this ServerAttribute.
50       * </p>
51       * <p>
52       * The current attributeType will be replaced. It is the responsibility of
53       * the caller to insure that the existing values are compatible with the new
54       * AttributeType
55       * </p>
56       *
57       * @param attributeType the attributeType associated with this entry attribute
58       */
59      void setAttributeType( AttributeType attributeType );
60  
61      
62      /**
63       * <p>
64       * Check if the current attribute type is of the expected attributeType
65       * </p>
66       * <p>
67       * This method won't tell if the current attribute is a descendant of 
68       * the attributeType. For instance, the "CN" serverAttribute will return
69       * false if we ask if it's an instance of "Name". 
70       * </p> 
71       *
72       * @param attributeId The AttributeType ID to check
73       * @return True if the current attribute is of the expected attributeType
74       * @throws InvalidAttributeValueException If there is no AttributeType
75       */
76      boolean instanceOf( String attributeId ) throws InvalidAttributeValueException;
77  
78  
79      /**
80       * <p>
81       * Set the user provided ID. If we have none, the upId is assigned
82       * the attributetype's name. If it does not have any name, we will
83       * use the OID.
84       * </p>
85       * <p>
86       * If we have an upId and an AttributeType, they must be compatible. :
87       *  - if the upId is an OID, it must be the AttributeType's OID
88       *  - otherwise, its normalized form must be equals to ones of
89       *  the attributeType's names.
90       * </p>
91       * <p>
92       * In any case, the ATtributeType will be changed. The caller is responsible for
93       * the present values to be compatoble with the new AttributeType.
94       * </p>
95       * 
96       * @param upId The attribute ID
97       * @param attributeType The associated attributeType
98       */
99      void setUpId( String upId, AttributeType attributeType );
100     
101     
102     /**
103      * <p>
104      * Checks to see if this attribute is valid along with the values it contains.
105      * </p>
106      * <p>
107      * An attribute is valid if :
108      * <li>All of its values are valid with respect to the attributeType's syntax checker</li>
109      * <li>If the attributeType is SINGLE-VALUE, then no more than a value should be present</li>
110      *</p>
111      * @return true if the attribute and it's values are valid, false otherwise
112      * @throws NamingException if there is a failure to check syntaxes of values
113      */
114     boolean isValid() throws NamingException;
115 
116 
117     /**
118      * Convert the ServerAttribute to a ClientAttribute
119      *
120      * @return An instance of ClientAttribute
121      */
122     EntryAttribute toClientAttribute();
123 }