From 3d4c0acccda6e62b23f248d75c1cc6721fc20bdf Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 07 Jun 2016 13:51:21 +0000
Subject: [PATCH] OPENDJ-3037 inlined DirectoryServer.getAttributeType(String)
---
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java | 38 ++++++++++++++++++--------------------
1 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
index b3bcade..1ef1a0d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -19,6 +19,7 @@
import static org.forgerock.util.Reject.*;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.schema.BooleanSyntax.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -213,7 +214,7 @@
// Construct the backup base entry.
LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2);
objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP);
- objectClasses.put(DirectoryServer.getSchema().getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT);
+ objectClasses.put(getSchema().getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT);
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1);
@@ -269,8 +270,7 @@
{
int numEntries = 1;
- AttributeType backupPathType =
- DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType backupPathType = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
for (File dir : backupDirectories.keySet())
{
@@ -378,7 +378,7 @@
long count = 0;
Entry backupDirEntry = getBackupDirectoryEntry(entryDN);
- AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType t = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
List<Attribute> attrList = backupDirEntry.getAttribute(t);
for (ByteString v : attrList.get(0))
{
@@ -465,7 +465,7 @@
throws DirectoryException
{
// Make sure that the DN specifies a backup directory.
- AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType t = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
ByteString v = entryDN.rdn().getAttributeValue(t);
if (v == null)
{
@@ -503,13 +503,13 @@
// Construct the backup directory entry to return.
LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
- ocMap.put(DirectoryServer.getSchema().getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY);
+ ocMap.put(getSchema().getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY);
LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0);
LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3);
userAttrs.put(t, asList(t, v));
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN);
+ t = getSchema().getAttributeType(ATTR_BACKUP_BACKEND_DN);
userAttrs.put(t, asList(t, ByteString.valueOfUtf8(backupDirectory.getConfigEntryDN().toString())));
Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
@@ -533,7 +533,7 @@
throws DirectoryException
{
// First, get the backup ID from the entry DN.
- AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID);
+ AttributeType idType = getSchema().getAttributeType(ATTR_BACKUP_ID);
ByteString idValue = entryDN.rdn().getAttributeValue(idType);
if (idValue == null) {
throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN));
@@ -546,7 +546,7 @@
throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_PARENT_DN.get(entryDN));
}
- AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType t = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
ByteString v = parentDN.rdn().getAttributeValue(t);
if (v == null) {
throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN));
@@ -579,7 +579,7 @@
// Construct the backup entry to return.
LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(3);
ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP);
- ocMap.put(DirectoryServer.getSchema().getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO);
+ ocMap.put(getSchema().getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO);
ocMap.put(CoreSchema.getExtensibleObjectObjectClass(), OC_EXTENSIBLE_OBJECT);
LinkedHashMap<AttributeType, List<Attribute>> opAttrs = new LinkedHashMap<>(0);
@@ -591,7 +591,7 @@
Date backupDate = backupInfo.getBackupDate();
if (backupDate != null) {
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_DATE);
+ t = getSchema().getAttributeType(ATTR_BACKUP_DATE);
userAttrs.put(t,
asList(t, ByteString.valueOfUtf8(GeneralizedTimeSyntax.format(backupDate))));
}
@@ -602,7 +602,7 @@
Set<String> dependencies = backupInfo.getDependencies();
if (dependencies != null && !dependencies.isEmpty()) {
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_DEPENDENCY);
+ t = getSchema().getAttributeType(ATTR_BACKUP_DEPENDENCY);
AttributeBuilder builder = new AttributeBuilder(t);
builder.addAllStrings(dependencies);
userAttrs.put(t, builder.toAttributeList());
@@ -621,7 +621,7 @@
Map<String, String> properties = backupInfo.getBackupProperties();
if (properties != null && !properties.isEmpty()) {
for (Map.Entry<String, String> e : properties.entrySet()) {
- t = DirectoryServer.getAttributeType(toLowerCase(e.getKey()));
+ t = getSchema().getAttributeType(toLowerCase(e.getKey()));
userAttrs.put(t, asList(t, ByteString.valueOfUtf8(e.getValue())));
}
}
@@ -633,13 +633,13 @@
private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value)
{
- AttributeType t = DirectoryServer.getAttributeType(attrName);
+ AttributeType t = getSchema().getAttributeType(attrName);
userAttrs.put(t, asList(t, ByteString.wrap(value)));
}
private void putBoolean(LinkedHashMap<AttributeType, List<Attribute>> attrsMap, String attrName, boolean value)
{
- AttributeType t = DirectoryServer.getAttributeType(attrName);
+ AttributeType t = getSchema().getAttributeType(attrName);
attrsMap.put(t, asList(t, createBooleanValue(value)));
}
@@ -710,8 +710,7 @@
if (scope != SearchScope.BASE_OBJECT && !backupDirectories.isEmpty())
{
- AttributeType backupPathType =
- DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType backupPathType = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
for (File dir : backupDirectories.keySet())
{
// Check to see if the descriptor file exists. If not, then skip this
@@ -762,8 +761,7 @@
if (scope != SearchScope.BASE_OBJECT)
{
- AttributeType t =
- DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
+ AttributeType t = getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH);
List<Attribute> attrList = backupDirEntry.getAttribute(t);
returnEntries(searchOperation, baseDN, filter, attrList);
}
@@ -803,7 +801,7 @@
{
File dir = new File(v.toString());
BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
- AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID);
+ AttributeType idType = getSchema().getAttributeType(ATTR_BACKUP_ID);
for (String backupID : backupDirectory.getBackups().keySet())
{
--
Gitblit v1.10.0