| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.AdminToolMessages; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** The task that is called when we must modify an entry. */ |
| | | public class ModifyEntryTask extends Task |
| | |
| | | { |
| | | continue; |
| | | } |
| | | AttributeType attrType = schema.getAttributeType(attr.getName().toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attr.getName().toLowerCase()); |
| | | } |
| | | List<ByteString> newValues = new ArrayList<>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | |
| | | */ |
| | | public static String getRDNString(String attrName, String attrValue) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | RDN rdn = new RDN(attrType, attrName, ByteString.valueOf(attrValue)); |
| | | return rdn.toString(); |
| | | } |
| | |
| | | // Only add the aclRights information if the aclRights attribute type was seen. |
| | | if(hasAttrMask(mask, ACL_RIGHTS)) { |
| | | String typeStr = aclRightsAttributeLevelStr + ";" + a.getNameOrOID(); |
| | | AttributeType attributeType = DirectoryServer.getDefaultAttributeType(typeStr); |
| | | AttributeType attributeType = DirectoryServer.getAttributeTypeOrDefault(typeStr); |
| | | Attribute attr = Attributes.create(attributeType, evalInfo.toString()); |
| | | //It is possible that the user might have specified the same attributes |
| | | //in both the search and the specific attribute part of the control. |
| | |
| | | evalInfo.append(rightsString(container, handler, skipCheck, "proxy")); |
| | | addEntryLevelRightsInfo(container, mask, retEntry, "proxy"); |
| | | if(hasAttrMask(mask, ACL_RIGHTS)) { |
| | | AttributeType attributeType= |
| | | DirectoryServer.getDefaultAttributeType(aclRightsEntryLevelStr); |
| | | Attribute attr = Attributes.create(attributeType, evalInfo.toString()); |
| | | Attribute attr = Attributes.create(aclRightsEntryLevelStr, evalInfo.toString()); |
| | | retEntry.addAttribute(attr,null); |
| | | } |
| | | } |
| | |
| | | String typeStr= |
| | | aclRightsInfoAttrLogsStr + ";" + rightStr + ";" + |
| | | aType.getPrimaryName(); |
| | | AttributeType attributeType= |
| | | DirectoryServer.getDefaultAttributeType(typeStr); |
| | | Attribute attr = Attributes.create(attributeType, |
| | | container.getEvalSummary()); |
| | | AttributeType attributeType = DirectoryServer.getAttributeTypeOrDefault(typeStr); |
| | | Attribute attr = Attributes.create(attributeType, container.getEvalSummary()); |
| | | // The attribute type might have already been added, probably |
| | | // not but it is possible. |
| | | if(!retEntry.hasAttribute(attributeType)) |
| | |
| | | //Check if the aclRightsInfo attribute was requested. |
| | | if(hasAttrMask(mask,ACL_RIGHTS_INFO)) { |
| | | String typeStr = aclRightsInfoEntryLogsStr + ";" + rightStr; |
| | | AttributeType attributeType= |
| | | DirectoryServer.getDefaultAttributeType(typeStr); |
| | | Attribute attr = Attributes.create(attributeType, |
| | | container.getEvalSummary()); |
| | | Attribute attr = Attributes.create(typeStr, container.getEvalSummary()); |
| | | retEntry.addAttribute(attr,null); |
| | | } |
| | | } |
| | |
| | | |
| | | ArrayList<Attribute> monitorAttrs = new ArrayList<>(); |
| | | String jeVersion = JEVersion.CURRENT_VERSION.getVersionString(); |
| | | AttributeType versionType = |
| | | DirectoryServer.getDefaultAttributeType("JEVersion"); |
| | | monitorAttrs.add(Attributes.create(versionType, jeVersion)); |
| | | monitorAttrs.add(Attributes.create("JEVersion", jeVersion)); |
| | | |
| | | addAttributesForStatsObject(monitorAttrs, environmentStats, "Environment"); |
| | | addAttributesForStatsObject(monitorAttrs, transactionStats, "Transaction"); |
| | |
| | | |
| | | if(filterUseEnabled) |
| | | { |
| | | monitorAttrs.add(Attributes.create("filter-use-startTime", |
| | | startTimeStamp)); |
| | | monitorAttrs.add(Attributes.create("filter-use-startTime", startTimeStamp)); |
| | | AttributeBuilder builder = new AttributeBuilder("filter-use"); |
| | | |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | |
| | | |
| | | |
| | | // Get the schedule for this task. |
| | | attrType = DirectoryServer.getAttributeTypeOrNull(ATTR_RECURRING_TASK_SCHEDULE.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(ATTR_RECURRING_TASK_SCHEDULE); |
| | | } |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_RECURRING_TASK_SCHEDULE.toLowerCase(), ATTR_RECURRING_TASK_SCHEDULE); |
| | | |
| | | attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | |
| | | weekdayArray = taskArrays[WEEKDAY_INDEX]; |
| | | |
| | | // Get the class name from the entry. If there isn't one, then fail. |
| | | attrType = DirectoryServer.getAttributeTypeOrNull(ATTR_TASK_CLASS.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(ATTR_TASK_CLASS); |
| | | } |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | |
| | | attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | if (type == null) |
| | | { |
| | | type = getDefaultAttributeType(lowerName); |
| | | } |
| | | return type; |
| | | return getAttributeTypeOrDefault(lowerName, lowerName); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | AttributeType type = getAttributeTypeOrNull(lowerName); |
| | | if (type == null) |
| | | { |
| | | type = getDefaultAttributeType(upperName); |
| | | type = getDefaultAttributeType(upperName, getDefaultAttributeSyntax()); |
| | | } |
| | | return type; |
| | | } |
| | |
| | | |
| | | /** |
| | | * Causes the Directory Server to construct a new attribute type definition |
| | | * with the provided name and using the default attribute syntax. This should |
| | | * only be used if there is no real attribute type for the specified name. |
| | | * |
| | | * @param name The name to use for the attribute type, as provided by the |
| | | * user. |
| | | * |
| | | * @return The constructed attribute type definition. |
| | | */ |
| | | public static AttributeType getDefaultAttributeType(String name) |
| | | { |
| | | return getDefaultAttributeType(name, getDefaultAttributeSyntax()); |
| | | } |
| | | |
| | | /** |
| | | * Causes the Directory Server to construct a new attribute type definition |
| | | * with the provided name and syntax. This should only be used if there is no |
| | | * real attribute type for the specified name. |
| | | * |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType("connection"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | AttributeBuilder builder = new AttributeBuilder("connection"); |
| | | for (ClientConnection conn : connMap.values()) |
| | | { |
| | | builder.add(conn.getMonitorSummary()); |
| | |
| | | import java.lang.management.MemoryUsage; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MemoryUsageMonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | | * This class defines a monitor provider that reports information about |
| | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<>(); |
| | | |
| | |
| | | gcSafeNames.put(gcName, safeName); |
| | | } |
| | | |
| | | attrs.add(createAttribute(safeName + "-total-collection-count", |
| | | String.valueOf(gcCount))); |
| | | attrs.add(createAttribute(safeName + "-total-collection-duration", |
| | | String.valueOf(gcTime))); |
| | | attrs.add(createAttribute(safeName + "-average-collection-duration", |
| | | String.valueOf(avgGCDuration))); |
| | | attrs.add(createAttribute(safeName + "-recent-collection-duration", |
| | | String.valueOf(recentGCDuration))); |
| | | attrs.add(createAttribute(safeName + "-total-collection-count", gcCount)); |
| | | attrs.add(createAttribute(safeName + "-total-collection-duration", gcTime)); |
| | | attrs.add(createAttribute(safeName + "-average-collection-duration", avgGCDuration)); |
| | | attrs.add(createAttribute(safeName + "-recent-collection-duration", recentGCDuration)); |
| | | } |
| | | |
| | | for (MemoryPoolMXBean mp : ManagementFactory.getMemoryPoolMXBeans()) |
| | |
| | | gcSafeNames.put(poolName, safeName); |
| | | } |
| | | |
| | | if (currentUsage == null) |
| | | { |
| | | attrs.add(createAttribute(safeName + "-current-bytes-used", "0")); |
| | | } |
| | | else |
| | | { |
| | | attrs.add(createAttribute(safeName + "-current-bytes-used", |
| | | String.valueOf(currentUsage.getUsed()))); |
| | | } |
| | | long currentBytesUsed = currentUsage != null ? currentUsage.getUsed() : 0; |
| | | attrs.add(createAttribute(safeName + "-current-bytes-used", currentBytesUsed)); |
| | | |
| | | if (collectionUsage == null) |
| | | { |
| | | attrs.add(createAttribute(safeName + |
| | | "-bytes-used-after-last-collection", |
| | | "0")); |
| | | } |
| | | else |
| | | { |
| | | attrs.add(createAttribute(safeName + |
| | | "-bytes-used-after-last-collection", |
| | | String.valueOf(collectionUsage.getUsed()))); |
| | | } |
| | | long collectionBytesUsed = collectionUsage != null ? collectionUsage.getUsed() : 0; |
| | | attrs.add(createAttribute(safeName + "-bytes-used-after-last-collection", collectionBytesUsed)); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructs an attribute using the provided information. It will have the |
| | | * default syntax. |
| | | * |
| | | * @param name The name to use for the attribute. |
| | | * @param value The value to use for the attribute. |
| | | * |
| | | * @return The attribute created from the provided information. |
| | | */ |
| | | private Attribute createAttribute(String name, String value) |
| | | private Attribute createAttribute(String name, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | return Attributes.create(attrType, value); |
| | | return Attributes.create(name, String.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.StackTraceMonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | |
| | | orderedStacks.put(e.getKey().getId(), e); |
| | | } |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getDefaultAttributeType("jvmThread"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | AttributeBuilder builder = new AttributeBuilder("jvmThread"); |
| | | for (Map.Entry<Thread,StackTraceElement[]> e : orderedStacks.values()) |
| | | { |
| | | Thread t = e.getKey(); |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<>(13); |
| | | |
| | | attrs.add(createAttribute("javaVersion", |
| | | System.getProperty("java.version"))); |
| | | attrs.add(createAttribute("javaVersion", System.getProperty("java.version"))); |
| | | attrs.add(createAttribute("javaVendor", System.getProperty("java.vendor"))); |
| | | attrs.add(createAttribute("jvmVersion", |
| | | System.getProperty("java.vm.version"))); |
| | | attrs.add(createAttribute("jvmVendor", |
| | | System.getProperty("java.vm.vendor"))); |
| | | attrs.add(createAttribute("javaHome", |
| | | System.getProperty("java.home"))); |
| | | attrs.add(createAttribute("classPath", |
| | | System.getProperty("java.class.path"))); |
| | | attrs.add(createAttribute("workingDirectory", |
| | | System.getProperty("user.dir"))); |
| | | attrs.add(createAttribute("jvmVersion", System.getProperty("java.vm.version"))); |
| | | attrs.add(createAttribute("jvmVendor", System.getProperty("java.vm.vendor"))); |
| | | attrs.add(createAttribute("javaHome", System.getProperty("java.home"))); |
| | | attrs.add(createAttribute("classPath", System.getProperty("java.class.path"))); |
| | | attrs.add(createAttribute("workingDirectory", System.getProperty("user.dir"))); |
| | | |
| | | String osInfo = System.getProperty("os.name") + " " + |
| | | System.getProperty("os.version") + " " + |
| | |
| | | |
| | | |
| | | Runtime runtime = Runtime.getRuntime(); |
| | | attrs.add(createAttribute("availableCPUs", |
| | | String.valueOf(runtime.availableProcessors()))); |
| | | attrs.add(createAttribute("maxMemory", |
| | | String.valueOf(runtime.maxMemory()))); |
| | | attrs.add(createAttribute("usedMemory", |
| | | String.valueOf(runtime.totalMemory()))); |
| | | attrs.add(createAttribute("freeUsedMemory", |
| | | String.valueOf(runtime.freeMemory()))); |
| | | attrs.add(createAttribute("availableCPUs", runtime.availableProcessors())); |
| | | attrs.add(createAttribute("maxMemory", runtime.maxMemory())); |
| | | attrs.add(createAttribute("usedMemory", runtime.totalMemory())); |
| | | attrs.add(createAttribute("freeUsedMemory", runtime.freeMemory())); |
| | | String installPath = DirectoryServer.getServerRoot(); |
| | | if (installPath != null) |
| | | { |
| | |
| | | |
| | | private void addAttribute(ArrayList<Attribute> attrs, String attrName, Collection<String> values) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | AttributeBuilder builder = new AttributeBuilder(attrName); |
| | | builder.addAllStrings(values); |
| | | attrs.add(builder.toAttribute()); |
| | | } |
| | | |
| | | /** |
| | | * Constructs an attribute using the provided information. It will have the |
| | | * default syntax. |
| | | * |
| | | * @param name The name to use for the attribute. |
| | | * @param value The value to use for the attribute. |
| | | * |
| | | * @return The attribute created from the provided information. |
| | | */ |
| | | private Attribute createAttribute(String name, String value) |
| | | private Attribute createAttribute(String name, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | return Attributes.create(attrType, value); |
| | | return Attributes.create(name, String.valueOf(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.VersionMonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.DynamicConstants; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a monitor provider that reports Directory Server version |
| | | * information. |
| | | */ |
| | | /** This class defines a monitor provider that reports Directory Server version information. */ |
| | | public class VersionMonitorProvider |
| | | extends MonitorProvider<VersionMonitorProviderCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the product name. |
| | | */ |
| | | /** The name of the attribute used to provide the product name. */ |
| | | public static final String ATTR_PRODUCT_NAME = "productName"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the short name. |
| | | */ |
| | | /** The name of the attribute used to provide the short name. */ |
| | | public static final String ATTR_SHORT_NAME = "shortName"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the major version number. |
| | | */ |
| | | /** The name of the attribute used to provide the major version number. */ |
| | | public static final String ATTR_MAJOR_VERSION = "majorVersion"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the minor version number. |
| | | */ |
| | | /** The name of the attribute used to provide the minor version number. */ |
| | | public static final String ATTR_MINOR_VERSION = "minorVersion"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the point version number. |
| | | */ |
| | | /** The name of the attribute used to provide the point version number. */ |
| | | public static final String ATTR_POINT_VERSION = "pointVersion"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the version qualifier string. |
| | | */ |
| | | /** The name of the attribute used to provide the version qualifier string. */ |
| | | public static final String ATTR_VERSION_QUALIFIER = "versionQualifier"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the weekly build number. |
| | | */ |
| | | /** The name of the attribute used to provide the weekly build number. */ |
| | | public static final String ATTR_BUILD_NUMBER = "buildNumber"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the list of bugfix IDs. |
| | | */ |
| | | /** The name of the attribute used to provide the list of bugfix IDs. */ |
| | | public static final String ATTR_FIX_IDS = "fixIDs"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the Subversion revision number. |
| | | */ |
| | | /** The name of the attribute used to provide the Subversion revision number. */ |
| | | public static final String ATTR_REVISION_NUMBER = "revisionNumber"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the build ID (aka the build |
| | | * timestamp). |
| | | */ |
| | | /** The name of the attribute used to provide the build ID (aka the build timestamp). */ |
| | | public static final String ATTR_BUILD_ID = "buildID"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the compact version string. |
| | | */ |
| | | /** The name of the attribute used to provide the compact version string. */ |
| | | public static final String ATTR_COMPACT_VERSION = "compactVersion"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The name of the attribute used to provide the full version string. |
| | | */ |
| | | /** The name of the attribute used to provide the full version string. */ |
| | | public static final String ATTR_FULL_VERSION = "fullVersion"; |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider(VersionMonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // No initialization is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name of this monitor provider. It should be unique among all |
| | | * monitor providers, including all instances of the same monitor provider. |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "Version"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is requested. |
| | | * |
| | | * @return A set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | public ArrayList<Attribute> getMonitorData() |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<>(12); |
| | | |
| | | attrs.add(createAttribute(ATTR_PRODUCT_NAME, |
| | | DynamicConstants.PRODUCT_NAME)); |
| | | attrs.add(createAttribute(ATTR_PRODUCT_NAME, DynamicConstants.PRODUCT_NAME)); |
| | | attrs.add(createAttribute(ATTR_SHORT_NAME, DynamicConstants.SHORT_NAME)); |
| | | attrs.add(createAttribute(ATTR_MAJOR_VERSION, |
| | | String.valueOf(DynamicConstants.MAJOR_VERSION))); |
| | | attrs.add(createAttribute(ATTR_MINOR_VERSION, |
| | | String.valueOf(DynamicConstants.MINOR_VERSION))); |
| | | attrs.add(createAttribute(ATTR_POINT_VERSION, |
| | | String.valueOf(DynamicConstants.POINT_VERSION))); |
| | | attrs.add(createAttribute(ATTR_MAJOR_VERSION, DynamicConstants.MAJOR_VERSION)); |
| | | attrs.add(createAttribute(ATTR_MINOR_VERSION, DynamicConstants.MINOR_VERSION)); |
| | | attrs.add(createAttribute(ATTR_POINT_VERSION, DynamicConstants.POINT_VERSION)); |
| | | |
| | | String versionQualifier = DynamicConstants.VERSION_QUALIFIER; |
| | | if (versionQualifier != null && versionQualifier.length() > 0) |
| | |
| | | int buildNumber = DynamicConstants.BUILD_NUMBER; |
| | | if (buildNumber > 0) |
| | | { |
| | | attrs.add(createAttribute(ATTR_BUILD_NUMBER, |
| | | String.valueOf(buildNumber))); |
| | | attrs.add(createAttribute(ATTR_BUILD_NUMBER, buildNumber)); |
| | | } |
| | | |
| | | String fixIDs = DynamicConstants.FIX_IDS; |
| | |
| | | attrs.add(createAttribute(ATTR_FIX_IDS, fixIDs)); |
| | | } |
| | | |
| | | attrs.add(createAttribute(ATTR_REVISION_NUMBER, String.valueOf(DynamicConstants.REVISION))); |
| | | attrs.add(createAttribute(ATTR_REVISION_NUMBER, DynamicConstants.REVISION)); |
| | | attrs.add(createAttribute(ATTR_BUILD_ID, DynamicConstants.BUILD_ID)); |
| | | attrs.add(createAttribute(ATTR_COMPACT_VERSION, |
| | | DynamicConstants.COMPACT_VERSION_STRING)); |
| | | attrs.add(createAttribute(ATTR_FULL_VERSION, |
| | | DynamicConstants.FULL_VERSION_STRING)); |
| | | attrs.add(createAttribute(ATTR_COMPACT_VERSION, DynamicConstants.COMPACT_VERSION_STRING)); |
| | | attrs.add(createAttribute(ATTR_FULL_VERSION, DynamicConstants.FULL_VERSION_STRING)); |
| | | |
| | | return attrs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructs an attribute using the provided information. It will have the |
| | | * default syntax. |
| | | * |
| | | * @param name The name to use for the attribute. |
| | | * @param value The value to use for the attribute. |
| | | * |
| | | * @return The attribute created from the provided information. |
| | | */ |
| | | private Attribute createAttribute(String name, String value) |
| | | private Attribute createAttribute(String name, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | return Attributes.create(attrType, value); |
| | | return Attributes.create(name, String.valueOf(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.service.ReplicationDomain.ImportExportContext; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | |
| | | /** |
| | |
| | | { |
| | | List<Attribute> attributes = new ArrayList<>(); |
| | | |
| | | attributes.add(Attributes.create("domain-name", String.valueOf(domain.getBaseDN()))); |
| | | attributes.add(Attributes.create("connected-to", domain.getReplicationServer())); |
| | | addMonitorData(attributes, "domain-name", domain.getBaseDN()); |
| | | addMonitorData(attributes, "connected-to", domain.getReplicationServer()); |
| | | addMonitorData(attributes, "lost-connections", domain.getNumLostConnections()); |
| | | addMonitorData(attributes, "received-updates", domain.getNumRcvdUpdates()); |
| | | addMonitorData(attributes, "sent-updates", domain.getNumSentUpdates()); |
| | |
| | | |
| | | // get the Server State |
| | | final String ATTR_SERVER_STATE = "server-state"; |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(ATTR_SERVER_STATE); |
| | | AttributeBuilder builder = new AttributeBuilder(type, ATTR_SERVER_STATE); |
| | | AttributeBuilder builder = new AttributeBuilder(ATTR_SERVER_STATE); |
| | | builder.addAllStrings(domain.getServerState().toStringSet()); |
| | | attributes.add(builder.toAttribute()); |
| | | |
| | | attributes.add(Attributes.create("ssl-encryption", String.valueOf(domain.isSessionEncrypted()))); |
| | | attributes.add(Attributes.create("generation-id", String.valueOf(domain.getGenerationID()))); |
| | | addMonitorData(attributes, "ssl-encryption", domain.isSessionEncrypted()); |
| | | addMonitorData(attributes, "generation-id", domain.getGenerationID()); |
| | | |
| | | // Add import/export monitoring attributes |
| | | final ImportExportContext ieContext = domain.getImportExportContext(); |
| | |
| | | addMonitorData(attributes, "assured-sd-server-timeout-updates", domain.getAssuredSdServerTimeoutUpdates()); |
| | | |
| | | // Status related monitoring fields |
| | | addMonitorData(attributes, "last-status-change-date", domain.getLastStatusChangeDate().toString()); |
| | | addMonitorData(attributes, "last-status-change-date", domain.getLastStatusChangeDate()); |
| | | |
| | | addMonitorData(attributes, "status", domain.getStatus().toString()); |
| | | addMonitorData(attributes, "status", domain.getStatus()); |
| | | |
| | | return attributes; |
| | | } |
| | | |
| | | private void addMonitorData(List<Attribute> attributes, String attrType, |
| | | private void addMonitorData(List<Attribute> attributes, String attrName, |
| | | Map<Integer, Integer> serverIdToNb) |
| | | { |
| | | if (!serverIdToNb.isEmpty()) |
| | | { |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(attrType); |
| | | final AttributeBuilder builder = new AttributeBuilder(type, attrType); |
| | | final AttributeBuilder builder = new AttributeBuilder(attrName); |
| | | for (Entry<Integer, Integer> entry : serverIdToNb.entrySet()) |
| | | { |
| | | final Integer serverId = entry.getKey(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Add an attribute with an integer value to the list of monitoring |
| | | * attributes. |
| | | * Adds an attribute with a value to the list of monitoring attributes. |
| | | * |
| | | * @param attributes the list of monitoring attributes |
| | | * @param name the name of the attribute to add. |
| | | * @param value The integer value of he attribute to add. |
| | | * @param attrName the name of the attribute to add. |
| | | * @param value The value of he attribute to add. |
| | | */ |
| | | public static void addMonitorData(List<Attribute> attributes, String name, int value) |
| | | public static void addMonitorData(List<Attribute> attributes, String attrName, Object value) |
| | | { |
| | | addMonitorData(attributes, name, String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | | * Add an attribute with an integer value to the list of monitoring |
| | | * attributes. |
| | | * |
| | | * @param attributes the list of monitoring attributes |
| | | * @param name the name of the attribute to add. |
| | | * @param value The integer value of he attribute to add. |
| | | */ |
| | | private static void addMonitorData(List<Attribute> attributes, String name, long value) |
| | | { |
| | | addMonitorData(attributes, name, String.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | | * Add an attribute with an integer value to the list of monitoring |
| | | * attributes. |
| | | * |
| | | * @param attributes the list of monitoring attributes |
| | | * @param name the name of the attribute to add. |
| | | * @param value The String value of he attribute to add. |
| | | */ |
| | | private static void addMonitorData(List<Attribute> attributes, String name, String value) |
| | | { |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(name); |
| | | attributes.add(Attributes.create(type, value)); |
| | | attributes.add(Attributes.create(attrName, String.valueOf(value))); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | superiorType = DirectoryServer.getDefaultAttributeType(woidString); |
| | | superiorType = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | else |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | msg.get(valueStr, woidString)); |
| | | } |
| | | attr = DirectoryServer.getDefaultAttributeType(woidString); |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidString)); |
| | | } |
| | | attr = DirectoryServer.getDefaultAttributeType(woidString); |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | msg.get(oid, woidString)); |
| | | } |
| | | attr = DirectoryServer.getDefaultAttributeType(woidString); |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | LocalizableMessage message = msg.get(oid, woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | attr = DirectoryServer.getDefaultAttributeType(woidString); |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the named attribute type, creating a default attribute if |
| | | * necessary. |
| | | * |
| | | * @param attributeName |
| | | * The name of the attribute type. |
| | | * @return The attribute type associated with the provided attribute |
| | | * name. |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | private static AttributeType getAttributeTypeOrDefault(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | } |
| | |
| | | */ |
| | | public AttributeBuilder(String attributeName) |
| | | { |
| | | this(getAttributeType(attributeName), attributeName); |
| | | this(getAttributeTypeOrDefault(attributeName), attributeName); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public void setAttributeType(String attributeName) |
| | | { |
| | | setAttributeType(getAttributeType(attributeName), attributeName); |
| | | setAttributeType(getAttributeTypeOrDefault(attributeName), attributeName); |
| | | } |
| | | |
| | | /** |
| | |
| | | * The String representation of the attribute value. |
| | | * @return A new attribute with the specified name and value. |
| | | */ |
| | | public static Attribute create(String attributeName, |
| | | String valueString) |
| | | public static Attribute create(String attributeName, String valueString) |
| | | { |
| | | return create(getAttributeType(attributeName), attributeName, valueString); |
| | | return create(getAttributeTypeOrDefault(attributeName), attributeName, valueString); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static Attribute empty(String attributeName) |
| | | { |
| | | return empty(getAttributeType(attributeName), attributeName); |
| | | return empty(getAttributeTypeOrDefault(attributeName), attributeName); |
| | | } |
| | | |
| | | |
| | |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | /** |
| | | * Gets the named attribute type, creating a default attribute if necessary. |
| | | * |
| | | * @param attributeName |
| | | * The name of the attribute type. |
| | | * @return The attribute type associated with the provided attribute name. |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | private static AttributeType getAttributeTypeOrDefault(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | } |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType( |
| | | attributeNameString); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(attributeNameString); |
| | | } |
| | | |
| | | RDN rdn = new RDN(attrType, attributeNameString, parsedValue); |
| | |
| | | // using the default syntax. If this is a problem, it |
| | | // will be caught later either by not finding the target |
| | | // entry or by not allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType( |
| | | attributeNameString); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(attributeNameString); |
| | | } |
| | | |
| | | rdn.addValue(attrType, attributeNameString, ByteString.empty()); |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType( |
| | | attributeNameString); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(attributeNameString); |
| | | } |
| | | |
| | | rdn.addValue(attrType, attributeNameString, parsedValue); |
| | |
| | | // using the default syntax. If this is a problem, it |
| | | // will be caught later either by not finding the target |
| | | // entry or by not allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | return attrType; |
| | | } |
| | |
| | | // syntax. If this is a problem, it will be caught later either |
| | | // by not finding the target entry or by not allowing the entry |
| | | // to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | |
| | | if (attributeType == null) |
| | | { |
| | | String typeStr = attrType.substring(0, lowerType.length()); |
| | | attributeType = DirectoryServer.getDefaultAttributeType(typeStr); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(typeStr); |
| | | } |
| | | return attributeType; |
| | | } |
| | |
| | | * org.opends.server.protocol.ldap.AddResponseProtocolOp class. |
| | | */ |
| | | public class TestAddResponseProtocolOp extends DirectoryServerTestCase { |
| | | /** |
| | | * The protocol op type for add responses. |
| | | */ |
| | | /** The protocol op type for add responses. */ |
| | | private static final byte OP_TYPE_ADD_RESPONSE = 0x69; |
| | | |
| | | /** |
| | | * The result code for add result operations. |
| | | */ |
| | | /** The result code for add result operations. */ |
| | | private static final int resultCode = 10; |
| | | |
| | | /** |
| | | * The error message to use for add result operations. |
| | | */ |
| | | /** The error message to use for add result operations. */ |
| | | private static final LocalizableMessage resultMsg = LocalizableMessage.raw("Test Successful"); |
| | | |
| | | /** The DN to use for add result operations. */ |
| | |
| | | TestCaseUtils.startServer(); |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | */ |
| | | public class TestCompareResponseProtocolOp extends LdapTestCase |
| | | { |
| | | /** |
| | | * The protocol op type for compare responses. |
| | | */ |
| | | /** The protocol op type for compare responses. */ |
| | | public static final byte OP_TYPE_COMPARE_RESPONSE = 0x6F; |
| | | |
| | | /** |
| | | * The result code for compare result operations. |
| | | */ |
| | | /** The result code for compare result operations. */ |
| | | private static final int resultCode = 10; |
| | | |
| | | /** |
| | | * The error message to use for compare result operations. |
| | | */ |
| | | /** The error message to use for compare result operations. */ |
| | | private static final LocalizableMessage resultMsg = LocalizableMessage.raw("Test Successful"); |
| | | |
| | | /** |
| | | * The DN to use for compare result operations. |
| | | */ |
| | | /** The DN to use for compare result operations. */ |
| | | private DN dn; |
| | | |
| | | @BeforeClass |
| | |
| | | TestCaseUtils.startServer(); |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | |
| | | @Test |
| | | public void testOpType() throws Exception |
| | | { |
| | | CompareResponseProtocolOp compareResponse = new CompareResponseProtocolOp( |
| | | resultCode); |
| | | CompareResponseProtocolOp compareResponse = new CompareResponseProtocolOp(resultCode); |
| | | assertEquals(compareResponse.getType(), OP_TYPE_COMPARE_RESPONSE); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | */ |
| | | public class TestDeleteResponseProtocolOp extends LdapTestCase |
| | | { |
| | | /** |
| | | * The protocol op type for delete responses. |
| | | */ |
| | | /** The protocol op type for delete responses. */ |
| | | public static final byte OP_TYPE_DELETE_RESPONSE = 0x6B; |
| | | |
| | | /** |
| | | * The result code for delete result operations. |
| | | */ |
| | | /** The result code for delete result operations. */ |
| | | private static final int resultCode = 10; |
| | | |
| | | /** |
| | | * The error message to use for delete result operations. |
| | | */ |
| | | /** The error message to use for delete result operations. */ |
| | | private static final LocalizableMessage resultMsg = LocalizableMessage.raw("Test Successful"); |
| | | |
| | | /** |
| | | * The DN to use for delete result operations. |
| | | */ |
| | | /** The DN to use for delete result operations. */ |
| | | private DN dn; |
| | | |
| | | @BeforeClass |
| | |
| | | TestCaseUtils.startServer(); |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | |
| | | */ |
| | | public class TestModifyDNResponseProtocolOp extends DirectoryServerTestCase |
| | | { |
| | | /** |
| | | * The protocol op type for modify DN responses. |
| | | */ |
| | | /** The protocol op type for modify DN responses. */ |
| | | public static final byte OP_TYPE_MODIFY_DN_RESPONSE = 0x6D; |
| | | |
| | | /** |
| | | * The result code for compare result operations. |
| | | */ |
| | | /** The result code for compare result operations. */ |
| | | private static final int resultCode = 10; |
| | | |
| | | /** |
| | | * The error message to use for compare result operations. |
| | | */ |
| | | /** The error message to use for compare result operations. */ |
| | | private static final LocalizableMessage resultMsg = LocalizableMessage.raw("Test Successful"); |
| | | |
| | | /** |
| | | * The DN to use for compare result operations. |
| | | */ |
| | | /** The DN to use for compare result operations. */ |
| | | private DN dn; |
| | | |
| | | @BeforeClass |
| | |
| | | TestCaseUtils.startServer(); |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | |
| | | @Test |
| | | public void testOpType() throws Exception |
| | | { |
| | | ModifyDNResponseProtocolOp modifyResponse = new ModifyDNResponseProtocolOp( |
| | | resultCode); |
| | | ModifyDNResponseProtocolOp modifyResponse = new ModifyDNResponseProtocolOp(resultCode); |
| | | assertEquals(modifyResponse.getType(), OP_TYPE_MODIFY_DN_RESPONSE); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | */ |
| | | public class TestModifyResponseProtocolOp extends LdapTestCase |
| | | { |
| | | /** |
| | | * The protocol op type for modify responses. |
| | | */ |
| | | /** The protocol op type for modify responses. */ |
| | | public static final byte OP_TYPE_MODIFY_RESPONSE = 0x67; |
| | | |
| | | /** |
| | | * The result code for add result operations. |
| | | */ |
| | | /** The result code for add result operations. */ |
| | | private static final int resultCode = 10; |
| | | |
| | | /** |
| | | * The error message to use for add result operations. |
| | | */ |
| | | /** The error message to use for add result operations. */ |
| | | private static final LocalizableMessage resultMsg = LocalizableMessage.raw("Test Successful"); |
| | | |
| | | /** |
| | | * The DN to use for add result operations. |
| | | */ |
| | | /** The DN to use for add result operations. */ |
| | | private DN dn; |
| | | |
| | | @BeforeClass |
| | |
| | | TestCaseUtils.startServer(); |
| | | |
| | | //Setup the DN to use in the response tests. |
| | | AttributeType attribute = |
| | | DirectoryServer.getDefaultAttributeType("testAttribute"); |
| | | AttributeType attribute = DirectoryServer.getAttributeTypeOrDefault("testAttribute"); |
| | | ByteString attributeValue = ByteString.valueOf("testValue"); |
| | | dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) }); |
| | | } |
| | |
| | | @Test |
| | | public void testOpType() throws Exception |
| | | { |
| | | ModifyResponseProtocolOp modifyResponse = new ModifyResponseProtocolOp( |
| | | resultCode); |
| | | ModifyResponseProtocolOp modifyResponse = new ModifyResponseProtocolOp(resultCode); |
| | | assertEquals(modifyResponse.getType(), OP_TYPE_MODIFY_RESPONSE); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void defaultAttributeTypesWithDifferentCaseEquals() |
| | | { |
| | | AttributeType attrType = getDefaultAttributeType("displayName"); |
| | | AttributeType attrType2 = getDefaultAttributeType("displayname"); |
| | | AttributeType attrType = getAttributeTypeOrDefault("displayName"); |
| | | AttributeType attrType2 = getAttributeTypeOrDefault("displayname"); |
| | | Assert.assertNotSame(attrType, attrType2); |
| | | Assert.assertEquals(attrType, attrType2); |
| | | } |
| | |
| | | |
| | | for (int i = 0; i < types.length; i++) { |
| | | String name = "testType" + i; |
| | | types[i] = DirectoryServer.getDefaultAttributeType(name); |
| | | types[i] = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | } |
| | | |