1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.ldaptemplate.support;
18
19 import java.util.SortedSet;
20
21 import javax.naming.Name;
22 import javax.naming.directory.DirContext;
23
24 /***
25 * Interface for DirContextAdapter to simplify mock testing.
26 *
27 * @author Mattias Arthursson
28 */
29 public interface DirContextOperations extends DirContext,
30 AttributeModificationsAware {
31
32 /***
33 * Gets the update mode. The update mode should be <code>true</code> for a
34 * new entry and <code>true</code> for an existing entry that is being
35 * updated.
36 *
37 * @return update mode
38 */
39 public boolean isUpdateMode();
40
41 /***
42 * Creates a String array of the names of the attributes which have been
43 * changed.
44 *
45 * If this is a new entry, all set entries will be in the list. If this is
46 * an updated entry, only changed and removed entries will be in the array.
47 *
48 * @return Array of String
49 */
50 public String[] getNamesOfModifiedAttributes();
51
52 /***
53 * Get the value of a String attribute.
54 *
55 * @param name
56 * name of the attribute.
57 * @return the value of the attribute.
58 */
59 public String getStringAttribute(String name);
60
61 /***
62 * Get the value of an Object attribute.
63 *
64 * @param name
65 * name of the attribute.
66 * @return the attribute value as an object if it exists, or
67 * <code>null</code> otherwise.
68 */
69 public Object getObjectAttribute(String name);
70
71 /***
72 * Set the with the name <code>name</code> to the <code>value</code>.
73 *
74 * @param name
75 * name of the attribute.
76 * @param value
77 * value to set the attribute to.
78 */
79 public void setAttributeValue(String name, Object value);
80
81 /***
82 * Sets a multivalue attribute, disregarding the order of the values.
83 *
84 * If value is null or value.length == 0 then the attribute will be removed.
85 *
86 * If update mode, changes will be made only if the array has more or less
87 * objects or if one or more object has changed. Reordering the objects will
88 * not cause an update.
89 *
90 * @param name
91 * The id of the attribute.
92 * @param values
93 * Attribute values.
94 */
95 public void setAttributeValues(String name, Object[] values);
96
97 /***
98 * Sets a multivalue attribute.
99 *
100 * If value is null or value.length == 0 then the attribute will be removed.
101 *
102 * If update mode, changes will be made if the array has more or less
103 * objects or if one or more string has changed.
104 *
105 * Reordering the objects will only cause an update if orderMatters is set
106 * to true.
107 *
108 * @param name
109 * The id of the attribute.
110 * @param values
111 * Attribute values.
112 * @param orderMatters
113 * If <code>true</code>, it will be changed even if data was
114 * just reordered.
115 */
116 public void setAttributeValues(String name, Object[] values,
117 boolean orderMatters);
118
119 /***
120 * Update the attributes. This will mean that the getters
121 * (getStringAttribute methods) will return the updated values. Remove the
122 * attributes to be updated.
123 */
124 public void update();
125
126 /***
127 * Get all values of a String attribute.
128 *
129 * @param name
130 * name of the attribute.
131 *
132 * @return all registered values of the attribute.
133 */
134 public String[] getStringAttributes(String name);
135
136 /***
137 * Get all String values of the attribute as a SortedSet.
138 *
139 * @param name
140 * name of the attribute.
141 * @return a SortedSet containing all values of the attribute.
142 */
143 public SortedSet getAttributeSortedStringSet(String name);
144
145 /***
146 * Returns DN, for example <code>uid=some.user,ou=People,ou=EU</code>.
147 *
148 * @see DirContextAdapter#getNameInNamespace()
149 */
150 public Name getDn();
151
152 /***
153 * Set the dn of this entry.
154 *
155 * @param dn
156 * the dn.
157 */
158 public void setDn(Name dn);
159 }