import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.osgi.useradmin.UserDirectoryException;
/** Basic LDIF parser. */
public class LdifParser {
- private final static Log log = LogFactory.getLog(LdifParser.class);
private final static Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
protected Attributes addAttributes(SortedMap<LdapName, Attributes> res, int lineNumber, LdapName currentDn,
"Attribute " + nameAttr.getID() + "=" + nameAttr.get() + " not consistent with DN " + currentDn
+ " (shortly before line " + lineNumber + " in LDIF file)");
Attributes previous = res.put(currentDn, currentAttributes);
- if (log.isTraceEnabled())
- log.trace("Added " + currentDn);
return previous;
} catch (NamingException e) {
throw new UserDirectoryException("Cannot add " + currentDn, e);
try {
in.close();
} catch (IOException e) {
- if (log.isTraceEnabled())
- log.error("Cannot close stream", e);
+ // silent
}
}
}
//
Attributes previous = addAttributes(res, lineNumber, currentDn, currentAttributes);
if (previous != null) {
- log.warn("There was already an entry with DN " + currentDn
- + ", which has been discarded by a subsequent one.");
+// log.warn("There was already an entry with DN " + currentDn
+// + ", which has been discarded by a subsequent one.");
}
}
currentDn = new LdapName(attributeValue.toString());
currentAttributes = new BasicAttributes(true);
} catch (InvalidNameException e) {
- log.error(attributeValue + " not a valid DN, skipping the entry.");
+// log.error(attributeValue + " not a valid DN, skipping the entry.");
currentDn = null;
currentAttributes = null;
}
try {
reader.close();
} catch (IOException e) {
- if (log.isTraceEnabled())
- log.error("Cannot close stream", e);
+ // silent
}
}
return res;