opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java
@@ -22,10 +22,13 @@ * * * Copyright 2008 Sun Microsystems, Inc. * Portions copyright 2014 ForgeRock AS. */ package org.forgerock.opendj.config; import static org.forgerock.util.Utils.closeSilently; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; @@ -113,12 +116,15 @@ throw new MissingResourceException("Can't find resource " + path, baseName, ""); } final InputStream is = new BufferedInputStream(stream); p = new Properties(); try { p.load(new BufferedInputStream(stream)); p.load(is); } catch (IOException e) { throw new MissingResourceException("Can't load resource " + path + " due to IO exception: " + e.getMessage(), baseName, ""); throw new MissingResourceException("Can't load resource " + path + " due to IO exception: " + e.getMessage(), baseName, ""); } finally { closeSilently(is); } // Cache the resource. opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionUsageBuilder.java
@@ -22,6 +22,7 @@ * * * Copyright 2008-2009 Sun Microsystems, Inc. * Portions copyright 2014 ForgeRock AS. */ package org.forgerock.opendj.config; @@ -42,8 +43,8 @@ /** * Underlying implementation. */ private final class MyPropertyDefinitionVisitor extends PropertyDefinitionVisitor<LocalizableMessage, Void> { private static final class MyPropertyDefinitionVisitor extends PropertyDefinitionVisitor<LocalizableMessage, Void> { // Flag indicating whether detailed syntax information will be // generated. private final boolean isDetailed; opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
@@ -22,6 +22,7 @@ * * * Copyright 2009 Sun Microsystems, Inc. * Portions copyright 2014 ForgeRock AS. */ package org.forgerock.opendj.config.server; @@ -246,13 +247,7 @@ } return pvalues; } } catch (DefinitionDecodingException e) { throw PropertyException.defaultBehaviorException(propDef1, e); } catch (PropertyNotFoundException e) { throw PropertyException.defaultBehaviorException(propDef1, e); } catch (PropertyException e) { throw PropertyException.defaultBehaviorException(propDef1, e); } catch (ConfigException e) { } catch (Exception e) { throw PropertyException.defaultBehaviorException(propDef1, e); } } @@ -262,7 +257,7 @@ * A definition resolver that determines the managed object definition from * the object classes of a ConfigEntry. */ private final class MyDefinitionResolver implements DefinitionResolver { private static final class MyDefinitionResolver implements DefinitionResolver { // The config entry. private final Entry entry; @@ -608,7 +603,7 @@ // Get the configuration entry. DN targetDN = DNBuilder.create(path); try { return (getManagedObjectConfigEntry(targetDN) != null); return (configRepository.getEntry(targetDN) != null); } catch (ConfigException e) { // Assume it doesn't exist. return false; opendj-core/src/main/java/com/forgerock/opendj/util/StaticUtils.java
@@ -27,8 +27,6 @@ package com.forgerock.opendj.util; import java.io.Closeable; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; @@ -36,10 +34,8 @@ import java.nio.charset.Charset; import java.util.Arrays; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.Locale; import java.util.ServiceLoader; import java.util.TimeZone; @@ -47,7 +43,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.forgerock.i18n.LocalizableException; import org.forgerock.i18n.LocalizableMessage; @@ -56,6 +51,7 @@ import org.forgerock.opendj.ldap.ProviderNotFoundException; import org.forgerock.opendj.ldap.spi.Provider; import org.forgerock.util.Reject; import org.forgerock.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,7 +123,7 @@ @Override protected ScheduledExecutorService newInstance() { final ThreadFactory factory = newThreadFactory(null, "OpenDJ LDAP SDK Default Scheduler", true); Utils.newThreadFactory(null, "OpenDJ LDAP SDK Default Scheduler", true); return Executors.newSingleThreadScheduledExecutor(factory); } @@ -1198,40 +1194,6 @@ } /** * Closes the provided resources ignoring any errors which occurred. * * @param resources * The resources to be closed, which may be {@code null}. */ public static void closeSilently(Closeable... resources) { if (resources == null) { return; } closeSilently(Arrays.asList(resources)); } /** * Closes the provided resources ignoring any errors which occurred. * * @param resources * The resources to be closed, which may be {@code null}. */ public static void closeSilently(Iterable<? extends Closeable> resources) { if (resources == null) { return; } for (Closeable r : resources) { try { if (r != null) { r.close(); } } catch (IOException ignored) { // Ignore. } } } /** * Returns a string containing provided date formatted using the generalized * time syntax. * @@ -1508,68 +1470,6 @@ } /** * Returns a string whose content is the string representation of the * objects contained in the provided collection concatenated together using * the provided separator. * * @param c * The collection whose elements are to be joined. * @param separator * The separator string. * @return A string whose content is the string representation of the * objects contained in the provided collection concatenated * together using the provided separator. * @throws NullPointerException * If {@code c} or {@code separator} were {@code null}. */ public static String joinCollection(Collection<?> c, String separator) { Reject.ifNull(c, separator); switch (c.size()) { case 0: return ""; case 1: return String.valueOf(c.iterator().next()); default: StringBuilder builder = new StringBuilder(); Iterator<?> i = c.iterator(); builder.append(i.next()); while (i.hasNext()) { builder.append(separator); builder.append(i.next()); } return builder.toString(); } } /** * Creates a new thread factory which will create threads using the * specified thread group, naming template, and daemon status. * * @param group * The thread group, which may be {@code null}. * @param nameTemplate * The thread name format string which may contain a "%d" format * option which will be substituted with the thread count. * @param isDaemon * Indicates whether or not threads should be daemon threads. * @return The new thread factory. */ public static ThreadFactory newThreadFactory(final ThreadGroup group, final String nameTemplate, final boolean isDaemon) { return new ThreadFactory() { private final AtomicInteger count = new AtomicInteger(); public Thread newThread(Runnable r) { final String name = String.format(nameTemplate, count.getAndIncrement()); final Thread t = new Thread(group, r, name); t.setDaemon(isDaemon); return t; } }; } /** * Retrieves a stack trace from the provided exception as a single-line * string. * opendj-core/src/main/java/org/forgerock/opendj/io/ASN1.java
@@ -113,8 +113,8 @@ * The ASN.1 element decoding state that indicates that the next byte read * should be applied to the value of the element. */ public static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES = 3; public static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES = 3; /** * The byte array that will be used for ASN.1 elements with no value. */ opendj-core/src/main/java/org/forgerock/opendj/io/ASN1InputStreamReader.java
@@ -129,16 +129,16 @@ */ public int peekLength() throws IOException { peekType(); switch (state) { case ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE: needFirstLengthByteState(true, true); break; case ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES: needAdditionalLengthBytesState(true, true); break; default: // ASN1.ELEMENT_READ_STATE_NEED_VALUE_BYTES break; } return peekLength; } @@ -195,7 +195,6 @@ IO_LOG.trace("Ignoring {} unused trailing bytes in ASN.1 SEQUENCE", subSq.getSizeLimit() - subSq.getBytesRead()); } subSq.skip(subSq.getSizeLimit() - subSq.getBytesRead()); } opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestImpl.java
@@ -27,10 +27,9 @@ package org.forgerock.opendj.ldap.requests; import static com.forgerock.opendj.ldap.CoreMessages.ERR_SASL_PROTOCOL_ERROR; import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; import static com.forgerock.opendj.util.StaticUtils.joinCollection; import static com.forgerock.opendj.ldap.CoreMessages.ERR_SASL_PROTOCOL_ERROR; import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; import java.util.HashMap; @@ -54,6 +53,7 @@ import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.responses.BindResult; import org.forgerock.util.Reject; import org.forgerock.util.Utils; import com.forgerock.opendj.util.StaticUtils; @@ -81,7 +81,7 @@ final List<String> qopValues = initialBindRequest.getQOPs(); if (!qopValues.isEmpty()) { props.put(Sasl.QOP, joinCollection(qopValues, ",")); props.put(Sasl.QOP, Utils.joinAsString(",", qopValues)); } final String cipher = initialBindRequest.getCipher(); opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestImpl.java
@@ -27,12 +27,11 @@ package org.forgerock.opendj.ldap.requests; import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; import static com.forgerock.opendj.util.StaticUtils.joinCollection; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED; import static com.forgerock.opendj.ldap.CoreMessages.ERR_SASL_CONTEXT_CREATE_ERROR; import static com.forgerock.opendj.ldap.CoreMessages.ERR_SASL_PROTOCOL_ERROR; import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; import java.security.PrivilegedActionException; @@ -57,6 +56,7 @@ import org.forgerock.opendj.ldap.responses.BindResult; import org.forgerock.opendj.ldap.responses.Responses; import org.forgerock.util.Reject; import org.forgerock.util.Utils; import com.forgerock.opendj.util.StaticUtils; import com.sun.security.auth.callback.TextCallbackHandler; @@ -178,7 +178,7 @@ final List<String> qopValues = initialBindRequest.getQOPs(); if (!qopValues.isEmpty()) { props.put(Sasl.QOP, joinCollection(qopValues, ",")); props.put(Sasl.QOP, Utils.joinAsString(",", qopValues)); } final Boolean serverAuth = initialBindRequest.isServerAuth(); opendj-core/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java
@@ -433,7 +433,7 @@ state = stateGotLDIFLine; } break; case appendingLDIFLine: default: // appendingLDIFLine: if (line == null) { // We have reached the end of the LDIF source. ldifLines.add(lastLineBuilder.toString()); opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIF.java
@@ -68,8 +68,7 @@ import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.schema.AttributeUsage; import org.forgerock.opendj.ldap.schema.Schema; import com.forgerock.opendj.util.StaticUtils; import org.forgerock.util.Utils; /** * This class contains common utility methods for creating and manipulating @@ -335,7 +334,7 @@ // This should never happen for a String based reader. throw new LocalizedIllegalArgumentException(WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e.getMessage())); } finally { StaticUtils.closeSilently(reader); Utils.closeSilently(reader); } if (entries.isEmpty()) { throw new LocalizedIllegalArgumentException(WARN_READ_LDIF_ENTRY_NO_ENTRY_FOUND.get()); opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordReader.java
@@ -27,28 +27,8 @@ package org.forgerock.opendj.ldif; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import static com.forgerock.opendj.ldap.CoreMessages.*; import static com.forgerock.opendj.util.StaticUtils.toLowerCase; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_ATTRIBUTE_NAME_MISMATCH; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_BAD_CHANGE_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_BAD_MODIFICATION_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_CHANGE_EXCLUDED_BY_DN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_ATTRIBUTE_NAME; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_CHANGE_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_CONTROL; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_DELETE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_DELETE_OLD_RDN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_MODIFICATION_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_NEW_RDN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_MALFORMED_NEW_SUPERIOR; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_NO_CHANGE_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_NO_DELETE_OLD_RDN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_NO_NEW_RDN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_UNEXPECTED_BINARY_OPTION; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_UNKNOWN_ATTRIBUTE_TYPE; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR; import java.io.IOException; import java.io.InputStream; @@ -83,8 +63,8 @@ import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy; import org.forgerock.opendj.ldap.schema.Syntax; import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; import org.forgerock.util.Reject; import org.forgerock.util.Utils; /** * An LDIF change record reader reads change records using the LDAP Data @@ -162,7 +142,7 @@ WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e.getMessage()); throw new LocalizedIllegalArgumentException(message); } finally { closeSilently(reader); Utils.closeSilently(reader); } } opendj-core/src/main/java/org/forgerock/opendj/ldif/LDIFEntryReader.java
@@ -27,12 +27,7 @@ package org.forgerock.opendj.ldif; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_ENTRY_EXCLUDED_BY_DN; import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDIF_ENTRY_EXCLUDED_BY_FILTER; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND; import static com.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR; import static com.forgerock.opendj.ldap.CoreMessages.*; import java.io.IOException; import java.io.InputStream; @@ -52,8 +47,8 @@ import org.forgerock.opendj.ldap.Matcher; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy; import org.forgerock.util.Reject; import org.forgerock.util.Utils; /** * An LDIF entry reader reads attribute value records (entries) using the LDAP @@ -108,7 +103,7 @@ WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e.getMessage()); throw new LocalizedIllegalArgumentException(message); } finally { closeSilently(reader); Utils.closeSilently(reader); } } opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java
@@ -80,9 +80,9 @@ import org.forgerock.opendj.ldif.TemplateTag.UnderscoreDNTag; import org.forgerock.opendj.ldif.TemplateTag.UnderscoreParentDNTag; import org.forgerock.util.Reject; import org.forgerock.util.Utils; import com.forgerock.opendj.util.Pair; import com.forgerock.opendj.util.StaticUtils; /** * A template file allow to generate entries from a collection of constant @@ -250,7 +250,7 @@ final List<String> names = readLines(first); firstNames = names.toArray(new String[names.size()]); } finally { StaticUtils.closeSilently(first); Utils.closeSilently(first); } BufferedReader last = null; @@ -262,7 +262,7 @@ final List<String> names = readLines(last); lastNames = names.toArray(new String[names.size()]); } finally { StaticUtils.closeSilently(first); Utils.closeSilently(first); } } @@ -371,7 +371,7 @@ final String[] lines = fileLines.toArray(new String[fileLines.size()]); parse(lines, warnings); } finally { StaticUtils.closeSilently(templateReader); Utils.closeSilently(templateReader); } } @@ -397,7 +397,7 @@ final String[] lines = fileLines.toArray(new String[fileLines.size()]); parse(lines, warnings); } finally { StaticUtils.closeSilently(reader); Utils.closeSilently(reader); } } @@ -1013,7 +1013,7 @@ } break; case PARSING_ESCAPED_CHAR: default: // PARSING_ESCAPED_CHAR: buffer.append(c); phase = previousPhase; break; @@ -1724,12 +1724,11 @@ /** * Returns an entry for this template. * * @return the entry, or null if it can't be generated * @return the entry */ private TemplateEntry buildTemplateEntry() { templateFile.nextFirstAndLastNames(); final TemplateEntry templateEntry = new TemplateEntry(this, parentDN); for (final TemplateLine line : templateLines) { line.generateLine(templateEntry); } @@ -1752,12 +1751,9 @@ // get the template entry if (!currentEntryIsInitialized) { nextEntry = buildTemplateEntry(); if (nextEntry != null) { currentEntryIsInitialized = true; return true; } return false; } // get the next entry from current subtemplate if (nextEntry == null) { for (; subTemplateIndex < subTemplates.size(); subTemplateIndex++) { opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
@@ -44,8 +44,7 @@ import org.forgerock.opendj.ldif.TemplateFile.Template; import org.forgerock.opendj.ldif.TemplateFile.TemplateEntry; import org.forgerock.opendj.ldif.TemplateFile.TemplateValue; import com.forgerock.opendj.util.StaticUtils; import org.forgerock.util.Utils; /** * Represents a tag that may be used in a template line when generating entries. @@ -413,7 +412,7 @@ throw DecodeException.fatalError(message, ioe); } } finally { StaticUtils.closeSilently(dataReader); Utils.closeSilently(dataReader); } // If there is a second argument, then it should be either opendj-core/src/test/java/org/forgerock/opendj/ldif/EntryGeneratorTestCase.java
@@ -45,12 +45,11 @@ import org.forgerock.opendj.ldap.SdkTestCase; import org.forgerock.opendj.ldap.TestCaseUtils; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.util.Utils; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.forgerock.opendj.util.StaticUtils; @SuppressWarnings("javadoc") public class EntryGeneratorTestCase extends SdkTestCase { @@ -82,7 +81,7 @@ System.out.println(generator.readEntry()); } } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -94,7 +93,7 @@ generator = new EntryGenerator(); assertThat(generator.hasNext()).isTrue(); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -106,7 +105,7 @@ generator = new EntryGenerator("unknown/path"); generator.hasNext(); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -120,7 +119,7 @@ assertThat(generator.readEntry().getName().toString()).isEqualTo("uid=user.0,ou=People,dc=example,dc=com"); assertThat(generator.hasNext()).as("should have no more entries").isFalse(); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -200,7 +199,7 @@ } assertThat(generator.hasNext()).as("should have no more entries").isFalse(); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -219,7 +218,7 @@ checkEntryObjectClasses(topEntry, "top", "domainComponent"); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -240,7 +239,7 @@ checkEntryObjectClasses(entry, "top", "organizationalUnit"); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -265,7 +264,7 @@ checkEntryObjectClasses(entry, "top", "person", "organizationalPerson", "inetOrgPerson"); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -363,7 +362,7 @@ } assertThat(generator.hasNext()).isFalse(); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -589,7 +588,7 @@ assertThat(entry).isNotNull(); assertThat(entry.getAttribute(attrName).firstValueAsString()).isEqualTo(expectedValue); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } @@ -622,7 +621,7 @@ assertThat(entry).isNotNull(); assertThat(entry.getAttribute("cn").firstValueAsString()).matches("Foo <[A-Z]>\\{1\\}Bar"); } finally { StaticUtils.closeSilently(generator); Utils.closeSilently(generator); } } } opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
@@ -788,7 +788,7 @@ writer.flush(); } catch (final IOException e) { System.err.println(e.getMessage()); System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue()); return false; } return true; } opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java
@@ -110,17 +110,17 @@ private static final class Rewriter implements RequestHandler<RequestContext> { // This example hard codes the attribute... private final String clientAttributeTypeName = "fullname"; private final String serverAttributeTypeName = "cn"; private static final String CLIENT_ATTRIBUTE = "fullname"; private static final String SERVER_ATTRIBUTE = "cn"; // ...and DN rewriting configuration. private final CharSequence clientSuffix = "o=example"; private final CharSequence serverSuffix = "dc=example,dc=com"; private static final String CLIENT_SUFFIX = "o=example"; private static final String SERVER_SUFFIX = "dc=example,dc=com"; private final AttributeDescription clientAttributeDescription = AttributeDescription .valueOf(clientAttributeTypeName); .valueOf(CLIENT_ATTRIBUTE); private final AttributeDescription serverAttributeDescription = AttributeDescription .valueOf(serverAttributeTypeName); .valueOf(SERVER_ATTRIBUTE); // Next request handler in the chain. private final RequestHandler<RequestContext> nextHandler; @@ -222,8 +222,8 @@ private AddRequest rewrite(final AddRequest request) { // Transform the client DN into a server DN. final AddRequest rewrittenRequest = Requests.copyOfAddRequest(request); rewrittenRequest.setName(request.getName().toString().replace(clientSuffix, serverSuffix)); rewrittenRequest.setName(request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); /* * Transform the client attribute names into server attribute names, * fullname;lang-fr ==> cn;lang-fr. @@ -232,7 +232,7 @@ if (a != null) { final String ad = a.getAttributeDescriptionAsString().replaceFirst( clientAttributeTypeName, serverAttributeTypeName); CLIENT_ATTRIBUTE, SERVER_ATTRIBUTE); final Attribute serverAttr = Attributes.renameAttribute(a, AttributeDescription.valueOf(ad)); rewrittenRequest.addAttribute(serverAttr); @@ -253,21 +253,21 @@ * fullname;lang-fr ==> cn;lang-fr. */ final String ad = request.getAttributeDescription().toString(); if (ad.toLowerCase().startsWith(clientAttributeTypeName.toLowerCase())) { if (ad.toLowerCase().startsWith(CLIENT_ATTRIBUTE.toLowerCase())) { final String serverAttrDesc = ad.replaceFirst(clientAttributeTypeName, serverAttributeTypeName); ad.replaceFirst(CLIENT_ATTRIBUTE, SERVER_ATTRIBUTE); request.setAttributeDescription(AttributeDescription.valueOf(serverAttrDesc)); } // Transform the client DN into a server DN. return request .setName(request.getName().toString().replace(clientSuffix, serverSuffix)); .setName(request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); } private DeleteRequest rewrite(final DeleteRequest request) { // Transform the client DN into a server DN. return request .setName(request.getName().toString().replace(clientSuffix, serverSuffix)); .setName(request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); } private <S extends ExtendedResult> ExtendedRequest<S> rewrite( @@ -280,21 +280,21 @@ // Transform the client DNs into server DNs. if (request.getNewSuperior() != null) { return request.setName( request.getName().toString().replace(clientSuffix, serverSuffix)) request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)) .setNewSuperior( request.getNewSuperior().toString().replace(clientSuffix, serverSuffix)); request.getNewSuperior().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); } else { return request.setName(request.getName().toString().replace(clientSuffix, serverSuffix)); return request.setName(request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); } } private ModifyRequest rewrite(final ModifyRequest request) { // Transform the client DN into a server DN. final ModifyRequest rewrittenRequest = Requests.newModifyRequest(request.getName().toString().replace(clientSuffix, serverSuffix)); Requests.newModifyRequest(request.getName().toString().replace(CLIENT_SUFFIX, SERVER_SUFFIX)); /* * Transform the client attribute names into server attribute names, @@ -309,7 +309,7 @@ if (at.equals(clientAttributeDescription.getAttributeType())) { final AttributeDescription serverAttrDesc = AttributeDescription.valueOf(ad.toString().replaceFirst( clientAttributeTypeName, serverAttributeTypeName)); CLIENT_ATTRIBUTE, SERVER_ATTRIBUTE)); rewrittenRequest.addModification(new Modification(mod.getModificationType(), Attributes.renameAttribute(a, serverAttrDesc))); } else { @@ -331,9 +331,9 @@ final String[] a = new String[request.getAttributes().size()]; int count = 0; for (final String attrName : request.getAttributes()) { if (attrName.toLowerCase().startsWith(clientAttributeTypeName.toLowerCase())) { if (attrName.toLowerCase().startsWith(CLIENT_ATTRIBUTE.toLowerCase())) { a[count] = attrName.replaceFirst(clientAttributeTypeName, serverAttributeTypeName); attrName.replaceFirst(CLIENT_ATTRIBUTE, SERVER_ATTRIBUTE); } else { a[count] = attrName; } @@ -347,9 +347,9 @@ * this implementation will not work. */ return Requests.newSearchRequest(DN.valueOf(request.getName().toString().replace( clientSuffix, serverSuffix)), request.getScope(), Filter.valueOf(request .getFilter().toString().replace(clientAttributeTypeName, serverAttributeTypeName)), a); CLIENT_SUFFIX, SERVER_SUFFIX)), request.getScope(), Filter.valueOf(request .getFilter().toString().replace(CLIENT_ATTRIBUTE, SERVER_ATTRIBUTE)), a); } private SearchResultEntry rewrite(final SearchResultEntry entry) { @@ -363,7 +363,7 @@ if (at.equals(serverAttributeDescription.getAttributeType())) { final AttributeDescription clientAttrDesc = AttributeDescription.valueOf(ad.toString().replaceFirst( serverAttributeTypeName, clientAttributeTypeName)); SERVER_ATTRIBUTE, CLIENT_ATTRIBUTE)); attrsToAdd.add(Attributes.renameAttribute(a, clientAttrDesc)); attrsToRemove.add(ad); } @@ -379,7 +379,7 @@ } // Transform the server DN suffix into a client DN suffix. return entry.setName(entry.getName().toString().replace(serverSuffix, clientSuffix)); return entry.setName(entry.getName().toString().replace(SERVER_SUFFIX, CLIENT_SUFFIX)); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -30,7 +30,6 @@ import static com.forgerock.opendj.ldap.tools.ToolConstants.*; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import java.io.FileInputStream; import java.io.IOException; @@ -504,7 +503,7 @@ return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue(); } } finally { closeSilently(reader, connection); org.forgerock.util.Utils.closeSilently(reader, connection); } return ResultCode.SUCCESS.intValue(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -30,7 +30,6 @@ import static com.forgerock.opendj.ldap.tools.ToolConstants.*; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import java.io.BufferedReader; import java.io.FileReader; @@ -945,7 +944,7 @@ } catch (final ErrorResultException ere) { return Utils.printErrorMessage(this, ere); } finally { closeSilently(ldifWriter, connection); org.forgerock.util.Utils.closeSilently(ldifWriter, connection); } return 0; opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java
@@ -48,6 +48,7 @@ import org.forgerock.opendj.ldap.ResultHandler; import org.forgerock.opendj.ldap.responses.ExtendedResult; import org.forgerock.opendj.ldap.responses.Result; import org.forgerock.util.Utils; import com.forgerock.opendj.ldap.tools.AuthenticatedConnectionFactory.AuthenticatedConnection; import com.forgerock.opendj.util.StaticUtils; @@ -858,7 +859,7 @@ stopRequested = true; app.println(LocalizableMessage.raw(e.getResult().getDiagnosticMessage())); } finally { StaticUtils.closeSilently(connections); Utils.closeSilently(connections); } return 0; opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/MakeLDIFTestCase.java
@@ -26,7 +26,6 @@ package com.forgerock.opendj.ldap.tools; import static org.fest.assertions.Assertions.*; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import java.io.ByteArrayOutputStream; @@ -37,8 +36,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.forgerock.opendj.util.StaticUtils; @SuppressWarnings("javadoc") public class MakeLDIFTestCase extends ToolsTestCase { @@ -112,7 +109,7 @@ assertThat(err.toString("UTF-8")).contains(Utils.wrapText(expectedErrOutput, Utils.MAX_LINE_WIDTH)); } finally { StaticUtils.closeSilently(outStream, errStream); org.forgerock.util.Utils.closeSilently(outStream, errStream); } } opendj-rest2ldap-servlet/src/main/java/org/forgerock/opendj/rest2ldap/servlet/Rest2LDAPConnectionFactoryProvider.java
@@ -37,8 +37,7 @@ import org.forgerock.opendj.rest2ldap.AuthorizationPolicy; import org.forgerock.opendj.rest2ldap.Rest2LDAP; import org.forgerock.opendj.rest2ldap.Rest2LDAP.Builder; import com.forgerock.opendj.util.StaticUtils; import org.forgerock.util.Utils; /** * The connection factory provider which is used by the OpenDJ Commons REST LDAP @@ -149,7 +148,7 @@ throw new ServletException("Servlet configuration file '" + configFileName + "' could not be read: " + e.getMessage()); } finally { StaticUtils.closeSilently(configFile); Utils.closeSilently(configFile); } } opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/AbstractLDAPAttributeMapper.java
@@ -250,8 +250,10 @@ } }, h)); } } catch (final Exception e) { } catch (final RuntimeException e) { h.handleError(asResourceException(e)); } catch (final ResourceException e) { h.handleError(e); } } opendj-server-example-plugin/src/main/java/com/example/opendj/ExamplePlugin.java
@@ -42,10 +42,6 @@ public class ExamplePlugin implements ConfigurationChangeListener<ExamplePluginCfg> { // FIXME: fill in the remainder of this class once the server plugin API is migrated. // The current configuration. @SuppressWarnings("unused") private ExamplePluginCfg config; /** * Default constructor. */ @@ -60,10 +56,7 @@ public ConfigChangeResult applyConfigurationChange(final ExamplePluginCfg config) { // The new configuration has already been validated. // Update the configuration. this.config = config; // Update was successfull, no restart required. // Update was successful, no restart required. return new ConfigChangeResult(ResultCode.SUCCESS, false); } opendj-server/src/main/java/org/forgerock/opendj/server/core/ProductInformation.java
@@ -26,6 +26,8 @@ package org.forgerock.opendj.server.core; import static org.forgerock.util.Utils.closeSilently; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; @@ -62,11 +64,14 @@ } properties = new Properties(); final InputStream is = new BufferedInputStream(stream); try { properties.load(new BufferedInputStream(stream)); properties.load(is); } catch (final IOException e) { throw new MissingResourceException("Can't load product information " + resourceName + " due to IO exception: " + e.getMessage(), productName, ""); } finally { closeSilently(is); } versionFull = pom.xml
@@ -445,7 +445,7 @@ <dependency> <groupId>org.forgerock.commons</groupId> <artifactId>forgerock-util</artifactId> <version>1.2.0-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version> </dependency> </dependencies> </dependencyManagement>