use of org.opends.server.core.AddOperation in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method internalCreate.
/**
* Create an entry in the directory using the principal name
*/
private void internalCreate(SSOToken token, String dn, Map attrs) throws SMSException, SSOException {
SMSAuditor auditor = newAuditor(token, dn, null);
List attrList = copyMapToAttrList(attrs);
AddOperation ao = icConn.processAdd(dn, attrList);
ResultCode resultCode = ao.getResultCode();
if (resultCode == ResultCode.SUCCESS) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.create: Successfully created" + " entry: " + dn);
}
if (auditor != null) {
auditor.auditCreate(attrs);
}
} else if (resultCode == ResultCode.ENTRY_ALREADY_EXISTS) {
// During install time and other times,
// this error gets throws due to unknown issue. Issue:
// Hence mask it.
debug.warning("SMSEmbeddedLdapObject.create: Entry " + "Already Exists Error for DN" + dn);
} else {
debug.error("SMSEmbeddedLdapObject.create: Error creating entry: " + dn + ", error code = " + resultCode);
throw new SMSException("", "sms-entry-cannot-create");
}
}
use of org.opends.server.core.AddOperation in project midpoint by Evolveum.
the class TestSynchronization method test100SyncAddWill.
@Test
public void test100SyncAddWill() throws Exception {
final String TEST_NAME = "test100SyncAddWill";
TestUtil.displayTestTile(TEST_NAME);
final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
AssertJUnit.assertNotNull(syncTask);
assertSyncToken(syncTask, 0, result);
((SynchornizationServiceMock) syncServiceMock).reset();
// create add change in embeded LDAP
LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_WILL_FILE.getPath());
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry entry = ldifReader.readEntry();
display("Entry from LDIF", entry);
AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// WHEN
provisioningService.synchronize(coords, syncTask, result);
// THEN
SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
assertEquals("Unexpected number of synchronization service calls", 1, mock.getCallCount());
ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
// ObjectDelta<? extends ShadowType> objectDelta = lastChange.getObjectDelta();
// assertNotNull("Null object delta in change notification", objectDelta);
// assertEquals("Wrong change type in delta in change notification", ChangeType.ADD, objectDelta.getChangeType());
PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
assertNotNull("No current shadow in change notification", currentShadow);
assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_WILL_NAME), currentShadow.asObjectable().getName());
assertSyncToken(SYNC_TASK_OID, 1, result);
}
use of org.opends.server.core.AddOperation in project midpoint by Evolveum.
the class TestSynchronization method test500SyncAddProtected.
@Test
public void test500SyncAddProtected() throws Exception {
final String TEST_NAME = "test500SyncAddProtected";
TestUtil.displayTestTile(TEST_NAME);
final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME);
Task syncTask = taskManager.getTask(SYNC_TASK_OID, result);
AssertJUnit.assertNotNull(syncTask);
assertSyncToken(syncTask, 1, result);
((SynchornizationServiceMock) syncServiceMock).reset();
// create add change in embedded LDAP
LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_CALYPSO_FILE.getPath());
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry entry = ldifReader.readEntry();
ldifReader.close();
display("Entry from LDIF", entry);
AddOperation addOperation = openDJController.getInternalConnection().processAdd(entry);
AssertJUnit.assertEquals("LDAP add operation failed", ResultCode.SUCCESS, addOperation.getResultCode());
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(resourceType.getOid(), AbstractOpenDjTest.RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// WHEN
provisioningService.synchronize(coords, syncTask, result);
// THEN
SynchornizationServiceMock mock = (SynchornizationServiceMock) syncServiceMock;
assertEquals("Unexpected number of synchronization service calls", 0, mock.getCallCount());
// ResourceObjectShadowChangeDescription lastChange = mock.getLastChange();
// PrismObject<? extends ShadowType> currentShadow = lastChange.getCurrentShadow();
// assertNotNull("No current shadow in change notification", currentShadow);
// assertNotNull("No old shadow in change notification", lastChange.getOldShadow());
//
// assertEquals("Wrong shadow name", PrismTestUtil.createPolyStringType(ACCOUNT_CALYPSO_NAME), currentShadow.asObjectable().getName());
//
// assertNotNull("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
// assertTrue("Calypso is not protected", currentShadow.asObjectable().isProtectedObject());
assertSyncToken(SYNC_TASK_OID, 2, result);
}
Aggregations