Search in sources :

Example 1 with LdifFileLoader

use of org.apache.directory.server.protocol.shared.store.LdifFileLoader in project aws-iam-ldap-bridge by denismo.

the class ApacheDSUtils method loadLdif.

public void loadLdif(String s) throws LdapException {
    if (getClass().getClassLoader().getResourceAsStream(s) == null) {
        s = new File("E:\\WS\\ApacheDS_AWSIAM\\dist\\apacheds\\" + s).getAbsolutePath();
    }
    LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), s);
    loader.execute();
}
Also used : LdifFileLoader(org.apache.directory.server.protocol.shared.store.LdifFileLoader) File(java.io.File)

Example 2 with LdifFileLoader

use of org.apache.directory.server.protocol.shared.store.LdifFileLoader in project spring-security by spring-projects.

the class ApacheDSContainer method importLdifs.

private void importLdifs() throws Exception {
    // Import any ldif files
    Resource[] ldifs;
    if (ctxt == null) {
        // Not running within an app context
        ldifs = new PathMatchingResourcePatternResolver().getResources(ldifResources);
    } else {
        ldifs = ctxt.getResources(ldifResources);
    }
    if (ldifs == null || ldifs.length == 0) {
        return;
    }
    if (ldifs.length == 1) {
        String ldifFile;
        try {
            ldifFile = ldifs[0].getFile().getAbsolutePath();
        } catch (IOException e) {
            ldifFile = ldifs[0].getURI().toString();
        }
        logger.info("Loading LDIF file: " + ldifFile);
        LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), new File(ldifFile), null, getClass().getClassLoader());
        loader.execute();
    } else {
        throw new IllegalArgumentException("More than one LDIF resource found with the supplied pattern:" + ldifResources + " Got " + Arrays.toString(ldifs));
    }
}
Also used : LdifFileLoader(org.apache.directory.server.protocol.shared.store.LdifFileLoader) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) File(java.io.File)

Aggregations

File (java.io.File)2 LdifFileLoader (org.apache.directory.server.protocol.shared.store.LdifFileLoader)2 IOException (java.io.IOException)1 Resource (org.springframework.core.io.Resource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1