Address JavaFormat Violations in Ldif
Issue gh-743
This commit is contained in:
@@ -221,8 +221,9 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (this.resource.isOpen())
|
||||
if (this.resource.isOpen()) {
|
||||
this.reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() throws IOException {
|
||||
@@ -319,8 +320,8 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
"Record [dn: " + record.getDN() + "] does not conform to specification.");
|
||||
}
|
||||
}
|
||||
catch (NamingException e) {
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
catch (NamingException ex) {
|
||||
LOG.error("Error adding attribute to record", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -372,11 +373,11 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NamingException e) {
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
catch (NamingException ex) {
|
||||
LOG.error("Error adding attribute to record", ex);
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
catch (NoSuchElementException ex) {
|
||||
LOG.error("Error adding attribute to record", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -393,8 +393,8 @@ public class DefaultAttributeValidationPolicy implements AttributeValidationPoli
|
||||
return new LdapAttribute(id, LdapEncoder.parseBase64Binary(value), options, this.ordered);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new InvalidAttributeFormatException(e);
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new InvalidAttributeFormatException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,8 +412,8 @@ public class DefaultAttributeValidationPolicy implements AttributeValidationPoli
|
||||
return new LdapAttribute(id, new URI(value), options, this.ordered);
|
||||
}
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
throw new InvalidAttributeFormatException(e);
|
||||
catch (URISyntaxException ex) {
|
||||
throw new InvalidAttributeFormatException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,35 +44,37 @@ public class BasicSchemaSpecification implements Specification<LdapAttributes> {
|
||||
* @throws NamingException
|
||||
*/
|
||||
public boolean isSatisfiedBy(LdapAttributes record) throws NamingException {
|
||||
if (record != null) {
|
||||
if (record == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// DN is required.
|
||||
LdapName dn = record.getName();
|
||||
if (dn != null) {
|
||||
// DN is required.
|
||||
LdapName dn = record.getName();
|
||||
if (dn == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// objectClass definition is required.
|
||||
if (record.get("objectClass") != null) {
|
||||
// objectClass definition is required.
|
||||
if (record.get("objectClass") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Naming attribute is required.
|
||||
Rdn rdn = dn.getRdn(dn.size() - 1);
|
||||
if (record.get(rdn.getType()) != null) {
|
||||
Object object = record.get(rdn.getType()).get();
|
||||
// Naming attribute is required.
|
||||
Rdn rdn = dn.getRdn(dn.size() - 1);
|
||||
if (record.get(rdn.getType()) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object instanceof String) {
|
||||
String value = (String) object;
|
||||
if (((String) rdn.getValue()).equalsIgnoreCase(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (object instanceof byte[]) {
|
||||
String rdnValue = LdapEncoder.printBase64Binary(((String) rdn.getValue()).getBytes());
|
||||
String attributeValue = LdapEncoder.printBase64Binary((byte[]) object);
|
||||
if (rdnValue.equals(attributeValue))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Object object = record.get(rdn.getType()).get();
|
||||
|
||||
if (object instanceof String) {
|
||||
String value = (String) object;
|
||||
return ((String) rdn.getValue()).equalsIgnoreCase(value);
|
||||
}
|
||||
else if (object instanceof byte[]) {
|
||||
String rdnValue = LdapEncoder.printBase64Binary(((String) rdn.getValue()).getBytes());
|
||||
String attributeValue = LdapEncoder.printBase64Binary((byte[]) object);
|
||||
return rdnValue.equals(attributeValue);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user