892 refCtx.close();
893 }
894 }
895 } catch (IOException e) {
896 NamingException e2 = new CommunicationException(e.getMessage());
897 e2.setRootCause(e);
898 throw cont.fillInException(e2);
899 } catch (NamingException e) {
900 throw cont.fillInException(e);
901 }
902 }
903
904 /**
905 * Adds attributes from RDN to attrs if not already present.
906 * Note that if attrs already contains an attribute by the same name,
907 * or if the distinguished name is empty, then leave attrs unchanged.
908 *
909 * @param dn The non-null DN of the entry to add
910 * @param attrs The non-null attributes of entry to add
911 * @param directUpdate Whether attrs can be updated directly
912 * @returns Non-null attributes with attributes from the RDN added
913 */
914 private static Attributes addRdnAttributes(String dn, Attributes attrs,
915 boolean directUpdate) throws NamingException {
916
917 // Handle the empty name
918 if (dn.equals("")) {
919 return attrs;
920 }
921
922 // Parse string name into list of RDNs
923 List<Rdn> rdnList = (new LdapName(dn)).getRdns();
924
925 // Get leaf RDN
926 Rdn rdn = rdnList.get(rdnList.size() - 1);
927 Attributes nameAttrs = rdn.toAttributes();
928
929 // Add attributes of RDN to attrs if not already there
930 NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
931 Attribute nameAttr;
932 while (enum_.hasMore()) {
|
892 refCtx.close();
893 }
894 }
895 } catch (IOException e) {
896 NamingException e2 = new CommunicationException(e.getMessage());
897 e2.setRootCause(e);
898 throw cont.fillInException(e2);
899 } catch (NamingException e) {
900 throw cont.fillInException(e);
901 }
902 }
903
904 /**
905 * Adds attributes from RDN to attrs if not already present.
906 * Note that if attrs already contains an attribute by the same name,
907 * or if the distinguished name is empty, then leave attrs unchanged.
908 *
909 * @param dn The non-null DN of the entry to add
910 * @param attrs The non-null attributes of entry to add
911 * @param directUpdate Whether attrs can be updated directly
912 * @return Non-null attributes with attributes from the RDN added
913 */
914 private static Attributes addRdnAttributes(String dn, Attributes attrs,
915 boolean directUpdate) throws NamingException {
916
917 // Handle the empty name
918 if (dn.equals("")) {
919 return attrs;
920 }
921
922 // Parse string name into list of RDNs
923 List<Rdn> rdnList = (new LdapName(dn)).getRdns();
924
925 // Get leaf RDN
926 Rdn rdn = rdnList.get(rdnList.size() - 1);
927 Attributes nameAttrs = rdn.toAttributes();
928
929 // Add attributes of RDN to attrs if not already there
930 NamingEnumeration<? extends Attribute> enum_ = nameAttrs.getAll();
931 Attribute nameAttr;
932 while (enum_.hasMore()) {
|