use of org.gluu.site.ldap.persistence.LdifDataUtility in project oxTrust by GluuFederation.
the class LdifService method exportLDIFFile.
public void exportLDIFFile(List<String> checkedItems, OutputStream output) throws LDAPException {
List<SearchResultEntry> result = null;
LDAPConnection connection = ldapEntryManager.getLdapOperationService().getConnection();
try {
LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
result = ldifDataUtility.getAttributeResultEntryLDIF(connection, checkedItems, attributeService.getDnForAttribute(null));
} catch (Exception ex) {
log.error("Failed to export ldif file: ", ex);
} finally {
ldapEntryManager.getLdapOperationService().releaseConnection(connection);
}
if (result != null && result.size() > 0) {
// Write all of the matching entries to LDIF.
LDIFWriter ldifWriter;
try {
ldifWriter = new LDIFWriter(output);
for (SearchResultEntry entry : result) {
ldifWriter.writeEntry(entry);
}
ldifWriter.close();
} catch (IOException e) {
throw new LdapMappingException("Error writing to file, try again", e);
}
}
}
use of org.gluu.site.ldap.persistence.LdifDataUtility in project oxTrust by GluuFederation.
the class LdifService method importLdifFileInLdap.
public ResultCode importLdifFileInLdap(InputStream is) throws LDAPException {
ResultCode result = ResultCode.UNAVAILABLE;
LDAPConnection connection = ldapEntryManager.getLdapOperationService().getConnection();
try {
LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
LDIFReader importLdifReader = new LDIFReader(is);
result = ldifDataUtility.importLdifFile(connection, importLdifReader);
importLdifReader.close();
} catch (Exception ex) {
log.error("Failed to import ldif file: ", ex);
} finally {
ldapEntryManager.getLdapOperationService().releaseConnection(connection);
}
return result;
}
use of org.gluu.site.ldap.persistence.LdifDataUtility in project oxTrust by GluuFederation.
the class LdifService method validateLdifFile.
public ResultCode validateLdifFile(InputStream is, String dn) throws LDAPException {
ResultCode result = ResultCode.UNAVAILABLE;
try {
LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
LDIFReader validateLdifReader = new LDIFReader(is);
result = ldifDataUtility.validateLDIF(validateLdifReader, dn);
validateLdifReader.close();
} catch (Exception ex) {
log.error("Failed to validate ldif file: ", ex);
}
return result;
}
Aggregations