Search in sources :

Example 1 with LDIFChangeRecord

use of com.unboundid.ldif.LDIFChangeRecord in project oxCore by GluuFederation.

the class LdifDataUtility method validateLDIF.

public ResultCode validateLDIF(LDIFReader ldifReader, String dn) {
    String baseDn = dn.toLowerCase();
    ResultCode resultCode = ResultCode.SUCCESS;
    while (true) {
        // Read the next change to process
        LDIFChangeRecord ldifRecord = null;
        try {
            ldifRecord = ldifReader.readChangeRecord(true);
            if (ldifRecord != null) {
                if (StringHelper.isNotEmpty(baseDn)) {
                    if (!ldifRecord.getDN().toLowerCase().endsWith(baseDn)) {
                        resultCode = ResultCode.NOT_SUPPORTED;
                        break;
                    }
                }
            }
        } catch (LDIFException le) {
            log.info("Malformed ldif record " + ldifRecord);
            log.error("Malformed ldif record", le);
            resultCode = ResultCode.DECODING_ERROR;
            break;
        } catch (IOException ioe) {
            log.error("I/O error encountered while reading a change record", ioe);
            resultCode = ResultCode.LOCAL_ERROR;
            break;
        }
        // changes to be processed.
        if (ldifRecord == null) {
            break;
        }
    }
    return resultCode;
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) LDIFException(com.unboundid.ldif.LDIFException) IOException(java.io.IOException) ResultCode(com.unboundid.ldap.sdk.ResultCode)

Aggregations

ResultCode (com.unboundid.ldap.sdk.ResultCode)1 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)1 LDIFException (com.unboundid.ldif.LDIFException)1 IOException (java.io.IOException)1