summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java')
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java61
1 files changed, 57 insertions, 4 deletions
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
index 0824cc9a7..be674bfd5 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java
@@ -138,8 +138,6 @@ public class DBSubsystem implements IDBSubsystem {
private static final String PROP_INCREMENT_NAME = "increment_name";
private static final String PROP_RANGE_DN = "rangeDN";
- private static final BigInteger BI_ONE = new BigInteger("1");
-
private ILogger mLogger = null;
// singleton enforcement
@@ -424,7 +422,7 @@ public class DBSubsystem implements IDBSubsystem {
conn.modify(dn, mods);
// Add new range object
- String endRange = nextRangeNo.add(incrementNo).subtract(BI_ONE).toString();
+ String endRange = nextRangeNo.add(incrementNo).subtract(BigInteger.ONE).toString();
LDAPAttributeSet attrs = new LDAPAttributeSet();
attrs.add(new LDAPAttribute("objectClass", "top"));
attrs.add(new LDAPAttribute("objectClass", "pkiRange"));
@@ -436,6 +434,8 @@ public class DBSubsystem implements IDBSubsystem {
String dn2 = "cn=" + nextRange + "," + rangeDN;
LDAPEntry rangeEntry = new LDAPEntry(dn2, attrs);
conn.add(rangeEntry);
+ CMS.debug("DBSubsystem: getNextRange Next range has been added: " +
+ nextRange + " - " + endRange);
} catch (Exception e) {
CMS.debug("DBSubsystem: getNextRange. Unable to provide next range :" + e);
e.printStackTrace();
@@ -531,6 +531,7 @@ public class DBSubsystem implements IDBSubsystem {
PROP_NEXT_SERIAL_NUMBER, "0"), 16);
mEnableSerialMgmt = mDBConfig.getBoolean(PROP_ENABLE_SERIAL_MGMT, false);
+ CMS.debug("DBSubsystem: init() mEnableSerialMgmt="+mEnableSerialMgmt);
// populate the certs hash entry
Hashtable<String, String> certs = new Hashtable<String, String>();
@@ -783,6 +784,10 @@ public class DBSubsystem implements IDBSubsystem {
reg.registerAttribute(IRepositoryRecord.ATTR_PUB_STATUS,
new StringMapper(RepositorySchema.LDAP_ATTR_PUB_STATUS));
}
+ if (!reg.isAttributeRegistered(IRepositoryRecord.ATTR_DESCRIPTION)) {
+ reg.registerAttribute(IRepositoryRecord.ATTR_DESCRIPTION,
+ new StringMapper(RepositorySchema.LDAP_ATTR_DESCRIPTION));
+ }
} catch (EBaseException e) {
if (CMS.isPreOpMode())
@@ -791,6 +796,47 @@ public class DBSubsystem implements IDBSubsystem {
}
}
+ public String getEntryAttribute(String dn, String attrName,
+ String defaultValue, String errorValue) {
+ LDAPConnection conn = null;
+ String attrValue = null;
+ try {
+ conn = mLdapConnFactory.getConn();
+ String[] attrs = { attrName };
+ LDAPEntry entry = conn.read(dn, attrs);
+ if (entry != null) {
+ LDAPAttribute attr = entry.getAttribute(attrName);
+ if (attr != null) {
+ attrValue = (String) attr.getStringValues().nextElement();
+ } else {
+ attrValue = defaultValue;
+ }
+ } else {
+ attrValue = errorValue;
+ }
+ } catch (LDAPException e) {
+ CMS.debug("DBSubsystem: getEntryAttribute LDAPException code="+e.getLDAPResultCode());
+ if (e.getLDAPResultCode() == LDAPException.NO_SUCH_OBJECT) {
+ attrValue = defaultValue;
+ }
+ } catch (Exception e) {
+ CMS.debug("DBSubsystem: getEntryAttribute. Unable to retrieve '"+attrName+"': "+ e);
+ attrValue = errorValue;
+ } finally {
+ try {
+ if ((conn != null) && (mLdapConnFactory != null)) {
+ CMS.debug("Releasing ldap connection");
+ mLdapConnFactory.returnConn(conn);
+ }
+ } catch (Exception e) {
+ CMS.debug("Error releasing the ldap connection" + e.toString());
+ }
+ }
+ CMS.debug("DBSubsystem: getEntryAttribute: dn="+dn+" attr="+attrName+":"+attrValue+";");
+
+ return attrValue;
+ }
+
/**
* Starts up this service.
*/
@@ -798,13 +844,20 @@ public class DBSubsystem implements IDBSubsystem {
}
/**
- * Retrieves configuration store.
+ * Retrieves internal DB configuration store.
*/
public IConfigStore getConfigStore() {
return mConfig;
}
/**
+ * Retrieves DB subsystem configuration store.
+ */
+ public IConfigStore getDBConfigStore() {
+ return mDBConfig;
+ }
+
+ /**
* Retrieves base DN of backend database.
*/
public String getBaseDN() {