use of org.forgerock.opendj.ldif.LDIFEntryReader in project OpenAM by OpenRock.
the class OpenDJUpgrader method findBaseDNs.
private List<DN> findBaseDNs() throws IOException {
final List<DN> baseDNs = new LinkedList<DN>();
final SearchRequest request = LDAPRequests.newSearchRequest("cn=backends,cn=config", SearchScope.WHOLE_SUBTREE, "(objectclass=ds-cfg-backend)", "ds-cfg-base-dn");
try (LDIFEntryReader reader = new LDIFEntryReader(new FileInputStream(installRoot + "/config/config.ldif"))) {
final EntryReader filteredReader = LDIF.search(reader, request);
while (filteredReader.hasNext()) {
final Entry entry = filteredReader.readEntry();
final Attribute values = entry.getAttribute("ds-cfg-base-dn");
if (values != null) {
for (final ByteString value : values) {
baseDNs.add(DN.valueOf(value.toString()));
}
}
}
}
return baseDNs;
}
use of org.forgerock.opendj.ldif.LDIFEntryReader in project OpenAM by OpenRock.
the class IdRepoTestBase method setUpSuite.
@BeforeClass
public void setUpSuite() throws Exception {
InjectorConfiguration.setGuiceModuleLoader(new GuiceModuleLoader() {
@Override
public Set<Class<? extends Module>> getGuiceModules(Class<? extends Annotation> aClass) {
return Collections.<Class<? extends Module>>singleton(TestGuiceModule.class);
}
});
PowerMockito.mockStatic(WebtopNaming.class);
idRepoListener = PowerMockito.mock(IdRepoListener.class);
when(WebtopNaming.getAMServerID()).thenReturn("01");
when(WebtopNaming.getSiteID(eq("01"))).thenReturn("02");
memoryBackend = decorateBackend(new MemoryBackend(new LDIFEntryReader(getClass().getResourceAsStream(getLDIFPath()))));
}
use of org.forgerock.opendj.ldif.LDIFEntryReader in project OpenAM by OpenRock.
the class OpenDJUpgrader method patchConfiguration.
private void patchConfiguration() throws IOException {
message("Patching configuration config/config.ldif...");
try (InputStream defaultCurrentConfig = new FileInputStream(installRoot + "/config/upgrade/config.ldif." + currentVersion);
InputStream defaultNewConfig = new FileInputStream(installRoot + "/config/upgrade/config.ldif." + newVersion);
InputStream currentConfig = new FileInputStream(getBackupFileName("config/config.ldif"));
OutputStream newCurrentConfig = new FileOutputStream(installRoot + "/config/config.ldif")) {
final LDIFEntryReader defaultCurrentConfigReader = new LDIFEntryReader(defaultCurrentConfig);
final LDIFEntryReader defaultNewConfigReader = new LDIFEntryReader(defaultNewConfig);
final LDIFEntryReader currentConfigReader = new LDIFEntryReader(currentConfig);
final LDIFEntryWriter newConfigWriter = new LDIFEntryWriter(newCurrentConfig);
LDIF.copyTo(LDIF.patch(currentConfigReader, LDIF.diff(defaultCurrentConfigReader, defaultNewConfigReader)), newConfigWriter);
newConfigWriter.flush();
message("done");
} catch (final IOException ioe) {
message("failed: " + ioe.getMessage());
throw ioe;
}
}
Aggregations