public boolean remove(AbstractTransaction txn, Entry entry)
throws NdbApiException
{
DN dn = entry.getDN();
NdbResultSet rs = null;
NdbTransaction ndbTxn = txn.getNdbTransaction();
NdbOperation op = ndbTxn.getSelectOperation(name,
NdbOperation.LockMode.LM_CommittedRead);
boolean extensibleObject = false;
int componentIndex = dn.getNumComponents() - 1;
for (int i=0; i < BackendImpl.DN2ID_DN_NC; i++) {
while (componentIndex >= 0) {
op.equalString(BackendImpl.DN2ID_DN + Integer.toString(i),
dn.getRDN(componentIndex).toNormalizedString());
componentIndex--;
i++;
}
op.equalString(BackendImpl.DN2ID_DN +
Integer.toString(i), "");
}
op.getValue(BackendImpl.EID);
op.getValue(BackendImpl.DN2ID_OC);
op.getValue(BackendImpl.DN2ID_XOC);
rs = op.resultData();
ndbTxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);
long eid = 0;
NdbTransaction ndbDATxn = null;
String[] ocsStringArray = null;
String[] xocsStringArray = null;
List<NdbResultSet> ocRsList = new ArrayList<NdbResultSet>();
NdbIndexScanOperation indexScanOp = null;
if (rs.next()) {
eid = rs.getLong(BackendImpl.EID);
String ocsString = rs.getString(BackendImpl.DN2ID_OC);
ocsStringArray = ocsString.split(" ");
String xocsString = rs.getString(BackendImpl.DN2ID_XOC);
xocsStringArray = xocsString.split(" ");
if (xocsString.length() > 0) {
extensibleObject = true;
}
for (String ocName : ocsStringArray) {
ObjectClass oc =
DirectoryServer.getObjectClass(ocName, true);
if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
continue;
}
if (ndbDATxn == null) {
ndbDATxn = txn.getNdbDATransaction(ocName, eid);
}
indexScanOp =
ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, ocName);
indexScanOp.setBoundLong(BackendImpl.EID,
NdbIndexScanOperation.BoundType.BoundEQ, eid);
indexScanOp.getValue(BackendImpl.MID);
ocRsList.add(indexScanOp.resultData());
}
// Extensible object.
if (extensibleObject) {
for (String xocName : xocsStringArray) {
ObjectClass xoc =
DirectoryServer.getObjectClass(xocName, true);
if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
continue;
}
if (ndbDATxn == null) {
ndbDATxn = txn.getNdbDATransaction(xocName, eid);
}
indexScanOp =
ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, xocName);
indexScanOp.setBoundLong(BackendImpl.EID,
NdbIndexScanOperation.BoundType.BoundEQ, eid);
indexScanOp.getValue(BackendImpl.MID);
ocRsList.add(indexScanOp.resultData());
}
}
}
// Attribute options.
if (ndbDATxn == null) {
ndbDATxn = txn.getNdbDATransaction(BackendImpl.TAGS_TABLE, eid);
}
indexScanOp = ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME,
BackendImpl.TAGS_TABLE);
indexScanOp.setBoundLong(BackendImpl.EID,
NdbIndexScanOperation.BoundType.BoundEQ, eid);
indexScanOp.getValue(BackendImpl.TAG_ATTR);
indexScanOp.getValue(BackendImpl.MID);
NdbResultSet tagRs = indexScanOp.resultData();
ndbDATxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);
Iterator<NdbResultSet> rsIterator = ocRsList.iterator();
for (String ocName : ocsStringArray) {
ObjectClass oc =
DirectoryServer.getObjectClass(ocName, true);
if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
continue;
}
NdbResultSet ocRs = rsIterator.next();
while (ocRs.next()) {
int mid = ocRs.getInt(BackendImpl.MID);
op = ndbDATxn.getDeleteOperation(ocName);
op.equalLong(BackendImpl.EID, eid);
op.equalInt(BackendImpl.MID, mid);
}
}
// Extensible object.
if (extensibleObject) {
for (String xocName : xocsStringArray) {
ObjectClass xoc =
DirectoryServer.getObjectClass(xocName, true);
if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
continue;
}
NdbResultSet ocRs = rsIterator.next();
while (ocRs.next()) {
int mid = ocRs.getInt(BackendImpl.MID);
op = ndbDATxn.getDeleteOperation(xocName);
op.equalLong(BackendImpl.EID, eid);
op.equalInt(BackendImpl.MID, mid);
}
}