/** * Creates a new search result entry protocol op from the provided entry. * * @param entry The entry to use to create this protocol op. */ public SearchResultEntryProtocolOp(final Entry entry) { dn = entry.getDN(); attributes = Collections.unmodifiableList(new ArrayList<Attribute>( entry.getAttributes())); }
/** * Creates a new search result entry protocol op from the provided entry. * * @param entry The entry to use to create this protocol op. */ public SearchResultEntryProtocolOp(final Entry entry) { dn = entry.getDN(); attributes = Collections.unmodifiableList(new ArrayList<Attribute>( entry.getAttributes())); }
/** * Creates a new joined entry with the specified DN, attributes, and nested * join results. * * @param entry The entry containing the DN and attributes to * use for this joined entry. It must not be * {@code null}. * @param nestedJoinResults A list of nested join results for this joined * entry. It may be {@code null} or empty if there * are no nested join results. */ public JoinedEntry(final Entry entry, final List<JoinedEntry> nestedJoinResults) { this(entry.getDN(), entry.getAttributes(), nestedJoinResults); }
/** * Creates a new LDIF add change record from the provided entry. * * @param entry The entry to use to create this LDIF add change record. * It must not be {@code null}. * @param controls The set of controls for this LDIF add change record. It * may be {@code null} or empty if there are no controls. */ public LDIFAddChangeRecord(final Entry entry, final List<Control> controls) { super(entry.getDN(), controls); final Collection<Attribute> attrs = entry.getAttributes(); attributes = new Attribute[attrs.size()]; final Iterator<Attribute> iterator = attrs.iterator(); for (int i=0; i < attributes.length; i++) { attributes[i] = iterator.next(); } }
/** * Writes debug information about monitor entry parsing, if appropriate. * * @param l The log level that should be used for the debug information. * @param e The entry containing the monitor information being parsed. * @param m The message to be written to the debug logger. */ public static void debugMonitor(final Level l, final Entry e, final String m) { if (debugEnabled && debugTypes.contains(DebugType.MONITOR)) { final StringBuilder buffer = new StringBuilder(); addCommonHeader(buffer, l); buffer.append("monitorEntryDN=\""); buffer.append(e.getDN()); buffer.append("\" message=\""); buffer.append(m); buffer.append('"'); logger.log(l, buffer.toString()); } }
/** * Creates a new LDIF add change record from the provided entry. * * @param entry The entry to use to create this LDIF add change record. * It must not be {@code null}. * @param controls The set of controls for this LDIF add change record. It * may be {@code null} or empty if there are no controls. */ public LDIFAddChangeRecord(final Entry entry, final List<Control> controls) { super(entry.getDN(), controls); final Collection<Attribute> attrs = entry.getAttributes(); attributes = new Attribute[attrs.size()]; final Iterator<Attribute> iterator = attrs.iterator(); for (int i=0; i < attributes.length; i++) { attributes[i] = iterator.next(); } }
/** * Writes debug information about monitor entry parsing, if appropriate. * * @param l The log level that should be used for the debug information. * @param e The entry containing the monitor information being parsed. * @param m The message to be written to the debug logger. */ public static void debugMonitor(final Level l, final Entry e, final String m) { if (debugEnabled && debugTypes.contains(DebugType.MONITOR)) { final StringBuilder buffer = new StringBuilder(); addCommonHeader(buffer, l); buffer.append("monitorEntryDN=\""); buffer.append(e.getDN()); buffer.append("\" message=\""); buffer.append(m); buffer.append('"'); logger.log(l, buffer.toString()); } }
/** * Creates a new add request to add the provided entry. * * @param entry The entry to be added. It must not be {@code null}. * @param controls The set of controls to include in the request. */ public AddRequest(final Entry entry, final Control[] controls) { super(controls); ensureNotNull(entry); dn = entry.getDN(); attributes = new ArrayList<Attribute>(entry.getAttributes()); }
/** * Creates a new add request to add the provided entry. * * @param entry The entry to be added. It must not be {@code null}. * @param controls The set of controls to include in the request. */ public AddRequest(final Entry entry, final Control[] controls) { super(controls); ensureNotNull(entry); dn = entry.getDN(); attributes = new ArrayList<Attribute>(entry.getAttributes()); }
/** * Creates a new add request to add the provided entry. * * @param entry The entry to be added. It must not be {@code null}. */ public AddRequest(final Entry entry) { super(null); ensureNotNull(entry); dn = entry.getDN(); attributes = new ArrayList<Attribute>(entry.getAttributes()); }
/** * Creates a new add request to add the provided entry. * * @param entry The entry to be added. It must not be {@code null}. */ public AddRequest(final Entry entry) { super(null); ensureNotNull(entry); dn = entry.getDN(); attributes = new ArrayList<Attribute>(entry.getAttributes()); }
/** * Composes an LDAP modify request for the specified entry. * * @param newEntry The new entry. Must not be {@code null}. * @param oldEntry The old entry. Must not be {@code null}. * * @return The modify request, {@code null} if no modification is * required (no diff between new and old entry). */ public ModifyRequest composeModifyRequest(final Entry newEntry, final Entry oldEntry) { String[] attrs = modifiableAttributes.toArray(new String[modifiableAttributes.size()]); List<Modification> mods = Entry.diff(oldEntry, newEntry, true, attrs); if (mods.isEmpty()) { // No diff return null; } return new ModifyRequest(newEntry.getDN(), mods); } }
/** * Composes an LDAP modify request for the specified entry. * * @param newEntry The new entry. Must not be {@code null}. * @param oldEntry The old entry. Must not be {@code null}. * * @return The modify request, {@code null} if no modification is * required (no diff between new and old entry). */ public ModifyRequest composeModifyRequest(final Entry newEntry, final Entry oldEntry) { String[] attrs = modifiableAttributes.toArray(new String[modifiableAttributes.size()]); List<Modification> mods = Entry.diff(oldEntry, newEntry, true, attrs); if (mods.isEmpty()) { // No diff return null; } return new ModifyRequest(newEntry.getDN(), mods); } }
/** * Creates a new compact entry from the provided entry. * * @param entry The entry to use to create this compact entry. It must not * be {@code null}. */ public CompactEntry(final Entry entry) { ensureNotNull(entry); dn = entry.getDN(); hashCode = -1; final Collection<Attribute> attrs = entry.getAttributes(); attributes = new CompactAttribute[attrs.size()]; final Iterator<Attribute> iterator = attrs.iterator(); for (int i=0; i < attributes.length; i++) { attributes[i] = new CompactAttribute(iterator.next()); } }
/** * Creates a new compact entry from the provided entry. * * @param entry The entry to use to create this compact entry. It must not * be {@code null}. */ public CompactEntry(final Entry entry) { ensureNotNull(entry); dn = entry.getDN(); hashCode = -1; final Collection<Attribute> attrs = entry.getAttributes(); attributes = new CompactAttribute[attrs.size()]; final Iterator<Attribute> iterator = attrs.iterator(); for (int i=0; i < attributes.length; i++) { attributes[i] = new CompactAttribute(iterator.next()); } }
/** * {@inheritDoc} */ public Entry transformEntry(final Entry e) { if (e == null) { return null; } final String dn; if (scrambleEntryDNs) { dn = scrambleDN(e.getDN()); } else { dn = e.getDN(); } final Collection<Attribute> originalAttributes = e.getAttributes(); final ArrayList<Attribute> scrambledAttributes = new ArrayList<Attribute>(originalAttributes.size()); for (final Attribute a : originalAttributes) { scrambledAttributes.add(scrambleAttribute(a)); } return new Entry(dn, schema, scrambledAttributes); }
/** * Sends a search result entry message to the client with the provided * information. * * @param messageID The message ID for the LDAP message to send to the * client. It must match the message ID of the associated * search request. * @param entry The entry to return to the client. It must not be * {@code null}. * @param controls The set of controls to include in the response message. * It may be empty or {@code null} if no controls should be * included. * * @throws LDAPException If a problem occurs while attempting to send the * provided response message. If an exception is * thrown, then the client connection will have been * terminated. */ public void sendSearchResultEntry(final int messageID, final Entry entry, final Control... controls) throws LDAPException { sendSearchResultEntry(messageID, new SearchResultEntryProtocolOp(entry.getDN(), new ArrayList<Attribute>(entry.getAttributes())), controls); }
/** * Creates a new LDAP entry from the provided {@link Entry} object. * * @param entry The entry to use to create this LDAP entry. */ public LDAPEntry(final Entry entry) { dn = entry.getDN(); attributeSet = new LDAPAttributeSet(); for (final Attribute a : entry.getAttributes()) { attributeSet.add(new LDAPAttribute(a)); } }
/** * Composes an LDAP modify request for the specified entry. * * @param entry The entry. Must not be {@code null}. * * @return The modify request. */ public ModifyRequest composeModifyRequest(final Entry entry) { List<Modification> mods = new LinkedList<>(); // Compose list of attribute updates List<String> updatedAttributes = new LinkedList<>(); for (com.unboundid.ldap.sdk.Attribute attr: entry.getAttributes()) { if (! getModifiableAttributes().contains(attr.getBaseName())) { continue; // skip, attribute not modifiable } // Flag attribute for replace, set new value(s) mods.add(new Modification(ModificationType.REPLACE, attr.getName(), attr.getValues())); updatedAttributes.add(attr.getBaseName()); // trim any lang-tags } // Compose list of attribute deletions for (String supAttr: getModifiableAttributes()) { if (! updatedAttributes.contains(supAttr)) { // Flag for delete via replace mods.add(new Modification(ModificationType.REPLACE, supAttr)); } } return new ModifyRequest(entry.getDN(), mods); }
/** * {@inheritDoc} */ public Entry transformEntry(final Entry e) { if (e == null) { return null; } // Iterate through the attributes in the entry and make any appropriate DN // replacements final Collection<Attribute> originalAttributes = e.getAttributes(); final ArrayList<Attribute> newAttributes = new ArrayList<Attribute>(originalAttributes.size()); for (final Attribute a : originalAttributes) { final String[] originalValues = a.getValues(); final String[] newValues = new String[originalValues.length]; for (int i=0; i < originalValues.length; i++) { newValues[i] = processString(originalValues[i]); } newAttributes.add(new Attribute(a.getName(), newValues)); } return new Entry(processString(e.getDN()), newAttributes); }