[maven-release-plugin] copy for tag 1.0.0
git-svn-id: https://svn.apache.org/repos/asf/directory/shared/tags/1.0.0@1797299 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f59847a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+target/
+.project
+.classpath
+.settings/
+.svn/
+bin/
+# Intellij
+*.ipr
+*.iml
+.idea
+out/
+.DS_Store
+/bootstrap
+/dependencies.xml
+.java-version
+META-INF/
+dependency-reduced-pom.xml
+
diff --git a/LICENSE b/LICENSE
index b6f663f..820c52a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -226,3 +226,23 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+==================================================================================================
+jBCrypt 0.4.1 license
+--------------------------------------------------------------------------------------------------
+jBCrypt is subject to the following license:
+
+/*
+ * Copyright (c) 2006 Damien Miller <djm@mindrot.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
\ No newline at end of file
diff --git a/all/pom.xml b/all/pom.xml
index 1289d97..ec19345 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-all</artifactId>
diff --git a/asn1/api/pom.xml b/asn1/api/pom.xml
index 64e07f3..69d5ec0 100644
--- a/asn1/api/pom.xml
+++ b/asn1/api/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-asn1-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-asn1-api</artifactId>
diff --git a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
index 7e7da26..33f7d81 100644
--- a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
+++ b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
@@ -71,7 +71,7 @@
return "";
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for ( byte b : buffer )
{
diff --git a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
index 16b2f29..438cde5 100644
--- a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
+++ b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
@@ -64,7 +64,7 @@
nbBits = length;
// As we store values in bytes, we must divide the length by 8
- nbBytes = ( length / 8 );
+ nbBytes = length / 8;
if ( ( length % 8 ) != 0 )
{
diff --git a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
index f720c30..34ecaeb 100644
--- a/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
+++ b/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
@@ -249,7 +249,7 @@
result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) );
result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) );
result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 );
break;
case 6 :
@@ -258,7 +258,7 @@
result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) );
result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) );
result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 );
break;
case 5 :
@@ -266,29 +266,29 @@
result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) );
result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) );
result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 );
break;
case 4 :
result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) );
result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) );
result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 );
break;
case 3 :
result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) );
result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 );
break;
case 2 :
result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) );
- result[pos--] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 );
+ result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 );
break;
case 1 :
- result[pos--] = ( byte ) ( oidBytes[0] & 0x7F );
+ result[pos] = ( byte ) ( oidBytes[0] & 0x7F );
break;
default :
@@ -296,7 +296,7 @@
break;
}
- BigInteger bigInteger = null;
+ BigInteger bigInteger;
if ( ( result[0] & 0x80 ) == 0x80 )
{
@@ -352,7 +352,6 @@
// normal processing
builder.append( '.' ).append( value );
- value = 0;
}
valStart = i;
@@ -621,16 +620,17 @@
{
char c = oid.charAt( pos );
- switch ( c )
+ if ( c == '.' )
{
- case '.' :
- // The first 2 arcs are single digit, we can collapse them in one byte.
- buffer[0] = ( byte ) ( 80 + buffer[1] );
- return OidFSAState.STATE_K;
-
- default :
- // Expecting a digit here
- throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a digit is expected" ) );
+ // The first 2 arcs are single digit, we can collapse them in one byte.
+ buffer[0] = ( byte ) ( 80 + buffer[1] );
+
+ return OidFSAState.STATE_K;
+ }
+ else
+ {
+ // Expecting a digit here
+ throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a digit is expected" ) );
}
}
@@ -756,14 +756,14 @@
{
char c = oid.charAt( pos );
- switch ( c )
+ if ( c == '.' )
{
- case '.' :
return OidFSAState.STATE_K;
-
- default :
- // Expecting a '.' here
- throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a '.' is expected" ) );
+ }
+ else
+ {
+ // Expecting a '.' here
+ throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a '.' is expected" ) );
}
}
@@ -1078,7 +1078,7 @@
int startArc = 0;
// The number of bytes in the resulting OID byte[]
- int nbBytes = 0;
+ int nbBytes;
for ( int i = 0; i < oidString.length(); i++ )
{
diff --git a/asn1/ber/pom.xml b/asn1/ber/pom.xml
index 412f111..2eedb79 100644
--- a/asn1/ber/pom.xml
+++ b/asn1/ber/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-asn1-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-asn1-ber</artifactId>
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadBitString.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadBitString.java
index 4a0fd8d..ff7c409 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadBitString.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadBitString.java
@@ -33,7 +33,7 @@
/**
* The action used read a BITSTRING from a TLV
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -70,6 +70,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void action( C container ) throws DecoderException
{
TLV tlv = container.getCurrentTLV();
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
index fdf009e..1d8c9c4 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
@@ -36,7 +36,7 @@
/**
* The action used to read an integer value
*
- * @param E The container type
+ * @param <E> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -96,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void action( E container ) throws DecoderException
{
TLV tlv = container.getCurrentTLV();
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadOctetString.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadOctetString.java
index 2a18807..82f7da7 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadOctetString.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadOctetString.java
@@ -33,7 +33,7 @@
/**
* The action used to read an OCTET STRING value
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -83,6 +83,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void action( C container ) throws DecoderException
{
TLV tlv = container.getCurrentTLV();
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/CheckNotNullLength.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/CheckNotNullLength.java
index 3287378..085a61a 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/CheckNotNullLength.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/CheckNotNullLength.java
@@ -32,7 +32,7 @@
/**
* An action that checks the length is not null
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -54,6 +54,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void action( C container ) throws DecoderException
{
TLV tlv = container.getCurrentTLV();
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/AbstractContainer.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/AbstractContainer.java
index a8f961c..0a7dbf9 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/AbstractContainer.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/AbstractContainer.java
@@ -97,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Grammar<?> getGrammar()
{
return grammar;
@@ -106,6 +107,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setGrammar( Grammar<?> grammar )
{
this.grammar = grammar;
@@ -115,6 +117,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public TLVStateEnum getState()
{
return state;
@@ -124,6 +127,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setState( TLVStateEnum state )
{
this.state = state;
@@ -133,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isGrammarEndAllowed()
{
return grammarEndAllowed;
@@ -142,6 +147,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setGrammarEndAllowed( boolean grammarEndAllowed )
{
this.grammarEndAllowed = grammarEndAllowed;
@@ -151,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Enum<?> getTransition()
{
return transition;
@@ -160,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTransition( Enum<?> transition )
{
this.transition = transition;
@@ -169,6 +177,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCurrentTLV( TLV currentTLV )
{
this.tlv = currentTLV;
@@ -178,6 +187,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public TLV getCurrentTLV()
{
return this.tlv;
@@ -187,6 +197,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public TLV getParentTLV()
{
return parentTLV;
@@ -196,6 +207,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setParentTLV( TLV parentTLV )
{
this.parentTLV = parentTLV;
@@ -217,6 +229,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getNewTlvId()
{
return id++;
@@ -226,6 +239,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTlvId()
{
return tlv.getId();
@@ -235,6 +249,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getDecodedBytes()
{
return decodedBytes;
@@ -244,6 +259,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDecodedBytes( int decodedBytes )
{
this.decodedBytes = decodedBytes;
@@ -253,6 +269,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void incrementDecodedBytes( int nb )
{
decodedBytes += nb;
@@ -262,6 +279,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getMaxPDUSize()
{
return maxPDUSize;
@@ -271,6 +289,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMaxPDUSize( int maxPDUSize )
{
if ( maxPDUSize > 0 )
@@ -287,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ByteBuffer getStream()
{
return stream;
@@ -296,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setStream( ByteBuffer stream )
{
this.stream = stream;
@@ -305,6 +326,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rewind()
{
@@ -316,6 +338,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void updateParent()
{
TLV parentTlv = tlv.getParent();
@@ -332,6 +355,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isGathering()
{
return gathering;
@@ -341,9 +365,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setGathering( boolean gathering )
{
this.gathering = gathering;
}
-
}
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
index 3972a55..57c9088 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
@@ -125,7 +125,7 @@
*/
private void dumpTLVTree( Asn1Container container )
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
TLV current = container.getCurrentTLV();
sb.append( "TLV" ).append( Asn1StringUtils.dumpByte( current.getTag() ) ).append( "(" ).append(
@@ -172,7 +172,7 @@
if ( ( value != null ) && ( value.getData() != null ) )
{
- return ( current.getExpectedLength() == value.getData().length );
+ return current.getExpectedLength() == value.getData().length;
}
else
{
@@ -307,7 +307,7 @@
*/
private String getParentLength( TLV tlv )
{
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append( "TLV expected length stack : " );
@@ -789,6 +789,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getMaxLengthLength()
{
return maxLengthLength;
@@ -798,6 +799,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getMaxTagLength()
{
return maxTagLength;
@@ -807,6 +809,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void disallowIndefiniteLength()
{
this.indefiniteLengthAllowed = false;
@@ -816,6 +819,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void allowIndefiniteLength()
{
this.indefiniteLengthAllowed = true;
@@ -825,6 +829,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isIndefiniteLengthAllowed()
{
@@ -835,6 +840,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMaxLengthLength( int maxLengthLength ) throws DecoderException
{
if ( ( this.indefiniteLengthAllowed ) && ( maxLengthLength > 126 ) )
@@ -849,6 +855,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMaxTagLength( int maxTagLength )
{
this.maxTagLength = maxTagLength;
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/AbstractGrammar.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/AbstractGrammar.java
index ee04c27..784d1d2 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/AbstractGrammar.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/AbstractGrammar.java
@@ -32,7 +32,7 @@
* The abstract Grammar which is the Mother of all the grammars. It contains
* the transitions table.
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -64,6 +64,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getName()
{
return name;
@@ -73,6 +74,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setName( String name )
{
this.name = name;
@@ -95,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void executeAction( C container ) throws DecoderException
{
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Action.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Action.java
index 0e6bf95..5bd50b5 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Action.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Action.java
@@ -28,7 +28,7 @@
* Action interface just contains the method 'action' which must be implemented
* in all the implementing classes.
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Grammar.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Grammar.java
index b2157dd..b4ba950 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Grammar.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/Grammar.java
@@ -27,7 +27,7 @@
/**
* The interface which expose common behavior of a Grammar implementer.
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarAction.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarAction.java
index a0e9044..1209ed4 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarAction.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarAction.java
@@ -27,7 +27,7 @@
* A top level grammar class that store meta informations about the actions.
* Those informations are not mandatory, but they can be useful for debugging.
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -59,6 +59,7 @@
*
* @return The action's name
*/
+ @Override
public String toString()
{
return name;
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarTransition.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarTransition.java
index 848ae23..38722c9 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarTransition.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/grammar/GrammarTransition.java
@@ -29,7 +29,7 @@
* Define a transition between two states of a grammar. It stores the next
* state, and the action to execute while executing the transition.
*
- * @param C The container type
+ * @param <C> The container type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/BerValue.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/BerValue.java
index 715aee5..f280a43 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/BerValue.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/BerValue.java
@@ -310,7 +310,7 @@
*/
public static byte[] getBytes( int value )
{
- byte[] bytes = null;
+ byte[] bytes;
if ( value >= 0 )
{
@@ -354,9 +354,6 @@
}
else
{
- // We have to compute the complement, and add 1
- //value = ( ~value ) + 1;
-
if ( value >= 0xFFFFFF80 )
{
bytes = new byte[1];
@@ -455,7 +452,7 @@
*/
public static byte[] getBytes( long value )
{
- byte[] bytes = null;
+ byte[] bytes;
if ( value >= 0 )
{
@@ -545,9 +542,6 @@
}
else
{
- // We have to compute the complement, and add 1
- // value = ( ~value ) + 1;
-
if ( value >= 0xFFFFFFFFFFFFFF80L )
{
bytes = new byte[1];
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
index 28f350b..d2a95e2 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
@@ -443,6 +443,7 @@
*
* @return A String
*/
+ @Override
public String toString()
{
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/UniversalTag.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/UniversalTag.java
index b7f309f..e4697bb 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/UniversalTag.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/UniversalTag.java
@@ -278,7 +278,7 @@
*
* @param value The tag value
*/
- private UniversalTag( byte value )
+ UniversalTag( byte value )
{
this.value = value;
}
diff --git a/asn1/pom.xml b/asn1/pom.xml
index 100a052..84796b2 100644
--- a/asn1/pom.xml
+++ b/asn1/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-asn1-parent</artifactId>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 1483a2d..bc5155c 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>apache-ldap-api</artifactId>
diff --git a/distribution/src/main/release/NOTICE b/distribution/src/main/release/NOTICE
index 6dd29ad..dab3426 100644
--- a/distribution/src/main/release/NOTICE
+++ b/distribution/src/main/release/NOTICE
@@ -11,7 +11,7 @@
This product includes/uses Apache Commons (http://commons.apache.org/).
-This product includes/uses Apache Loggin Services (http://logging.apache.org/).
+This product includes/uses Apache Logging Services (http://logging.apache.org/).
This product includes/uses Apache Felix (http://felix.apache.org/).
@@ -31,3 +31,5 @@
developed by QOS.ch (http://www.qos.ch)
This product includes/uses software, XMLPullParser 3 - xpp3:xpp3:jar:1.1.3.4.O (http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/)
+
+This product includes/uses software, jBCrypt 0.4.1 (http://www.mindrot.org/files/jBCrypt)
diff --git a/distribution/src/main/release/licenses/jbcrypt-LICENSE.txt b/distribution/src/main/release/licenses/jbcrypt-LICENSE.txt
new file mode 100644
index 0000000..bf0d67b
--- /dev/null
+++ b/distribution/src/main/release/licenses/jbcrypt-LICENSE.txt
@@ -0,0 +1,18 @@
+jBCrypt is subject to the following license:
+
+/*
+ * Copyright (c) 2006 Damien Miller <djm@mindrot.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
diff --git a/dsml/engine/pom.xml b/dsml/engine/pom.xml
index d06d16a..79f521b 100644
--- a/dsml/engine/pom.xml
+++ b/dsml/engine/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-dsml-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-dsml-engine</artifactId>
diff --git a/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java b/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
index dfea393..a5d15d7 100644
--- a/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
+++ b/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
@@ -24,7 +24,6 @@
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -192,7 +191,7 @@
* @throws XmlPullParserException if an error occurs in the parser
* @throws FileNotFoundException if the file does not exist
*/
- public String processDSMLFile( String fileName ) throws XmlPullParserException, FileNotFoundException
+ public String processDSMLFile( String fileName ) throws XmlPullParserException, IOException
{
parser = new Dsmlv2Parser( grammar );
parser.setInputFile( fileName );
diff --git a/dsml/parser/pom.xml b/dsml/parser/pom.xml
index fe7bd3c..5607e74 100644
--- a/dsml/parser/pom.xml
+++ b/dsml/parser/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-dsml-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-dsml-parser</artifactId>
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2Parser.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2Parser.java
index c920cb7..3b2f188 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2Parser.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2Parser.java
@@ -20,14 +20,14 @@
package org.apache.directory.api.dsmlv2;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import org.apache.directory.api.dsmlv2.request.BatchRequestDsml;
import org.apache.directory.api.dsmlv2.request.Dsmlv2Grammar;
@@ -121,10 +121,13 @@
* @throws FileNotFoundException if the file does not exist
* @throws XmlPullParserException if an error occurs in the parser
*/
- public void setInputFile( String fileName ) throws FileNotFoundException, XmlPullParserException
+ public void setInputFile( String fileName ) throws IOException, XmlPullParserException
{
- Reader reader = new InputStreamReader( new FileInputStream( fileName ), Charset.defaultCharset() );
- container.getParser().setInput( reader );
+ try ( Reader reader = new InputStreamReader( Files.newInputStream( Paths.get( ( fileName ) ) ),
+ Charset.defaultCharset() ) )
+ {
+ container.getParser().setInput( reader );
+ }
}
@@ -155,7 +158,7 @@
/**
* Launches the parsing on the input
- * This method will parse the whole DSML document, without considering the flag {@link #storeMsgInBatchReq}
+ * This method will parse the whole DSML document, without considering the flag storeMsgInBatchReq
* @throws XmlPullParserException when an unrecoverable error occurs
* @throws IOException when an IO execption occurs
*/
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2ResponseParser.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2ResponseParser.java
index 660d8ee..1fb3d19 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2ResponseParser.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2ResponseParser.java
@@ -20,14 +20,14 @@
package org.apache.directory.api.dsmlv2;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import org.apache.directory.api.dsmlv2.response.BatchResponseDsml;
import org.apache.directory.api.dsmlv2.response.Dsmlv2ResponseGrammar;
@@ -91,10 +91,13 @@
* @throws FileNotFoundException if the file does not exist
* @throws XmlPullParserException if an error occurs in the parser
*/
- public void setInputFile( String fileName ) throws FileNotFoundException, XmlPullParserException
+ public void setInputFile( String fileName ) throws IOException, XmlPullParserException
{
- Reader reader = new InputStreamReader( new FileInputStream( fileName ), Charset.defaultCharset() );
- container.getParser().setInput( reader );
+ try ( Reader reader = new InputStreamReader( Files.newInputStream( Paths.get( fileName ) ),
+ Charset.defaultCharset() ) )
+ {
+ container.getParser().setInput( reader );
+ }
}
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2StatesEnum.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2StatesEnum.java
index 501c715..6910f4a 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2StatesEnum.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/Dsmlv2StatesEnum.java
@@ -40,6 +40,7 @@
/** The <batchRequest> tag */
BATCHREQUEST_START_TAG,
+ /** The BatchRequest loop */
BATCHREQUEST_LOOP,
/** The </batchRequest> tag */
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbandonRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbandonRequestDsml.java
index fe946b6..b340cd6 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbandonRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbandonRequestDsml.java
@@ -78,7 +78,7 @@
// AbandonID
if ( getDecorated().getAbandoned() != 0 )
{
- element.addAttribute( "abandonID", "" + getDecorated().getAbandoned() );
+ element.addAttribute( "abandonID", Integer.toString( getDecorated().getAbandoned() ) );
}
return element;
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractRequestDsml.java
index 7ada419..b84d5eb 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractRequestDsml.java
@@ -32,6 +32,8 @@
/**
* Abstract class for DSML requests.
+ *
+ * @param <E> The request type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -65,7 +67,7 @@
int requestID = getDecorated().getMessageId();
if ( requestID > 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
// Controls
@@ -118,12 +120,22 @@
}
+ /**
+ * @return the buffer's length (always 0)
+ */
public int computeLength()
{
return 0;
}
+ /**
+ * Encode the request. Always return an empty buffer.
+ *
+ * @param buffer The buffer to allocate
+ * @return The resulting buffer
+ * @throws EncoderException If we had an error while encoding the request
+ */
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
return null;
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractResultResponseRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractResultResponseRequestDsml.java
index 0cdfaa7..ea74cc2 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractResultResponseRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/AbstractResultResponseRequestDsml.java
@@ -35,6 +35,9 @@
/**
* Abstract class for DSML requests.
*
+ * @param <E> The response request result type
+ * @param <F> The response result type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractResultResponseRequestDsml<E extends ResultResponseRequest, F extends ResultResponse>
@@ -69,7 +72,7 @@
int requestID = getDecorated().getMessageId();
if ( requestID > 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
// Controls
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/BatchRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/BatchRequestDsml.java
index 15b354e..b588dcc 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/BatchRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/BatchRequestDsml.java
@@ -282,7 +282,7 @@
// RequestID
if ( requestID != 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
// ResponseOrder
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ExtendedRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ExtendedRequestDsml.java
index b8c6918..931cc3d 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ExtendedRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ExtendedRequestDsml.java
@@ -34,6 +34,9 @@
/**
* DSML Decorator for ExtendedRequest
+ *
+ * @param <Q> The extended request type
+ * @param <P> The extended response type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResponseDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResponseDsml.java
index 1c1ac3b..9ea6b6d 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResponseDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResponseDsml.java
@@ -28,6 +28,8 @@
/**
* Base class for all DSML responses.
*
+ * @param <E> The response type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractResponseDsml<E extends Response>
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResultResponseDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResultResponseDsml.java
index e9ad6a2..b4195a5 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResultResponseDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/AbstractResultResponseDsml.java
@@ -23,12 +23,13 @@
import org.apache.directory.api.ldap.codec.api.LdapApiService;
import org.apache.directory.api.ldap.model.message.LdapResult;
import org.apache.directory.api.ldap.model.message.ResultResponse;
-import org.dom4j.Element;
/**
* Base class for all DSML responses.
*
+ * @param <E> The response result type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractResultResponseDsml<E extends ResultResponse>
@@ -49,12 +50,6 @@
/**
* {@inheritDoc}
*/
- public abstract Element toDsml( Element root );
-
-
- /**
- * {@inheritDoc}
- */
public LdapResult getLdapResult()
{
return getDecorated().getLdapResult();
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/BatchResponseDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/BatchResponseDsml.java
index 4bd72b1..eaeef34 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/BatchResponseDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/BatchResponseDsml.java
@@ -154,7 +154,7 @@
// RequestID
if ( requestID != 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
for ( DsmlDecorator<? extends Response> response : responses )
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ErrorResponse.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ErrorResponse.java
index 2d407bd..090ee19 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ErrorResponse.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ErrorResponse.java
@@ -138,7 +138,7 @@
// RequestID
if ( requestID != 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
// Type
@@ -275,6 +275,9 @@
}
+ /**
+ * @return The LdapApiService instance
+ */
public LdapApiService getCodecService()
{
throw new IllegalArgumentException( "This should not be a decorator "
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/LdapResultDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/LdapResultDsml.java
index 8a79a8b..d8fc402 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/LdapResultDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/LdapResultDsml.java
@@ -77,7 +77,7 @@
int requestID = message.getMessageId();
if ( requestID > 0 )
{
- root.addAttribute( "requestID", "" + requestID );
+ root.addAttribute( "requestID", Integer.toString( requestID ) );
}
// Matched Dn
@@ -93,12 +93,13 @@
// ResultCode
Element resultCodeElement = root.addElement( "resultCode" );
- resultCodeElement.addAttribute( "code", "" + result.getResultCode().getResultCode() );
+ resultCodeElement.addAttribute( "code", Integer.toString( result.getResultCode().getResultCode() ) );
resultCodeElement.addAttribute( "descr", result.getResultCode().getMessage() );
// ErrorMessage
String errorMessage = ( result.getDiagnosticMessage() );
- if ( ( errorMessage != null ) && ( !errorMessage.equals( "" ) ) )
+
+ if ( ( errorMessage != null ) && ( errorMessage.length() != 0 ) )
{
Element errorMessageElement = root.addElement( "errorMessage" );
errorMessageElement.addText( errorMessage );
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/SearchResponseDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/SearchResponseDsml.java
index 5d7e439..a1c4812 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/SearchResponseDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/SearchResponseDsml.java
@@ -165,7 +165,7 @@
int requestID = getDecorated().getMessageId();
if ( requestID > 0 )
{
- element.addAttribute( "requestID", "" + requestID );
+ element.addAttribute( "requestID", Integer.toString( requestID ) );
}
}
diff --git a/dsml/pom.xml b/dsml/pom.xml
index a50a1b6..ae3ad3c 100644
--- a/dsml/pom.xml
+++ b/dsml/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-dsml-parent</artifactId>
diff --git a/i18n/pom.xml b/i18n/pom.xml
index 18a7deb..6bc939d 100644
--- a/i18n/pom.xml
+++ b/i18n/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-i18n</artifactId>
diff --git a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
index 1796739..daf89b5 100644
--- a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
@@ -626,7 +626,8 @@
ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY("ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY"),
ERR_04486_VALUE_ALREADY_EXISTS("ERR_04486_VALUE_ALREADY_EXISTS"),
ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED("ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED"),
-
+ ERR_04488_SYNTAX_INVALID("ERR_04488_SYNTAX_INVALID"),
+
// ldap-constants
ERR_05001_UNKNOWN_AUTHENT_LEVEL("ERR_05001_UNKNOWN_AUTHENT_LEVEL"),
@@ -773,18 +774,28 @@
ERR_12084("ERR_12084"),
ERR_12085("ERR_12085"),
ERR_12086("ERR_12086"),
- ERR_12087("ERR_12087");
+ ERR_12087("ERR_12087"),
+ // The messages
+ MSG_04489_SYNTAX_VALID( "MSG_04489_SYNTAX_VALID" );
+
/** The error code */
private String errorCode;
+ /** The file containing the errors */
+ private static final ResourceBundle ERR_BUNDLE = ResourceBundle
+ .getBundle( "org/apache/directory/api/i18n/errors", Locale.ROOT );
+
+ /** The file containing the messages */
+ private static final ResourceBundle MSG_BUNDLE = ResourceBundle
+ .getBundle( "org/apache/directory/api/i18n/messages", Locale.ROOT );
/**
* Creates a new instance of I18n.
*
* @param errorCode the error code
*/
- private I18n( String errorCode )
+ I18n( String errorCode )
{
this.errorCode = errorCode;
}
@@ -801,14 +812,6 @@
return errorCode;
}
- /** The file containing the errors */
- private static final ResourceBundle ERR_BUNDLE = ResourceBundle
- .getBundle( "org/apache/directory/api/i18n/errors" );
-
- /** The file containing the messages */
- private static final ResourceBundle MSG_BUNDLE = ResourceBundle
- .getBundle( "org/apache/directory/api/i18n/messages" );
-
/**
*
@@ -849,6 +852,43 @@
/**
*
+ * Translate a message code with argument(s)
+ *
+ * @param msg The message code
+ * @param args The argument(s)
+ * @return The translated error
+ */
+ public static String msg( I18n msg, Object... args )
+ {
+ try
+ {
+ return msg + " " + format( ERR_BUNDLE.getString( msg.getErrorCode() ), args );
+ }
+ catch ( Exception e )
+ {
+ StringBuilder sb = new StringBuilder();
+ boolean comma = false;
+
+ for ( Object obj : args )
+ {
+ if ( comma )
+ {
+ sb.append( "," );
+ }
+ else
+ {
+ comma = true;
+ }
+
+ sb.append( obj );
+ }
+ return msg + " (" + sb.toString() + ")";
+ }
+ }
+
+
+ /**
+ *
* Translate a message with argument(s)
*
* @param msg The message
@@ -891,7 +931,13 @@
}
}
-
+ /**
+ * Format a message injecting some parameters in the pattern.
+ *
+ * @param pattern The message pattern
+ * @param args The arguments to inject in the pattern
+ * @return The resulting messages
+ */
public static String format( String pattern, Object... args )
{
return new MessageFormat( pattern, Locale.ROOT ).format( args );
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
index c576d77..b1c25a6 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
@@ -613,6 +613,7 @@
ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY=The Collective Attribute ({0}) cannot be added in the MAY list of the {1} ObjectClass
ERR_04486_VALUE_ALREADY_EXISTS=The value ''{0}'' already exists in the attribute ({1})
ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED=The attribute ''{0}'' is single valued, we can't add no more values into it
+ERR_04488_SYNTAX_INVALID=Syntax invalid for ''{0}''
# ldap-constants
ERR_05001_UNKNOWN_AUTHENT_LEVEL=Unknown AuthenticationLevel {0}
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
index f10f002..ac85883 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
@@ -17,3 +17,6 @@
# under the License.
#
#
+
+# ldap model messages
+MSG_04489_SYNTAX_VALID=Syntax valid for ''{0}''
diff --git a/integ-osgi/pom.xml b/integ-osgi/pom.xml
index 37073b4..54d362c 100644
--- a/integ-osgi/pom.xml
+++ b/integ-osgi/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-integ-osgi</artifactId>
diff --git a/integ-osgi2/pom.xml b/integ-osgi2/pom.xml
new file mode 100644
index 0000000..ba5f12b
--- /dev/null
+++ b/integ-osgi2/pom.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>api-integ-osgi2</artifactId>
+ <name>Apache Directory API OSGi Integration Tests 2</name>
+
+ <dependencies>
+ <!-- Bundles under test -->
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-client-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-net-mina</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-schema-converter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-extras-aci</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-extras-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-extras-sp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-extras-trigger</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-dsml-engine</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test and PAX dependencies -->
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.javax-inject</artifactId>
+ <version>1_2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-forked</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <scope>test</scope>
+ </dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.eclipse</groupId> -->
+<!-- <artifactId>osgi</artifactId> -->
+<!-- <version>3.9.1-v20140110-1610</version> -->
+<!-- <scope>test</scope> -->
+<!-- </dependency> -->
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <includeScope>runtime</includeScope>
+ <outputFile>${project.build.directory}/test-classes/deps.txt</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.maven.plugins
+ </groupId>
+ <artifactId>
+ maven-dependency-plugin
+ </artifactId>
+ <versionRange>
+ [2.8,)
+ </versionRange>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiAsn1ApiOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiAsn1ApiOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiAsn1ApiOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiAsn1ApiOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiAsn1BerOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiAsn1BerOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiAsn1BerOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiAsn1BerOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiDsmlEngineOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiDsmlEngineOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiDsmlEngineOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiDsmlEngineOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiDsmlParserOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiDsmlParserOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiDsmlParserOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiDsmlParserOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiI18nOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiI18nOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiI18nOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiI18nOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapClientApiOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapClientApiOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapClientApiOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapClientApiOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java
similarity index 90%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java
index 931fbaa..322fb19 100644
--- a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java
+++ b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapCodecCoreOsgiTest.java
@@ -40,6 +40,7 @@
import org.apache.directory.api.ldap.codec.search.SubstringFilter;
import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
+import org.apache.directory.api.ldap.model.message.controls.SortRequest;
import org.junit.Test;
import org.osgi.framework.ServiceReference;
@@ -100,8 +101,11 @@
{
assertTrue( LdapApiServiceFactory.isInitialized() );
assertFalse( LdapApiServiceFactory.isUsingStandaloneImplementation() );
- assertNotNull( LdapApiServiceFactory.getSingleton() );
- assertNotNull( LdapApiServiceFactory.getSingleton().getProtocolCodecFactory() );
+
+ LdapApiService ldapApiService = LdapApiServiceFactory.getSingleton();
+ assertNotNull( ldapApiService );
+ assertNotNull( ldapApiService.getProtocolCodecFactory() );
+
+ assertTrue( ldapApiService.isControlRegistered( SortRequest.OID ) );
}
-
}
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasAciOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasAciOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasAciOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasAciOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
similarity index 100%
rename from integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
rename to integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
diff --git a/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiOsgiTestBase.java b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiOsgiTestBase.java
new file mode 100644
index 0000000..30df072
--- /dev/null
+++ b/integ-osgi2/src/test/java/org/apache/directory/api/osgi/ApiOsgiTestBase.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.api.osgi;
+
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.url;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public abstract class ApiOsgiTestBase
+{
+
+ @Inject
+ protected BundleContext context;
+
+ private static Set<String> skips = new HashSet<String>();
+// static
+// {
+// skips.add( "antlr-2.7.7.jar" );
+// skips.add( "xpp3-1.1.4c.jar" );
+// skips.add( "dom4j-1.6.1.jar" );
+// }
+
+
+ @Configuration
+ public Option[] config() throws IOException
+ {
+ List<Option> dependencies = new ArrayList<Option>();
+
+ URL resource = getClass().getResource( "/" );
+ File targetTestClassesDir = new File( resource.getFile() );
+ File targetDependenciesDir = new File( targetTestClassesDir.getParent(), "dependency" );
+ File[] files = targetDependenciesDir.listFiles();
+ for ( File file : files )
+ {
+ if ( !skips.contains( file.getName() ) )
+ {
+ dependencies.add( url( file.toURI().toString() ) );
+ }
+ }
+
+ // shuffle dependencies, there mustn't be any dependency on order
+ Collections.shuffle( dependencies );
+
+ return options(
+ systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value( "WARN" ),
+ systemProperty( "logback.configurationFile" ).value(
+ "file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml" ),
+ systemPackages( "javax.xml.stream;version=1.0.0", "javax.xml.stream.util;version=1.0.0",
+ "javax.xml.stream.events;version=1.0.0" ), mavenBundle( "ch.qos.logback", "logback-classic", "1.0.6" ),
+ mavenBundle( "ch.qos.logback", "logback-core", "1.0.6" ), junitBundles(),
+ composite( dependencies.toArray( new Option[0] ) ) );
+ }
+
+
+ @Test
+ public void testInjectContext()
+ {
+ assertNotNull( context );
+ }
+
+
+ @Test
+ public void testBundleActivation()
+ {
+ String bundleName = getBundleName();
+
+ boolean bundleFound = false;
+ boolean bundleActive = false;
+ Bundle[] bundles = context.getBundles();
+ for ( Bundle bundle : bundles )
+ {
+ //System.out.println( "### bundle=" + bundle + " " + bundle.getState() );
+ if ( bundle != null && bundle.getSymbolicName() != null && bundle.getSymbolicName().equals( bundleName ) )
+ {
+ bundleFound = true;
+ if ( bundle.getState() == Bundle.ACTIVE )
+ {
+ bundleActive = true;
+ }
+ }
+ }
+
+ assertTrue( "Bundle " + bundleName + " not found.", bundleFound );
+ assertTrue( "Bundle " + bundleName + " is not active.", bundleActive );
+ }
+
+
+ /**
+ * @return the symbolic name of the bundle under test.
+ */
+ protected abstract String getBundleName();
+
+
+ @Test
+ public void testUseBundleClasses() throws Exception
+ {
+ useBundleClasses();
+ }
+
+
+ /**
+ * Implementations should use the bundle's classes to check if they are accessible.
+ * @throws Exception
+ */
+ protected abstract void useBundleClasses() throws Exception;
+
+}
diff --git a/integ-osgi2/src/test/resources/exam.properties b/integ-osgi2/src/test/resources/exam.properties
new file mode 100644
index 0000000..12af2ff
--- /dev/null
+++ b/integ-osgi2/src/test/resources/exam.properties
@@ -0,0 +1,18 @@
+#############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#############################################################################
+
+pax.exam.logging = none
diff --git a/integ-osgi2/src/test/resources/logback.xml b/integ-osgi2/src/test/resources/logback.xml
new file mode 100644
index 0000000..a284c18
--- /dev/null
+++ b/integ-osgi2/src/test/resources/logback.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="error">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
\ No newline at end of file
diff --git a/integ/pom.xml b/integ/pom.xml
index 029038f..ac1e89a 100644
--- a/integ/pom.xml
+++ b/integ/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-integ</artifactId>
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareAttributeTest.java b/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareAttributeTest.java
index b4e4022..7843adf 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareAttributeTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareAttributeTest.java
@@ -48,7 +48,6 @@
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -791,10 +790,10 @@
Attribute attr2 = new DefaultAttribute( atPwd );
- nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
+ nbAdded = attr2.add( Strings.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, attr2.getBytes() ) );
Attribute attr3 = new DefaultAttribute( atPwd );
@@ -1159,10 +1158,10 @@
Attribute attr2 = new DefaultAttribute( atPwd );
- nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
+ nbAdded = attr2.add( Strings.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, attr2.getBytes() ) );
Attribute attr3 = new DefaultAttribute( atPwd );
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareValueSerializationTest.java b/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareValueSerializationTest.java
index ccf7dcb..a567abc 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareValueSerializationTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/entry/SchemaAwareValueSerializationTest.java
@@ -34,7 +34,7 @@
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -85,10 +85,10 @@
userCertificate = schemaManager.getAttributeType( "userCertificate" );
bv1 = new BinaryValue( userCertificate, DATA );
- bv2 = new BinaryValue( userCertificate, StringConstants.EMPTY_BYTES );
+ bv2 = new BinaryValue( userCertificate, Strings.EMPTY_BYTES );
bv3 = new BinaryValue( userCertificate, null );
bv1n = new BinaryValue( userCertificate, DATA );
- bv2n = new BinaryValue( userCertificate, StringConstants.EMPTY_BYTES );
+ bv2n = new BinaryValue( userCertificate, Strings.EMPTY_BYTES );
bv3n = new BinaryValue( userCertificate, null );
sv1 = new StringValue( cn, "test" );
sv2 = new StringValue( dc, "" );
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java b/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
index 521453e..17bb1df 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
@@ -54,7 +54,7 @@
JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
SchemaManager schemaManager = new DefaultSchemaManager( loader );
schemaManager.loadAllEnabled();
- checker = new org.apache.directory.api.ldap.aci.ACIItemSyntaxChecker();
+ checker = ACIItemSyntaxChecker.INSTANCE;
checker.setSchemaManager( schemaManager );
}
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java b/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
index d1ab96b..524b133 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
@@ -59,7 +59,7 @@
schemaManager.loadAllEnabled();
- checker = new SubtreeSpecificationSyntaxChecker();
+ checker = SubtreeSpecificationSyntaxChecker.INSTANCE;
checker.setSchemaManager( schemaManager );
}
diff --git a/ldap/client/all/pom.xml b/ldap/client/all/pom.xml
index 2a1aeab..a6e464b 100644
--- a/ldap/client/all/pom.xml
+++ b/ldap/client/all/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-client-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-client-all</artifactId>
diff --git a/ldap/client/api/pom.xml b/ldap/client/api/pom.xml
index 48d09a4..dd455ce 100644
--- a/ldap/client/api/pom.xml
+++ b/ldap/client/api/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-client-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-client-api</artifactId>
@@ -38,9 +38,9 @@
</issueManagement>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/directory/clients/ldap/tags/1.0.0-RC2/ldap/trunk/ldap-client-api</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/clients/ldap/tags/1.0.0-RC2/ldap/trunk/ldap-client-api</developerConnection>
- <url>http://svn.apache.org/viewvc/directory/clients/ldap/tags/1.0.0-RC2/ldap/trunk/ldap-client-api</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/directory/clients/ldap/tags/1.0.0/ldap/trunk/ldap-client-api</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/clients/ldap/tags/1.0.0/ldap/trunk/ldap-client-api</developerConnection>
+ <url>http://svn.apache.org/viewvc/directory/clients/ldap/tags/1.0.0/ldap/trunk/ldap-client-api</url>
</scm>
<description>
@@ -94,6 +94,11 @@
<version>1.10.19</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
index 05bfb6e..2f33cf4 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
@@ -33,7 +33,6 @@
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.slf4j.Logger;
@@ -79,9 +78,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public void bind( Dn name ) throws LdapException
{
- byte[] credBytes = StringConstants.EMPTY_BYTES;
+ byte[] credBytes = Strings.EMPTY_BYTES;
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn( name );
@@ -96,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void bind( String name ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -107,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void bind( String name, String credentials ) throws LdapException
{
bind( new Dn( schemaManager, name ), credentials );
@@ -116,9 +118,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public void bind( Dn name, String credentials ) throws LdapException
{
- byte[] credBytes = ( credentials == null ? StringConstants.EMPTY_BYTES : Strings.getBytesUtf8( credentials ) );
+ byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials );
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn( name );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java
index 68457d1..55fc692 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractPoolableLdapConnectionFactory.java
@@ -51,6 +51,7 @@
*
* There is nothing to do to activate a connection.
*/
+ @Override
public void activateObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Activating {}", connection );
@@ -68,6 +69,7 @@
* Destroying a connection will unbind it which will result on a shutdown
* of teh underlying protocol.
*/
+ @Override
public void destroyObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Destroying {}", connection );
@@ -104,6 +106,7 @@
*
* @throws LdapException If unable to connect.
*/
+ @Override
public LdapConnection makeObject() throws LdapException
{
LOG.debug( "Creating a LDAP connection" );
@@ -136,6 +139,7 @@
*
* @throws LdapException If unable to reconfigure and rebind.
*/
+ @Override
public void passivateObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Passivating {}", connection );
@@ -167,6 +171,7 @@
*
* Validating a connection is done by checking the connection status.
*/
+ @Override
public boolean validateObject( LdapConnection connection )
{
LOG.debug( "Validating {}", connection );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java
index 7b881c7..3519af0 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultLdapConnectionValidator.java
@@ -34,6 +34,7 @@
* @param connection The connection to validate
* @return True, if the connection is still valid
*/
+ @Override
public boolean validate( LdapConnection connection )
{
return connection.isConnected() && connection.isAuthenticated();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
index 83bf6b7..71ed73a 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
@@ -118,6 +118,28 @@
/**
+ * Creates a new instance of NetworkSchemaLoader.
+ *
+ * @param connection the LDAP connection
+ * @param subschemaSubentryDn The SubschemaSubentry
+ * @throws LdapException if the connection is not authenticated or if there are any problems
+ * while loading the schema entries
+ */
+ public DefaultSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws LdapException
+ {
+ if ( !connection.isAuthenticated() )
+ {
+ throw new IllegalArgumentException( "connection is not authenticated" );
+ }
+
+ this.connection = connection;
+ this.subschemaSubentryDn = subschemaSubentryDn;
+
+ loadSchemas();
+ }
+
+
+ /**
* Creates a new instance of DefaultSchemaLoader.
*
* @param connection the LDAP connection
@@ -235,28 +257,6 @@
/**
- * Creates a new instance of NetworkSchemaLoader.
- *
- * @param connection the LDAP connection
- * @param subschemaSubentryDn The SubschemaSubentry
- * @throws Exception if the connection is not authenticated or if there are any problems
- * while loading the schema entries
- */
- public DefaultSchemaLoader( LdapConnection connection, Dn subschemaSubentryDn ) throws Exception
- {
- if ( !connection.isAuthenticated() )
- {
- throw new IllegalArgumentException( "connection is not authenticated" );
- }
-
- this.connection = connection;
- this.subschemaSubentryDn = subschemaSubentryDn;
-
- loadSchemas();
- }
-
-
- /**
* Load all the schemas.
*
* @param subschemaSubentryDn
@@ -327,9 +327,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadAttributeTypes( Attribute attributeTypes ) throws LdapException
{
if ( attributeTypes == null )
@@ -355,9 +352,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadComparators( Attribute comparators ) throws LdapException
{
if ( comparators == null )
@@ -383,9 +377,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadDitContentRules( Attribute ditContentRules ) throws LdapException
{
if ( ditContentRules == null )
@@ -411,9 +402,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadDitStructureRules( Attribute ditStructureRules ) throws LdapException
{
if ( ditStructureRules == null )
@@ -439,9 +427,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadLdapSyntaxes( Attribute ldapSyntaxes ) throws LdapException
{
if ( ldapSyntaxes == null )
@@ -467,9 +452,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadMatchingRules( Attribute matchingRules ) throws LdapException
{
if ( matchingRules == null )
@@ -495,9 +477,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadMatchingRuleUses( Attribute matchingRuleUses ) throws LdapException
{
if ( matchingRuleUses == null )
@@ -523,9 +502,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadNameForms( Attribute nameForms ) throws LdapException
{
if ( nameForms == null )
@@ -551,9 +527,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadNormalizers( Attribute normalizers ) throws LdapException
{
if ( normalizers == null )
@@ -579,9 +552,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadObjectClasses( Attribute objectClasses ) throws LdapException
{
if ( objectClasses == null )
@@ -607,9 +577,6 @@
}
- /**
- * {@inheritDoc}
- */
private void loadSyntaxCheckers( Attribute syntaxCheckers ) throws LdapException
{
if ( syntaxCheckers == null )
@@ -638,7 +605,7 @@
private void updateSchemas( SchemaObject schemaObject )
{
String schemaName = schemaObject.getSchemaName();
- Schema schema = null;
+ Schema schema;
if ( Strings.isEmpty( schemaName ) || Strings.equals( "null", schemaName ) )
{
@@ -665,9 +632,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> attributeTypeEntries = new ArrayList<Entry>();
+ List<Entry> attributeTypeEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -702,9 +670,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> comparatorEntries = new ArrayList<Entry>();
+ List<Entry> comparatorEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -736,9 +705,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditContentRuleEntries = new ArrayList<Entry>();
+ List<Entry> ditContentRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -773,9 +743,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditStructureRuleEntries = new ArrayList<Entry>();
+ List<Entry> ditStructureRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -810,9 +781,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleUseEntries = new ArrayList<Entry>();
+ List<Entry> matchingRuleUseEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -847,9 +819,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleEntries = new ArrayList<Entry>();
+ List<Entry> matchingRuleEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -884,9 +857,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> nameFormEntries = new ArrayList<Entry>();
+ List<Entry> nameFormEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -921,9 +895,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> normalizerEntries = new ArrayList<Entry>();
+ List<Entry> normalizerEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -955,9 +930,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> objectClassEntries = new ArrayList<Entry>();
+ List<Entry> objectClassEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -992,9 +968,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxCheckerEntries = new ArrayList<Entry>();
+ List<Entry> syntaxCheckerEntries = new ArrayList<>();
if ( schemas == null )
{
@@ -1026,9 +1003,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxEntries = new ArrayList<Entry>();
+ List<Entry> syntaxEntries = new ArrayList<>();
if ( schemas == null )
{
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
index 6f55503..72a82b1 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
@@ -87,6 +87,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
if ( !searchCursor.next() )
@@ -144,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry get() throws CursorException
{
if ( !searchCursor.available() )
@@ -183,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchResultDone getSearchResultDone()
{
return searchCursor.getSearchResultDone();
@@ -192,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return searchCursor.available();
@@ -234,6 +238,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void after( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -245,6 +250,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -256,6 +262,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void before( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -267,6 +274,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -278,6 +286,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -289,6 +298,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -300,6 +310,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -310,6 +321,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getMessageId()
{
return messageId;
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java
index 5cf50bd..b5e3bad 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Krb5LoginConfiguration.java
@@ -44,7 +44,7 @@
{
String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
- HashMap<String, Object> options = new HashMap<String, Object>();
+ HashMap<String, Object> options = new HashMap<>();
// TODO: this only works for Sun JVM
options.put( "refreshKrb5Config", "true" );
@@ -60,6 +60,7 @@
* @param applicationName the application name
* @return the configuration entry
*/
+ @Override
public AppConfigurationEntry[] getAppConfigurationEntry( String applicationName )
{
// We will ignore the applicationName, since we want all apps to use Kerberos V5
@@ -70,6 +71,7 @@
/**
* Interface method for reloading the configuration. We don't need this.
*/
+ @Override
public void refresh()
{
// Right now this is a load once scheme and we will not implement the refresh method
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
index a60508b..9595d22 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
@@ -100,6 +100,7 @@
*
* @throws IOException if some I/O error occurs
*/
+ @Override
void close() throws IOException;
@@ -840,6 +841,7 @@
* @return true if there is a non-null future exists, false otherwise
* @deprecated Use {@link #isRequestCompleted(int)}
*/
+ @Deprecated
boolean doesFutureExistFor( int messageId );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
index c26f126..3e3b01a 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
@@ -21,14 +21,10 @@
package org.apache.directory.ldap.client.api;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.net.ssl.KeyManager;
import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
@@ -123,38 +119,13 @@
/**
- * sets the default trust manager based on the SunX509 trustManagement algorithm
+ * sets the default trust manager based on the SunX509 trustManagement algorithm.
+ *
+ * We use a non-verification Trust Manager
*/
private void setDefaultTrustManager()
{
- String trustMgmtAlgo = TrustManagerFactory.getDefaultAlgorithm();
-
- try
- {
- TrustManagerFactory tmFactory = TrustManagerFactory.getInstance( trustMgmtAlgo );
- tmFactory.init( ( KeyStore ) null );
-
- TrustManager[] factoryTrustManagers = tmFactory.getTrustManagers();
-
- for ( int i = 0; i < factoryTrustManagers.length; i++ )
- {
- if ( factoryTrustManagers[i] instanceof X509TrustManager )
- {
- trustManagers = new TrustManager[]
- { factoryTrustManagers[i] };
- LOG.debug( "found X509TrustManager {}", factoryTrustManagers[i] );
- break;
- }
- }
- }
- catch ( NoSuchAlgorithmException e )
- {
- LOG.warn( "couldn't find any default X509 TrustManager with algorithm {}", trustMgmtAlgo );
- }
- catch ( KeyStoreException e )
- {
- LOG.warn( "couldn't initialize TrustManagerFactory with keystore {}", KeyStore.getDefaultType() );
- }
+ trustManagers = new X509TrustManager[] { new NoVerificationTrustManager() };
}
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
index 0bc4d08..a0e3e3a 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
@@ -123,13 +123,9 @@
connection = super.borrowObject();
LOG.trace( "borrowed connection {}", connection );
}
- catch ( LdapException e )
+ catch ( LdapException | RuntimeException e )
{
- throw ( e );
- }
- catch ( RuntimeException e )
- {
- throw ( e );
+ throw e;
}
catch ( Exception e )
{
@@ -169,13 +165,9 @@
super.returnObject( connection );
LOG.trace( "returned connection {}", connection );
}
- catch ( LdapException e )
+ catch ( LdapException | RuntimeException e )
{
- throw ( e );
- }
- catch ( RuntimeException e )
- {
- throw ( e );
+ throw e;
}
catch ( Exception e )
{
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
index 708887d..33af536 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
@@ -65,9 +65,15 @@
*/
public class LdapConnectionWrapper implements LdapConnection, Wrapper<LdapConnection>
{
+ /** The wrapped connection */
protected LdapConnection connection;
+ /**
+ * Creates a new LdapConnectionWrapper instance
+ *
+ * @param connection The wrapped connection
+ */
protected LdapConnectionWrapper( LdapConnection connection )
{
this.connection = connection;
@@ -77,12 +83,16 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapConnection wrapped()
{
return connection;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isConnected()
{
@@ -90,6 +100,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isAuthenticated()
{
@@ -97,6 +110,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean connect() throws LdapException
{
@@ -104,6 +120,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void close() throws IOException
{
@@ -111,6 +130,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void add( Entry entry ) throws LdapException
{
@@ -118,6 +140,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public AddResponse add( AddRequest addRequest ) throws LdapException
{
@@ -125,6 +150,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void abandon( int messageId )
{
@@ -132,6 +160,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void abandon( AbandonRequest abandonRequest )
{
@@ -139,6 +170,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind() throws LdapException
{
@@ -146,6 +180,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void anonymousBind() throws LdapException
{
@@ -153,6 +190,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( String name ) throws LdapException
{
@@ -160,6 +200,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( String name, String credentials ) throws LdapException
{
@@ -167,6 +210,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( Dn name ) throws LdapException
{
@@ -174,6 +220,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void bind( Dn name, String credentials ) throws LdapException
{
@@ -181,6 +230,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
@@ -188,6 +240,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
@@ -196,6 +251,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
@@ -204,6 +262,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
@@ -211,6 +272,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void unBind() throws LdapException
{
@@ -218,6 +282,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setTimeOut( long timeOut )
{
@@ -225,6 +292,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( Dn dn, Modification... modifications ) throws LdapException
{
@@ -232,6 +302,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( String dn, Modification... modifications ) throws LdapException
{
@@ -239,6 +312,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
@@ -246,6 +322,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
{
@@ -253,6 +332,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( String entryDn, String newRdn ) throws LdapException
{
@@ -260,6 +342,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
{
@@ -267,6 +352,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
{
@@ -274,6 +362,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
{
@@ -281,6 +372,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void move( String entryDn, String newSuperiorDn ) throws LdapException
{
@@ -288,6 +382,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
{
@@ -295,6 +392,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
{
@@ -302,6 +402,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( String entryDn, String newDn ) throws LdapException
{
@@ -309,6 +412,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
@@ -316,6 +422,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
{
@@ -323,6 +432,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
{
@@ -330,6 +442,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void delete( String dn ) throws LdapException
{
@@ -337,6 +452,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void delete( Dn dn ) throws LdapException
{
@@ -344,6 +462,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
{
@@ -351,6 +472,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, String value ) throws LdapException
{
@@ -358,6 +482,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
{
@@ -365,6 +492,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
{
@@ -372,6 +502,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
{
@@ -379,6 +512,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
{
@@ -386,6 +522,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
{
@@ -393,6 +532,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
{
@@ -400,6 +542,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( String oid ) throws LdapException
{
@@ -407,6 +552,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
{
@@ -414,6 +562,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( Oid oid ) throws LdapException
{
@@ -421,6 +572,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
{
@@ -428,6 +582,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
{
@@ -435,6 +592,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean exists( String dn ) throws LdapException
{
@@ -442,6 +602,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean exists( Dn dn ) throws LdapException
{
@@ -449,6 +612,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry getRootDse() throws LdapException
{
@@ -456,6 +622,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry getRootDse( String... attributes ) throws LdapException
{
@@ -463,6 +632,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn ) throws LdapException
{
@@ -470,6 +642,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn ) throws LdapException
{
@@ -477,6 +652,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn, String... attributes ) throws LdapException
{
@@ -484,6 +662,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
{
@@ -491,6 +672,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn, String... attributes ) throws LdapException
{
@@ -498,6 +682,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
{
@@ -505,6 +692,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isControlSupported( String controlOID ) throws LdapException
{
@@ -512,6 +702,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public List<String> getSupportedControls() throws LdapException
{
@@ -519,6 +712,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void loadSchema() throws LdapException
{
@@ -526,6 +722,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public SchemaManager getSchemaManager()
{
@@ -533,6 +732,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public LdapApiService getCodecService()
{
@@ -540,6 +742,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isRequestCompleted( int messageId )
{
@@ -547,13 +752,19 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean doesFutureExistFor( int messageId )
{
- return connection.doesFutureExistFor( messageId );
+ return connection.isRequestCompleted( messageId );
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public BinaryAttributeDetector getBinaryAttributeDetector()
{
@@ -561,6 +772,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter )
{
@@ -568,6 +782,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setSchemaManager( SchemaManager schemaManager )
{
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index dd84992..d12f44b 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -23,7 +23,6 @@
import static org.apache.directory.api.ldap.model.message.ResultCodeEnum.processResponse;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
@@ -32,6 +31,8 @@
import java.net.SocketAddress;
import java.nio.channels.UnresolvedAddressException;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,13 +40,12 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
import javax.security.auth.Subject;
import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
@@ -56,7 +56,6 @@
import org.apache.directory.api.asn1.util.Oid;
import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
-import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
import org.apache.directory.api.ldap.codec.api.LdapApiService;
import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
import org.apache.directory.api.ldap.codec.api.LdapDecoder;
@@ -210,7 +209,7 @@
private IoSession ldapSession;
/** a map to hold the ResponseFutures for all operations */
- private Map<Integer, ResponseFuture<? extends Response>> futureMap = new ConcurrentHashMap<Integer, ResponseFuture<? extends Response>>();
+ private Map<Integer, ResponseFuture<? extends Response>> futureMap = new ConcurrentHashMap<>();
/** list of controls supported by the server */
private List<String> supportedControls;
@@ -243,12 +242,212 @@
static final String TIME_OUT_ERROR = "TimeOut occurred";
static final String NO_RESPONSE_ERROR = "The response queue has been emptied, no response was found.";
+
+
+ //------------------------- The constructors --------------------------//
+ /**
+ * Create a new instance of a LdapConnection on localhost,
+ * port 389.
+ */
+ public LdapNetworkConnection()
+ {
+ this( null, -1, false );
+ }
+
+
+ /**
+ *
+ * Creates a new instance of LdapConnection with the given connection configuration.
+ *
+ * @param config the configuration of the LdapConnection
+ */
+ public LdapNetworkConnection( LdapConnectionConfig config )
+ {
+ this( config, LdapApiServiceFactory.getSingleton() );
+ }
+
+
+ /**
+ * Creates a new LdapNetworkConnection instance
+ *
+ * @param config The configuration to use
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( LdapConnectionConfig config, LdapApiService ldapApiService )
+ {
+ super( ldapApiService );
+ this.config = config;
+
+ if ( config.getBinaryAttributeDetector() == null )
+ {
+ config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
+ }
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on localhost,
+ * port 389 if the SSL flag is off, or 636 otherwise.
+ *
+ * @param useSsl A flag to tell if it's a SSL connection or not.
+ */
+ public LdapNetworkConnection( boolean useSsl )
+ {
+ this( null, -1, useSsl );
+ }
+
+
+ /**
+ * Creates a new LdapNetworkConnection instance
+ *
+ * @param useSsl If we are going to create a secure connection or not
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( boolean useSsl, LdapApiService ldapApiService )
+ {
+ this( null, -1, useSsl, ldapApiService );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a given
+ * server, using the default port (389).
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ */
+ public LdapNetworkConnection( String server )
+ {
+ this( server, -1, false );
+ }
+
+
+ /**
+ * Creates a new LdapNetworkConnection instance
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( String server, LdapApiService ldapApiService )
+ {
+ this( server, -1, false, ldapApiService );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a given
+ * server, using the default port (389) if the SSL flag
+ * is off, or 636 otherwise.
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param useSsl A flag to tell if it's a SSL connection or not.
+ */
+ public LdapNetworkConnection( String server, boolean useSsl )
+ {
+ this( server, -1, useSsl );
+ }
+
+
+ /**
+ * Creates a new LdapNetworkConnection instance
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param useSsl A flag to tell if it's a SSL connection or not.
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( String server, boolean useSsl, LdapApiService ldapApiService )
+ {
+ this( server, -1, useSsl, ldapApiService );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a
+ * given server and a given port. We don't use ssl.
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param port The port the server is listening on
+ */
+ public LdapNetworkConnection( String server, int port )
+ {
+ this( server, port, false );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a
+ * given server and a given port. We don't use ssl.
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param port The port the server is listening on
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( String server, int port, LdapApiService ldapApiService )
+ {
+ this( server, port, false, ldapApiService );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a given
+ * server, and a give port. We set the SSL flag accordingly
+ * to the last parameter.
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param port The port the server is listening to
+ * @param useSsl A flag to tell if it's a SSL connection or not.
+ */
+ public LdapNetworkConnection( String server, int port, boolean useSsl )
+ {
+ this( buildConfig( server, port, useSsl ) );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a given
+ * server, and a give port. This SSL connection will use the provided
+ * TrustManagers
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param port The port the server is listening to
+ * @param trustManagers The TrustManager to use
+ */
+ public LdapNetworkConnection( String server, int port, TrustManager... trustManagers )
+ {
+ this( buildConfig( server, port, true ) );
+
+ config.setTrustManagers( trustManagers );
+ }
+
+
+ /**
+ * Create a new instance of a LdapConnection on a
+ * given server and a given port. We don't use ssl.
+ *
+ * @param server The server we want to be connected to. If null or empty,
+ * we will default to LocalHost.
+ * @param port The port the server is listening on
+ * @param useSsl A flag to tell if it's a SSL connection or not.
+ * @param ldapApiService The LDAP API Service to use
+ */
+ public LdapNetworkConnection( String server, int port, boolean useSsl, LdapApiService ldapApiService )
+ {
+ this( buildConfig( server, port, useSsl ), ldapApiService );
+ }
//--------------------------- Helper methods ---------------------------//
/**
* {@inheritDoc}
*/
+ @Override
public boolean isConnected()
{
return ( ldapSession != null ) && connected.get() && !ldapSession.isClosing();
@@ -258,6 +457,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAuthenticated()
{
return isConnected() && authenticated.get();
@@ -265,6 +465,17 @@
/**
+ * Tells if the connection is using a secured channel
+ *
+ * @return <tt>true</tt> if the session is using a secured channel
+ */
+ public boolean isSecured()
+ {
+ return isConnected() && ldapSession.isSecured();
+ }
+
+
+ /**
* Check that a session is valid, ie we can send requests to the
* server
*
@@ -351,140 +562,6 @@
}
- //------------------------- The constructors --------------------------//
- /**
- * Create a new instance of a LdapConnection on localhost,
- * port 389.
- */
- public LdapNetworkConnection()
- {
- this( null, -1, false );
- }
-
-
- /**
- *
- * Creates a new instance of LdapConnection with the given connection configuration.
- *
- * @param config the configuration of the LdapConnection
- */
- public LdapNetworkConnection( LdapConnectionConfig config )
- {
- this( config, LdapApiServiceFactory.getSingleton() );
- }
-
-
- public LdapNetworkConnection( LdapConnectionConfig config, LdapApiService ldapApiService )
- {
- super( ldapApiService );
- this.config = config;
-
- if ( config.getBinaryAttributeDetector() == null )
- {
- config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
- }
- }
-
-
- /**
- * Create a new instance of a LdapConnection on localhost,
- * port 389 if the SSL flag is off, or 636 otherwise.
- *
- * @param useSsl A flag to tell if it's a SSL connection or not.
- */
- public LdapNetworkConnection( boolean useSsl )
- {
- this( null, -1, useSsl );
- }
-
-
- public LdapNetworkConnection( boolean useSsl, LdapApiService ldapApiService )
- {
- this( null, -1, useSsl, ldapApiService );
- }
-
-
- /**
- * Create a new instance of a LdapConnection on a given
- * server, using the default port (389).
- *
- * @param server The server we want to be connected to. If null or empty,
- * we will default to LocalHost.
- */
- public LdapNetworkConnection( String server )
- {
- this( server, -1, false );
- }
-
-
- public LdapNetworkConnection( String server, LdapApiService ldapApiService )
- {
- this( server, -1, false, ldapApiService );
- }
-
-
- /**
- * Create a new instance of a LdapConnection on a given
- * server, using the default port (389) if the SSL flag
- * is off, or 636 otherwise.
- *
- * @param server The server we want to be connected to. If null or empty,
- * we will default to LocalHost.
- * @param useSsl A flag to tell if it's a SSL connection or not.
- */
- public LdapNetworkConnection( String server, boolean useSsl )
- {
- this( server, -1, useSsl );
- }
-
-
- public LdapNetworkConnection( String server, boolean useSsl, LdapApiService ldapApiService )
- {
- this( server, -1, useSsl, ldapApiService );
- }
-
-
- /**
- * Create a new instance of a LdapConnection on a
- * given server and a given port. We don't use ssl.
- *
- * @param server The server we want to be connected to
- * @param port The port the server is listening to
- */
- public LdapNetworkConnection( String server, int port )
- {
- this( server, port, false );
- }
-
-
- public LdapNetworkConnection( String server, int port, LdapApiService ldapApiService )
- {
- this( server, port, false, ldapApiService );
- }
-
-
- /**
- * Create a new instance of a LdapConnection on a given
- * server, and a give port. We set the SSL flag accordingly
- * to the last parameter.
- *
- * @param server The server we want to be connected to. If null or empty,
- * we will default to LocalHost.
- * @param port The port the server is listening to
- * @param useSsl A flag to tell if it's a SSL connection or not.
- */
- public LdapNetworkConnection( String server, int port, boolean useSsl )
- {
- this( buildConfig( server, port, useSsl ) );
- }
-
-
- public LdapNetworkConnection( String server, int port, boolean useSsl, LdapApiService ldapApiService )
- {
- this( buildConfig( server, port, useSsl ), ldapApiService );
- }
-
-
private static LdapConnectionConfig buildConfig( String server, int port, boolean useSsl )
{
LdapConnectionConfig config = new LdapConnectionConfig();
@@ -558,6 +635,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean connect() throws LdapException
{
if ( ( ldapSession != null ) && connected.get() )
@@ -565,7 +643,7 @@
// No need to connect if we already have a connected session
return true;
}
-
+
// Create the connector if needed
if ( connector == null )
{
@@ -616,7 +694,6 @@
// No need to wait
// We know that there was a permanent error such as "connection refused".
LOG.debug( "------>> Connection error: {}", connectionFuture.getException().getMessage() );
- break;
}
LOG.debug( "------>> Cannot get the connection... Retrying" );
@@ -693,14 +770,16 @@
// Add a listener to close the session in the session.
closeFuture.addListener( new IoFutureListener<IoFuture>()
{
+ @Override
public void operationComplete( IoFuture future )
{
// Process all the waiting operations and cancel them
LOG.debug( "received a NoD, closing everything" );
- for ( int messageId : futureMap.keySet() )
+ for ( Map.Entry<Integer, ResponseFuture<? extends Response>> entry : futureMap.entrySet() )
{
- ResponseFuture<?> responseFuture = futureMap.get( messageId );
+ int messageId = entry.getKey();
+ ResponseFuture<?> responseFuture = entry.getValue();
LOG.debug( "closing {}", responseFuture );
responseFuture.cancel();
@@ -740,10 +819,6 @@
( ( SearchFuture ) responseFuture ).set( SearchNoDResponse.PROTOCOLERROR );
}
}
- catch ( ExecutionException e )
- {
- LOG.error( "Error while processing the NoD for {}", responseFuture );
- }
catch ( InterruptedException e )
{
LOG.error( "Error while processing the NoD for {}", responseFuture );
@@ -797,12 +872,13 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
// Close the session
if ( ( ldapSession != null ) && connected.get() )
{
- ldapSession.close( true );
+ ldapSession.closeNow();
}
connected.set( false );
@@ -835,6 +911,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void add( Entry entry ) throws LdapException
{
if ( entry == null )
@@ -856,6 +933,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddFuture addAsync( Entry entry ) throws LdapException
{
if ( entry == null )
@@ -875,6 +953,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddResponse add( AddRequest addRequest ) throws LdapException
{
if ( addRequest == null )
@@ -920,18 +999,6 @@
return addResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !addFuture.isCancelled() )
- {
- abandon( addRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Add failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -951,6 +1018,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddFuture addAsync( AddRequest addRequest ) throws LdapException
{
if ( addRequest == null )
@@ -967,6 +1035,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
int newId = messageId.incrementAndGet();
@@ -988,6 +1059,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void abandon( int messageId )
{
if ( messageId < 0 )
@@ -1007,6 +1079,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void abandon( AbandonRequest abandonRequest )
{
if ( abandonRequest == null )
@@ -1060,6 +1133,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void bind() throws LdapException
{
LOG.debug( "Bind request" );
@@ -1076,12 +1150,13 @@
/**
* {@inheritDoc}
*/
+ @Override
public void anonymousBind() throws LdapException
{
LOG.debug( "Anonymous Bind request" );
// Create the BindRequest
- BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, StringConstants.EMPTY_BYTES );
+ BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, Strings.EMPTY_BYTES );
BindResponse bindResponse = bind( bindRequest );
@@ -1092,6 +1167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync() throws LdapException
{
LOG.debug( "Asynchronous Bind request" );
@@ -1106,12 +1182,13 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture anonymousBindAsync() throws LdapException
{
LOG.debug( "Anonymous asynchronous Bind request" );
// Create the BindRequest
- BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, StringConstants.EMPTY_BYTES );
+ BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, Strings.EMPTY_BYTES );
return bindAsync( bindRequest );
}
@@ -1130,7 +1207,7 @@
LOG.debug( "Bind request : {}", name );
// Create the BindRequest
- BindRequest bindRequest = createBindRequest( name, StringConstants.EMPTY_BYTES );
+ BindRequest bindRequest = createBindRequest( name, Strings.EMPTY_BYTES );
return bindAsync( bindRequest );
}
@@ -1139,6 +1216,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( String name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1170,7 +1248,7 @@
LOG.debug( "Bind request : {}", name );
// Create the BindRequest
- BindRequest bindRequest = createBindRequest( name, StringConstants.EMPTY_BYTES );
+ BindRequest bindRequest = createBindRequest( name, Strings.EMPTY_BYTES );
return bindAsync( bindRequest );
}
@@ -1179,6 +1257,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( Dn name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1200,6 +1279,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
@@ -1240,12 +1320,6 @@
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1276,6 +1350,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindFuture bindAsync( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
@@ -1382,12 +1457,6 @@
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1445,12 +1514,6 @@
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1522,12 +1585,6 @@
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1585,12 +1642,6 @@
return bindResponse;
}
- catch ( TimeoutException te )
- {
- // We didn't received anything : this is an error
- LOG.error( "Bind failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -1660,6 +1711,7 @@
final SaslGssApiRequest requetFinal = request;
return ( BindFuture ) Subject.doAs( loginContext.getSubject(), new PrivilegedExceptionAction<Object>()
{
+ @Override
public Object run() throws Exception
{
return bindSasl( requetFinal );
@@ -1676,6 +1728,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1702,6 +1755,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1712,6 +1766,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1732,6 +1787,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
@@ -1742,6 +1798,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchFuture searchAsync( SearchRequest searchRequest ) throws LdapException
{
if ( searchRequest == null )
@@ -1758,6 +1815,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
// If the session has not been establish, or is closed, we get out immediately
checkSession();
@@ -1793,6 +1853,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
if ( searchRequest == null )
@@ -1816,6 +1877,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unBind() throws LdapException
{
// If the session has not been establish, or is closed, we get out immediately
@@ -1835,9 +1897,7 @@
// Use this for logging instead: WriteFuture unbindFuture = ldapSession.write( unbindRequest );
WriteFuture unbindFuture = ldapSession.write( unbindRequest );
- //LOG.debug( "waiting for unbindFuture" );
unbindFuture.awaitUninterruptibly( timeout );
- //LOG.debug( "unbindFuture done" );
authenticated.set( false );
@@ -1857,8 +1917,8 @@
}
catch ( IOException e )
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOG.error( e.getMessage() );
+ throw new LdapException( e.getMessage() );
}
connected.set( false );
@@ -1885,6 +1945,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOut( long timeout )
{
if ( timeout <= 0 )
@@ -1926,7 +1987,7 @@
}
}
- session.close( true );
+ session.closeNow();
}
@@ -1937,9 +1998,9 @@
{
if ( message instanceof ExtendedResponse )
{
- ExtendedResponse response = ( ExtendedResponse ) message;
+ String responseName = ( ( ExtendedResponse ) message ).getResponseName();
- if ( response.getResponseName().equals( NoticeOfDisconnect.EXTENSION_OID ) )
+ if ( NoticeOfDisconnect.EXTENSION_OID.equals( responseName ) )
{
return true;
}
@@ -1980,7 +2041,7 @@
if ( isNoD )
{
// close the session
- session.close( true );
+ session.closeNow();
return;
}
@@ -2131,7 +2192,7 @@
break;
case INTERMEDIATE_RESPONSE:
- IntermediateResponse intermediateResponse = null;
+ IntermediateResponse intermediateResponse;
if ( responseFuture instanceof SearchFuture )
{
@@ -2287,6 +2348,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
if ( entry == null )
@@ -2314,6 +2376,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void modify( Dn dn, Modification... modifications ) throws LdapException
{
if ( dn == null )
@@ -2346,6 +2409,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void modify( String dn, Modification... modifications ) throws LdapException
{
modify( new Dn( dn ), modifications );
@@ -2355,6 +2419,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
{
if ( modRequest == null )
@@ -2399,18 +2464,6 @@
return modifyResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !modifyFuture.isCancelled() )
- {
- abandon( modRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Modify failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2430,6 +2483,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyFuture modifyAsync( ModifyRequest modRequest ) throws LdapException
{
if ( modRequest == null )
@@ -2446,6 +2500,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
int newId = messageId.incrementAndGet();
@@ -2465,6 +2522,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rename( String entryDn, String newRdn ) throws LdapException
{
rename( entryDn, newRdn, true );
@@ -2474,6 +2532,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
{
rename( entryDn, newRdn, true );
@@ -2483,6 +2542,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
{
if ( entryDn == null )
@@ -2514,6 +2574,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
{
if ( entryDn == null )
@@ -2544,6 +2605,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void move( String entryDn, String newSuperiorDn ) throws LdapException
{
if ( entryDn == null )
@@ -2575,6 +2637,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
{
if ( entryDn == null )
@@ -2595,7 +2658,6 @@
modDnRequest.setName( entryDn );
modDnRequest.setNewSuperior( newSuperiorDn );
- //TODO not setting the below value is resulting in error
modDnRequest.setNewRdn( entryDn.getRdn() );
ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );
@@ -2607,6 +2669,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
{
moveAndRename( entryDn, newDn, true );
@@ -2616,6 +2679,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( String entryDn, String newDn ) throws LdapException
{
moveAndRename( new Dn( entryDn ), new Dn( newDn ), true );
@@ -2625,6 +2689,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
// Check the parameters first
@@ -2675,6 +2740,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
{
moveAndRename( new Dn( entryDn ), new Dn( newDn ), true );
@@ -2684,6 +2750,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
{
if ( modDnRequest == null )
@@ -2722,18 +2789,6 @@
return modifyDnResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !modifyDnFuture.isCancelled() )
- {
- abandon( modDnRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Modify failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2753,6 +2808,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnFuture modifyDnAsync( ModifyDnRequest modDnRequest ) throws LdapException
{
if ( modDnRequest == null )
@@ -2776,6 +2832,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
int newId = messageId.incrementAndGet();
@@ -2795,6 +2854,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void delete( String dn ) throws LdapException
{
delete( new Dn( dn ) );
@@ -2804,6 +2864,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void delete( Dn dn ) throws LdapException
{
DeleteRequest deleteRequest = new DeleteRequestImpl();
@@ -2885,6 +2946,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
{
if ( deleteRequest == null )
@@ -2923,18 +2985,6 @@
return delResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !deleteFuture.isCancelled() )
- {
- abandon( deleteRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Del failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -2954,6 +3004,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteFuture deleteAsync( DeleteRequest deleteRequest ) throws LdapException
{
if ( deleteRequest == null )
@@ -2970,6 +3021,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
int newId = messageId.incrementAndGet();
@@ -2990,6 +3044,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, String value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -2999,6 +3054,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -3008,6 +3064,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
{
return compare( new Dn( dn ), attributeName, value );
@@ -3017,6 +3074,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3033,6 +3091,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3049,6 +3108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
{
CompareRequest compareRequest = new CompareRequestImpl();
@@ -3073,6 +3133,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
{
if ( compareRequest == null )
@@ -3111,18 +3172,6 @@
return compareResponse;
}
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !compareFuture.isCancelled() )
- {
- abandon( compareRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Compare failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
- }
catch ( Exception ie )
{
// Catch all other exceptions
@@ -3142,6 +3191,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareFuture compareAsync( CompareRequest compareRequest ) throws LdapException
{
if ( compareRequest == null )
@@ -3157,6 +3207,9 @@
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
+
+ // try to connect, if we aren't already connected.
+ connect();
checkSession();
@@ -3178,6 +3231,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( String oid ) throws LdapException
{
return extended( oid, null );
@@ -3187,6 +3241,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
{
try
@@ -3205,6 +3260,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( Oid oid ) throws LdapException
{
return extended( oid, null );
@@ -3214,6 +3270,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
{
ExtendedRequest extendedRequest =
@@ -3225,6 +3282,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
{
if ( extendedRequest == null )
@@ -3269,21 +3327,7 @@
}
// Decode the payload now
- ExtendedResponseDecorator<?> decoratedResponse = codec.decorate( response );
-
- return decoratedResponse;
- }
- catch ( TimeoutException te )
- {
- // Send an abandon request
- if ( !extendedFuture.isCancelled() )
- {
- abandon( extendedRequest.getMessageId() );
- }
-
- // We didn't received anything : this is an error
- LOG.error( "Extended failed : timeout occurred" );
- throw new LdapException( TIME_OUT_ERROR, te );
+ return codec.decorate( response );
}
catch ( Exception ie )
{
@@ -3304,6 +3348,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedFuture extendedAsync( ExtendedRequest extendedRequest ) throws LdapException
{
if ( extendedRequest == null )
@@ -3313,6 +3358,9 @@
throw new IllegalArgumentException( msg );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
int newId = messageId.incrementAndGet();
@@ -3332,6 +3380,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean exists( String dn ) throws LdapException
{
return exists( new Dn( dn ) );
@@ -3341,6 +3390,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean exists( Dn dn ) throws LdapException
{
try
@@ -3364,6 +3414,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getRootDse() throws LdapException
{
return lookup( Dn.ROOT_DSE, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3373,6 +3424,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getRootDse( String... attributes ) throws LdapException
{
return lookup( Dn.ROOT_DSE, attributes );
@@ -3382,6 +3434,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn ) throws LdapException
{
return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3391,6 +3444,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn ) throws LdapException
{
return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
@@ -3400,6 +3454,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn, String... attributes ) throws LdapException
{
return lookup( dn, null, attributes );
@@ -3409,6 +3464,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
{
Entry entry = null;
@@ -3463,6 +3519,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn, String... attributes ) throws LdapException
{
return lookup( new Dn( dn ), null, attributes );
@@ -3472,6 +3529,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
{
return lookup( new Dn( dn ), controls, attributes );
@@ -3481,6 +3539,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isControlSupported( String controlOID ) throws LdapException
{
return getSupportedControls().contains( controlOID );
@@ -3490,6 +3549,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getSupportedControls() throws LdapException
{
if ( supportedControls != null )
@@ -3502,7 +3562,7 @@
fetchRootDSE();
}
- supportedControls = new ArrayList<String>();
+ supportedControls = new ArrayList<>();
Attribute attr = rootDse.get( SchemaConstants.SUPPORTED_CONTROL_AT );
@@ -3531,6 +3591,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void loadSchema() throws LdapException
{
loadSchema( new DefaultSchemaLoader( this ) );
@@ -3540,6 +3601,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void loadSchemaRelaxed() throws LdapException
{
loadSchema( new DefaultSchemaLoader( this, true ) );
@@ -3602,13 +3664,18 @@
{
loadSchema();
}
+
+ if ( schemaManager == null )
+ {
+ throw new LdapException( "Cannot load the schema" );
+ }
OpenLdapSchemaParser olsp = new OpenLdapSchemaParser();
olsp.setQuirksMode( true );
olsp.parse( schemaFile );
Registries registries = schemaManager.getRegistries();
- List<Throwable> errors = new ArrayList<Throwable>();
+ List<Throwable> errors = new ArrayList<>();
for ( AttributeType atType : olsp.getAttributeTypes() )
{
@@ -3646,6 +3713,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapApiService getCodecService()
{
return codec;
@@ -3655,6 +3723,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaManager getSchemaManager()
{
return schemaManager;
@@ -3716,6 +3785,7 @@
*
* @return the configuration of the connection
*/
+ @Override
public LdapConnectionConfig getConfig()
{
return config;
@@ -3765,6 +3835,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean doesFutureExistFor( int messageId )
{
ResponseFuture<?> responseFuture = futureMap.get( messageId );
@@ -3775,6 +3846,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRequestCompleted( int messageId )
{
ResponseFuture<?> responseFuture = futureMap.get( messageId );
@@ -3792,7 +3864,7 @@
{
if ( conCloseListeners == null )
{
- conCloseListeners = new ArrayList<ConnectionClosedEventListener>();
+ conCloseListeners = new ArrayList<>();
}
conCloseListeners.add( ccListener );
@@ -3802,9 +3874,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public void inputClosed( IoSession session ) throws Exception
{
- session.close( true );
+ session.closeNow();
}
@@ -3814,12 +3887,12 @@
*
* @param session the newly created session
*/
+ @Override
public void sessionCreated( IoSession session ) throws Exception
{
// Last, store the message container
LdapMessageContainer<? extends MessageDecorator<Message>> ldapMessageContainer =
- new LdapMessageContainer<MessageDecorator<Message>>(
- codec, config.getBinaryAttributeDetector() );
+ new LdapMessageContainer<>( codec, config.getBinaryAttributeDetector() );
session.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR, ldapMessageContainer );
}
@@ -3837,7 +3910,7 @@
return;
}
- ldapSession.close( true );
+ ldapSession.closeNow();
connected.set( false );
// Reset the messageId
messageId.set( 0 );
@@ -3887,9 +3960,13 @@
throw new LdapException( "Cannot use TLS when the useSsl flag is set true in the configuration" );
}
+ // try to connect, if we aren't already connected.
+ connect();
+
checkSession();
IoFilter sslFilter = ldapSession.getFilterChain().get( SSL_FILTER_KEY );
+
if ( sslFilter != null )
{
LOG.debug( "LDAP session already using startTLS" );
@@ -3927,7 +4004,15 @@
try
{
SSLContext sslContext = SSLContext.getInstance( config.getSslProtocol() );
- sslContext.init( config.getKeyManagers(), config.getTrustManagers(), config.getSecureRandom() );
+
+ TrustManager[] trustManagers = config.getTrustManagers();
+
+ if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) )
+ {
+ trustManagers = new TrustManager[] { new NoVerificationTrustManager() };
+ }
+
+ sslContext.init( config.getKeyManagers(), trustManagers, config.getSecureRandom() );
SslFilter sslFilter = new SslFilter( sslContext, true );
sslFilter.setUseClientMode( true );
@@ -4008,12 +4093,12 @@
try
{
- BindResponse bindResponse = null;
- byte[] response = null;
- ResultCodeEnum result = null;
+ BindResponse bindResponse;
+ byte[] response;
+ ResultCodeEnum result;
// Creating a map for SASL properties
- Map<String, Object> properties = new HashMap<String, Object>();
+ Map<String, Object> properties = new HashMap<>();
// Quality of Protection SASL property
if ( saslRequest.getQualityOfProtection() != null )
@@ -4145,7 +4230,7 @@
}
catch ( Exception e )
{
- e.printStackTrace();
+ LOG.error( e.getMessage() );
throw new LdapException( e );
}
}
@@ -4187,7 +4272,7 @@
}
else
{
- throw new InvalidConnectionException( exception.getMessage() );
+ throw new InvalidConnectionException( exception.getMessage(), exception );
}
}
@@ -4248,7 +4333,8 @@
File krb5Conf = File.createTempFile( "client-api-krb5", ".conf" );
krb5Conf.deleteOnExit();
- try ( Writer writer = new OutputStreamWriter( new FileOutputStream( krb5Conf ), Charset.defaultCharset() ) )
+ try ( Writer writer = new OutputStreamWriter( Files.newOutputStream( Paths.get( krb5Conf.getPath() ) ),
+ Charset.defaultCharset() ) )
{
writer.write( sb.toString() );
}
@@ -4264,6 +4350,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BinaryAttributeDetector getBinaryAttributeDetector()
{
if ( config != null )
@@ -4280,6 +4367,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector )
{
if ( config != null )
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
index 4408d41..48032f8 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
@@ -23,12 +23,14 @@
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -115,10 +117,10 @@
public class LdifAnonymizer
{
/** The map that stores the anonymized values associated to the original value */
- private Map<Value<?>, Value<?>> valueMap = new HashMap<Value<?>, Value<?>>();
+ private Map<Value<?>, Value<?>> valueMap = new HashMap<>();
/** The set that contains all the values we already have anonymized */
- private Set<Value<?>> valueSet = new HashSet<Value<?>>();
+ private Set<Value<?>> valueSet = new HashSet<>();
/** The latest anonymized String value Map */
private Map<Integer, String> latestStringMap;
@@ -127,10 +129,10 @@
private Map<Integer, byte[]> latestBytesMap;
/** The map of AttributeType'sOID we want to anonymize. They are all associated with anonymizers */
- private Map<String, Anonymizer> attributeAnonymizers = new HashMap<String, Anonymizer>();
+ private Map<String, Anonymizer> attributeAnonymizers = new HashMap<>();
/** The list of existing NamingContexts */
- private Set<Dn> namingContexts = new HashSet<Dn>();
+ private Set<Dn> namingContexts = new HashSet<>();
/** The schemaManager */
private SchemaManager schemaManager;
@@ -159,6 +161,20 @@
init( null, null, null, null );
}
+
+ /**
+ * Creates a default instance of LdifAnonymizer. The list of anonymized attribute
+ * is set to a default value.
+ *
+ * @param schemaManager The SchemaManager instance we will use
+ */
+ public LdifAnonymizer( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+
+ init( null, null, null, null );
+ }
+
/**
* Set the PrintStream to use to print information about the processing
@@ -206,20 +222,6 @@
}
}
-
- /**
- * Creates a default instance of LdifAnonymizer. The list of anonymized attribute
- * is set to a default value.
- *
- * @param schemaManager The SchemaManager instance we will use
- */
- public LdifAnonymizer( SchemaManager schemaManager )
- {
- this.schemaManager = schemaManager;
-
- init( null, null, null, null );
- }
-
/**
* Initialize the anonymizer, filling the maps we use.
@@ -407,7 +409,7 @@
Value<?> value = ava.getValue();
AttributeType attributeType = ava.getAttributeType();
Value<?> anonymizedValue = valueMap.get( value );
- Ava anonymizedAva = null;
+ Ava anonymizedAva;
if ( anonymizedValue == null )
{
@@ -508,9 +510,7 @@
rdnPos--;
}
- Dn anonymizedDn = new Dn( schemaManager, anonymizedRdns );
-
- return anonymizedDn;
+ return new Dn( schemaManager, anonymizedRdns );
}
@@ -534,8 +534,8 @@
LdifReader ldifReader = new LdifReader( inputFile, schemaManager );
int count = 0;
- List<LdifEntry> errors = new ArrayList<LdifEntry>();
- List<String> errorTexts = new ArrayList<String>();
+ List<LdifEntry> errors = new ArrayList<>();
+ List<String> errorTexts = new ArrayList<>();
try
{
@@ -597,60 +597,7 @@
writer.write( "\n" );
}
}
-
- /*
- Entry entry = ldifEntry.getEntry();
- Entry newEntry = new DefaultEntry( schemaManager );
-
- // Process the DN first
- Dn entryDn = entry.getDn();
-
- Dn anonymizedDn = anonymizeDn( entryDn );
-
- if ( anonymizedDn == null )
- {
- // Wrong entry base DN
- continue;
- }
-
- // Now, process the entry
- for ( Attribute attribute : entry )
- {
- AttributeType attributeType = attribute.getAttributeType();
-
- if ( attributeType.getSyntax().getSyntaxChecker() instanceof DnSyntaxChecker )
- {
- for ( Value<?> dnValue : attribute )
- {
- String dnStr = dnValue.getString();
- Dn dn = new Dn( schemaManager, dnStr );
- Dn newdDn = anonymizeDn( dn );
- newEntry.add( attributeType, newdDn.toString() );
- }
- }
- else
- {
- Anonymizer anonymizer = attributeAnonymizers.get( attribute.getAttributeType().getOid() );
-
- if ( anonymizer == null )
- {
- newEntry.add( attribute );
- }
- else
- {
- Attribute anonymizedAttribute = anonymizer.anonymize( valueMap, attribute );
-
- newEntry.add( anonymizedAttribute );
- }
- }
- }
-
- newEntry.setDn( anonymizedDn );
- writer.write( LdifUtils.convertToLdif( newEntry ) );
- writer.write( "\n" );
- */
-
System.out.print( '.' );
if ( count % 100 == 0 )
@@ -675,7 +622,7 @@
println();
- if ( errors.size() != 0 )
+ if ( !errors.isEmpty() )
{
println( "There are " + errors.size() + " bad entries" );
int i = 0;
@@ -693,7 +640,7 @@
{
println();
- if ( errors.size() != 0 )
+ if ( !errors.isEmpty() )
{
println( "There are " + errors.size() + " bad entries" );
}
@@ -1126,20 +1073,23 @@
String ldifString = null;
- try ( BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream( args[0] ),
- Charset.defaultCharset() ) ) )
+ try ( InputStream fis = Files.newInputStream( Paths.get( args[0] ) ) )
{
- StringBuilder sb = new StringBuilder();
- String line = br.readLine();
-
- while ( line != null )
+
+ try ( BufferedReader br = new BufferedReader( new InputStreamReader( fis, Charset.defaultCharset() ) ) )
{
- sb.append( line );
- sb.append( System.lineSeparator() );
- line = br.readLine();
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while ( line != null )
+ {
+ sb.append( line );
+ sb.append( System.lineSeparator() );
+ line = br.readLine();
+ }
+
+ ldifString = sb.toString();
}
-
- ldifString = sb.toString();
}
String result = anonymizer.anonymize( ldifString );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LookupLdapConnectionValidator.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LookupLdapConnectionValidator.java
index 8e85d0e..10e9ccc 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LookupLdapConnectionValidator.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LookupLdapConnectionValidator.java
@@ -40,6 +40,7 @@
* @param connection The connection to validate
* @return True, if the connection is still valid
*/
+ @Override
public boolean validate( LdapConnection connection )
{
try
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
index 857c302..d490f91 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
@@ -32,8 +32,7 @@
/**
- *
- * TODO MonitoringLdapConnection.
+ * A class used to monitor the use of a LdapConnection
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -63,12 +62,18 @@
}
+ /**
+ * @return tells if a Bind has been issued
+ */
public boolean bindCalled()
{
return bindCalled;
}
+ /**
+ * Reset the Bind and StartTLS flags
+ */
public void resetMonitors()
{
bindCalled = false;
@@ -76,6 +81,9 @@
}
+ /**
+ * @return tells if the StarTLS extended operation has been called
+ */
public boolean startTlsCalled()
{
return startTlsCalled;
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/NoVerificationTrustManager.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/NoVerificationTrustManager.java
index 0678088..dca0b27 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/NoVerificationTrustManager.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/NoVerificationTrustManager.java
@@ -21,10 +21,12 @@
package org.apache.directory.ldap.client.api;
+import java.net.Socket;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
-import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedTrustManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,9 +37,8 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class NoVerificationTrustManager implements X509TrustManager
+public class NoVerificationTrustManager extends X509ExtendedTrustManager
{
-
/** The logger. */
private static final Logger LOG = LoggerFactory.getLogger( NoVerificationTrustManager.class );
@@ -45,15 +46,39 @@
/**
* {@inheritDoc}
*/
+ @Override
public void checkClientTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
{
LOG.debug( "checkClientTrusted {}", x509Certificates[0] );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType, Socket socket )
+ throws CertificateException
+ {
+ LOG.debug( "checkClientTrusted {}", x509Certificates[0] );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType, SSLEngine engine )
+ throws CertificateException
+ {
+ LOG.debug( "checkClientTrusted {}", x509Certificates[0] );
+ }
/**
* {@inheritDoc}
*/
+ @Override
public void checkServerTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
{
LOG.debug( "checkServerTrusted {}", x509Certificates[0] );
@@ -63,9 +88,30 @@
/**
* {@inheritDoc}
*/
+ @Override
+ public void checkServerTrusted( X509Certificate[] x509Certificates, String authType, Socket socket )
+ throws CertificateException
+ {
+ LOG.debug( "checkServerTrusted {}", x509Certificates[0] );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkServerTrusted( X509Certificate[] x509Certificates, String authType, SSLEngine engine )
+ throws CertificateException
+ {
+ LOG.debug( "checkServerTrusted {}", x509Certificates[0] );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[0];
}
-
}
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslDigestMd5Request.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslDigestMd5Request.java
index c64f4c8..f8b8d61 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslDigestMd5Request.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslDigestMd5Request.java
@@ -44,6 +44,7 @@
* {@inheritDoc}
*/
// Overriding the visibility of the method to public
+ @Override
public void setRealmName( String realmName )
{
super.setRealmName( realmName );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslGssApiRequest.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslGssApiRequest.java
index 1f23be0..4c464c8 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslGssApiRequest.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslGssApiRequest.java
@@ -172,6 +172,7 @@
* {@inheritDoc}
*/
// Overriding the visibility of the method to public
+ @Override
public void setRealmName( String realmName )
{
super.setRealmName( realmName );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslRequest.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslRequest.java
index 1b6e16e..41941c7 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslRequest.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslRequest.java
@@ -28,7 +28,6 @@
import org.apache.directory.api.ldap.model.constants.SaslQoP;
import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
import org.apache.directory.api.ldap.model.message.Control;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
@@ -43,7 +42,7 @@
protected String saslMechanism;
/** The list of controls */
- protected List<Control> controls = new ArrayList<Control>();
+ protected List<Control> controls = new ArrayList<>();
/** The username */
protected String username;
@@ -136,7 +135,7 @@
}
else
{
- return StringConstants.EMPTY_BYTES;
+ return Strings.EMPTY_BYTES;
}
}
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
index 9547c41..06e7566 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
@@ -102,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
if ( done )
@@ -150,15 +151,12 @@
throw new LdapConnectionTimeOutException( LdapNetworkConnection.TIME_OUT_ERROR );
}
- done = ( response instanceof SearchResultDone );
+ done = response instanceof SearchResultDone;
if ( done )
{
searchDoneResp = ( SearchResultDone ) response;
- // Process the response and throw an exception if needed
- //ResultCodeEnum.processResponse( searchDoneResp );
-
response = null;
}
@@ -169,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Response get() throws InvalidCursorPositionException
{
if ( !available() )
@@ -183,6 +182,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchResultDone getSearchResultDone()
{
return searchDoneResp;
@@ -192,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return response != null;
@@ -252,6 +253,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void after( Response element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -263,6 +265,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -274,6 +277,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void before( Response element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -285,6 +289,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -296,6 +301,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -307,6 +313,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -318,6 +325,7 @@
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -328,6 +336,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDone()
{
return done;
@@ -337,6 +346,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReferral()
{
return response instanceof SearchResultReference;
@@ -346,6 +356,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Referral getReferral() throws LdapException
{
if ( isReferral() )
@@ -360,6 +371,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEntry()
{
return response instanceof SearchResultEntry;
@@ -369,6 +381,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getEntry() throws LdapException
{
if ( isEntry() )
@@ -389,6 +402,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isIntermediate()
{
return response instanceof IntermediateResponse;
@@ -398,6 +412,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public IntermediateResponse getIntermediate() throws LdapException
{
if ( isEntry() )
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ValidatingPoolableLdapConnectionFactory.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ValidatingPoolableLdapConnectionFactory.java
index 85d799d..99a66e9 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ValidatingPoolableLdapConnectionFactory.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ValidatingPoolableLdapConnectionFactory.java
@@ -21,7 +21,11 @@
package org.apache.directory.ldap.client.api;
+import org.apache.directory.api.asn1.util.Oid;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.message.BindRequest;
+import org.apache.directory.api.ldap.model.message.ExtendedRequest;
+import org.apache.directory.api.ldap.model.name.Dn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -123,6 +127,7 @@
*
* @throws LdapException If unable to connect.
*/
+ @Override
public MonitoringLdapConnection makeObject() throws LdapException
{
LOG.debug( "Creating a LDAP connection" );
@@ -138,6 +143,7 @@
*
* @throws LdapException If unable to reconfigure and rebind.
*/
+ @Override
public void passivateObject( LdapConnection connection ) throws LdapException
{
LOG.debug( "Passivating {}", connection );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Wrapper.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Wrapper.java
index d6923cd..7d5e695 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Wrapper.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/Wrapper.java
@@ -24,6 +24,8 @@
* An interface for defining wrapper objects. An implementation of this class
* <b>MUST</b> implement <code>T</code> as well
*
+ * @param <T> The wrapped type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface Wrapper<T>
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/callback/SaslCallbackHandler.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/callback/SaslCallbackHandler.java
index 6cca771..0001487 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/callback/SaslCallbackHandler.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/callback/SaslCallbackHandler.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException
{
for ( Callback cb : callbacks )
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java
index 597a4d0..902b20b 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.AddResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the AddResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the add response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public AddResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java
index c2e83ad..bad1213 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.BindResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the BindResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the bind response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public BindResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/CompareFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/CompareFuture.java
index c3024fb..9562c8e 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/CompareFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/CompareFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.CompareResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the CompareResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the compare response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public CompareResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/DeleteFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/DeleteFuture.java
index 2bf43b6..8043dce 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/DeleteFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/DeleteFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.DeleteResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the DeleteResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the delete response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public DeleteResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
index 43ee198..1f57518 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.Response;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the ExtendedResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the extended response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public Response get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyDnFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyDnFuture.java
index 320f8fd..f301b86 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyDnFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyDnFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.ModifyDnResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the ModifyDnResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the modify Dn response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public ModifyDnResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyFuture.java
index 675d37f..56a386b 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ModifyFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.ModifyResponse;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,26 +44,9 @@
/**
- * Get the ModifyResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the modify response
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public ModifyResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
index a88ca79..7cb2931 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
@@ -22,11 +22,9 @@
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.apache.directory.api.ldap.model.message.Response;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -64,7 +62,7 @@
*/
public ResponseFuture( LdapConnection connection, int messageId )
{
- queue = new LinkedBlockingQueue<R>();
+ queue = new LinkedBlockingQueue<>();
this.messageId = messageId;
this.connection = connection;
}
@@ -73,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean cancel( boolean mayInterruptIfRunning )
{
if ( cancelled )
@@ -101,21 +100,20 @@
* {@inheritDoc}
* @throws InterruptedException if the operation has been cancelled by client
*/
- public R get() throws InterruptedException, ExecutionException
+ @Override
+ public R get() throws InterruptedException
{
- R response = null;
-
- response = queue.take();
-
- return response;
+ return queue.take();
}
/**
- * {@inheritDoc}
+ * Set the associated Response in this Future
+ *
+ * @param response The response to add into the Future
* @throws InterruptedException if the operation has been cancelled by client
*/
- public void set( R response ) throws InterruptedException, ExecutionException
+ public void set( R response ) throws InterruptedException
{
queue.add( response );
}
@@ -125,17 +123,17 @@
* {@inheritDoc}
* @throws InterruptedException if the operation has been cancelled by client
*/
- public R get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException, TimeoutException
+ @Override
+ public R get( long timeout, TimeUnit unit ) throws InterruptedException
{
- R response = queue.poll( timeout, unit );
-
- return response;
+ return queue.poll( timeout, unit );
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isCancelled()
{
return cancelled;
@@ -147,6 +145,7 @@
*
* {@inheritDoc}
*/
+ @Override
public boolean isDone()
{
throw new UnsupportedOperationException( "Operation not supported" );
@@ -186,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/SearchFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/SearchFuture.java
index dfe7a8e..c88d56d 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/SearchFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/SearchFuture.java
@@ -20,10 +20,6 @@
package org.apache.directory.ldap.client.api.future;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import org.apache.directory.api.ldap.model.message.Response;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -48,31 +44,9 @@
/**
- * Get the SearchResponse, blocking until one is received, or until the
- * given timeout is reached. It can be either a SearchResultEntry,
- * a SearchResultReference or a SearchResultDone, the last of all
- * the search responses.
- *
- * Get the ModifyResponse, blocking until one is received, or until the
- * given timeout is reached.
- *
- * @param timeout {@inheritDoc}
- * @param unit {@inheritDoc}
- * @return the response, either a SearchResultEntry, a SearchResultReference, or a SearchResultDone
- * @throws InterruptedException {@inheritDoc}
- * @throws ExecutionException {@inheritDoc}
- * @throws TimeoutException {@inheritDoc}
- */
- public Response get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
- TimeoutException
- {
- return super.get( timeout, unit );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/Filter.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/Filter.java
index 9260fd0..6a91acb 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/Filter.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/Filter.java
@@ -21,8 +21,7 @@
/**
- *
- * TODO Filter.
+ * The Search Filter interface
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/FilterOperator.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/FilterOperator.java
index b272316..b8ae01c 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/FilterOperator.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/FilterOperator.java
@@ -55,7 +55,7 @@
/**
* Creates a new instance of FilterOperator.
*/
- private FilterOperator( String operator )
+ FilterOperator( String operator )
{
this.operator = operator;
}
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SetOfFiltersFilter.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SetOfFiltersFilter.java
index 1561a8d..ef63216 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SetOfFiltersFilter.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SetOfFiltersFilter.java
@@ -44,7 +44,7 @@
private SetOfFiltersFilter( FilterOperator operator )
{
this.operator = operator;
- this.filters = new ArrayList<Filter>();
+ this.filters = new ArrayList<>();
}
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SubstringFilter.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SubstringFilter.java
index 03fd2c1..8008238 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SubstringFilter.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/SubstringFilter.java
@@ -58,7 +58,7 @@
// We have to filter the 'any' and remove every empty strings
if ( ( any != null ) && ( any.length != 0 ) )
{
- List<String> anyList = new ArrayList<String>();
+ List<String> anyList = new ArrayList<>();
for ( String string : any )
{
@@ -68,7 +68,7 @@
}
}
- if ( anyList.size() > 0 )
+ if ( !anyList.isEmpty() )
{
this.any = anyList.toArray( new String[]
{} );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/UnaryFilter.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/UnaryFilter.java
index c3a72f9..8b9a37c 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/UnaryFilter.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/search/UnaryFilter.java
@@ -53,7 +53,7 @@
/**
* Constructs a NOT filter with the associated inner Filter
*
- * @param Filter The inner Filter
+ * @param filter The inner Filter
* @return The constructed NOT Filter
*/
public static UnaryFilter not( Filter filter )
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/AbstractPasswordPolicyResponder.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/AbstractPasswordPolicyResponder.java
index 67af2d0..484a723 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/AbstractPasswordPolicyResponder.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/AbstractPasswordPolicyResponder.java
@@ -33,9 +33,9 @@
/**
* A base, abstract, implementation of <code>PasswordPolicyResponder</code>.
- * Extend this class and override {@link #success(PasswordPolicy)},
- * {@link #fail(ResultResponse, PasswordPolicy, ResultCodeEnum)}, or
- * {@link #exception(LdapException)}. If that does not offer enough
+ * Extend this class and override success(PasswordPolicy),
+ * fail(ResultResponse, PasswordPolicy, ResultCodeEnum), or
+ * exception(LdapException). If that does not offer enough
* flexibility, you must implement PasswordPolicyResponder yourself.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/ConnectionCallback.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/ConnectionCallback.java
index 5c34066..faa8cf9 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/ConnectionCallback.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/ConnectionCallback.java
@@ -27,6 +27,8 @@
/**
* A callback for running code against a managed {@link LdapConnection}.
*
+ * @param <T> The callback type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface ConnectionCallback<T>
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
index 9e5bf9d..d4ec178 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
@@ -674,7 +674,7 @@
public <T> List<T> search( SearchRequest searchRequest,
EntryMapper<T> entryMapper )
{
- List<T> entries = new ArrayList<T>();
+ List<T> entries = new ArrayList<>();
LdapConnection connection = null;
try
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/MemoryClearingBuffer.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/MemoryClearingBuffer.java
index 1734e0a..0dca769 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/MemoryClearingBuffer.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/MemoryClearingBuffer.java
@@ -224,7 +224,7 @@
/**
* Returns the <code>byte[]</code> used to create this buffer, or
- * {@link #getComputedBytes()} if created with a <code>char[]</code>.
+ * getComputedBytes() if created with a <code>char[]</code>.
*
* @return A byte[]
*/
@@ -237,7 +237,7 @@
/**
* Returns the <code>char[]</code> used to create this buffer, or
- * {@link #getComputedChars()} if created with a <code>byte[]</code>.
+ * getComputedChars() if created with a <code>byte[]</code>.
*
* @return A byte[]
*/
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/PasswordWarningImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/PasswordWarningImpl.java
index bac1b5f..c57073a 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/PasswordWarningImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/PasswordWarningImpl.java
@@ -66,6 +66,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int getTimeBeforeExpiration()
{
@@ -73,6 +76,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int getGraceAuthNsRemaining()
{
@@ -80,6 +86,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isChangeAfterReset()
{
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/RequestBuilder.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/RequestBuilder.java
index 9950bd8..fb3507b 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/RequestBuilder.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/RequestBuilder.java
@@ -25,6 +25,8 @@
/**
* Edits a supplied request adding specifics.
+ *
+ * @param <T> The request type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
index becc4da..e7a5ca7 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
@@ -34,9 +34,14 @@
{
private static final long serialVersionUID = 1982294624076306127L;
- private ResultResponse response;
+ private final transient ResultResponse response;
+ /**
+ * Creates a new LdapRequestUnsuccessfulException instance
+ *
+ * @param response The associated LDAP Response
+ */
public LdapRequestUnsuccessfulException( ResultResponse response )
{
super();
@@ -44,6 +49,9 @@
}
+ /**
+ * @return the associate LDAP Response
+ */
public ResultResponse getResponse()
{
return response;
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRuntimeException.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRuntimeException.java
index 95041e0..c555c52 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRuntimeException.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRuntimeException.java
@@ -34,6 +34,11 @@
private static final long serialVersionUID = 3618077059423567243L;
+ /**
+ * Creates a new LdapRuntimeException instance
+ *
+ * @param exception The wrapped exception
+ */
public LdapRuntimeException( LdapException exception )
{
super( exception );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/PasswordException.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/PasswordException.java
index e2aa13e..49bab17 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/PasswordException.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/PasswordException.java
@@ -40,6 +40,9 @@
private PasswordPolicyErrorEnum passwordPolicyError;
+ /**
+ * Creates a new PasswordException instance
+ */
public PasswordException()
{
super();
@@ -81,23 +84,44 @@
}
+ /**
+ * Sets the wrapped exception
+ *
+ * @param ldapException The wrapped exception
+ * @return The wrapping exception
+ */
public PasswordException setLdapException( LdapException ldapException )
{
this.ldapException = ldapException;
+
return this;
}
+ /**
+ * Set the Password Policy error
+ *
+ * @param passwordPolicyError The Password Policy error
+ * @return The wrapping exception
+ */
public PasswordException setPasswordPolicyError( PasswordPolicyErrorEnum passwordPolicyError )
{
this.passwordPolicyError = passwordPolicyError;
+
return this;
}
+ /**
+ * Sets the LDAP Result code
+ *
+ * @param resultCode The LDAP error code
+ * @return The wrapping exception
+ */
public PasswordException setResultCode( ResultCodeEnum resultCode )
{
this.resultCode = resultCode;
+
return this;
}
}
diff --git a/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java b/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java
new file mode 100644
index 0000000..172c1d9
--- /dev/null
+++ b/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java
@@ -0,0 +1,663 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldap.client.api;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.directory.api.asn1.util.Oid;
+import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
+import org.apache.directory.api.ldap.codec.api.LdapApiService;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.cursor.EntryCursor;
+import org.apache.directory.api.ldap.model.cursor.SearchCursor;
+import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.entry.Modification;
+import org.apache.directory.api.ldap.model.entry.ModificationOperation;
+import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.ldif.LdifEntry;
+import org.apache.directory.api.ldap.model.ldif.LdifReader;
+import org.apache.directory.api.ldap.model.message.AbandonRequest;
+import org.apache.directory.api.ldap.model.message.AddRequest;
+import org.apache.directory.api.ldap.model.message.AddResponse;
+import org.apache.directory.api.ldap.model.message.BindRequest;
+import org.apache.directory.api.ldap.model.message.BindResponse;
+import org.apache.directory.api.ldap.model.message.CompareRequest;
+import org.apache.directory.api.ldap.model.message.CompareResponse;
+import org.apache.directory.api.ldap.model.message.Control;
+import org.apache.directory.api.ldap.model.message.DeleteRequest;
+import org.apache.directory.api.ldap.model.message.DeleteResponse;
+import org.apache.directory.api.ldap.model.message.ExtendedRequest;
+import org.apache.directory.api.ldap.model.message.ExtendedResponse;
+import org.apache.directory.api.ldap.model.message.ModifyDnRequest;
+import org.apache.directory.api.ldap.model.message.ModifyDnResponse;
+import org.apache.directory.api.ldap.model.message.ModifyRequest;
+import org.apache.directory.api.ldap.model.message.ModifyResponse;
+import org.apache.directory.api.ldap.model.message.SearchRequest;
+import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.api.ldap.model.schema.ObjectClass;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.ldap.model.schema.registries.Schema;
+import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.api.util.exception.Exceptions;
+import org.junit.Test;
+
+
+/**
+ * Tests the DefaultSchemaLoader and DefaultSchemaManager with schema that is full of quirks.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class QuirkySchemaTest
+{
+
+ protected static final String SCHEMA_DN = "cn=schema";
+
+
+ /**
+ * Try to load a very minimal (and correct) schema. It has just 'person' objectclass and all
+ * the necessary attributes, matching rules and syntaxes. Load it in strict mode.
+ * This test is here mostly to make sure that the test itself works.
+ */
+ @Test
+ public void testLoadMinimalSchema() throws Exception
+ {
+ LdapConnection connection = createFakeConnection( "src/test/resources/schema-minimal.ldif" );
+ DefaultSchemaLoader loader = new DefaultSchemaLoader( connection );
+ Collection<Schema> allEnabled = loader.getAllEnabled();
+ assertEquals( 1, allEnabled.size() );
+ Schema schema = allEnabled.iterator().next();
+ assertNotNull( schema );
+ assertEquals( 26, schema.getContent().size() );
+
+ SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+ boolean loaded = schemaManager.loadAllEnabled();
+
+ if ( !loaded )
+ {
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+ }
+
+ assertTrue( schemaManager.getRegistries().getAttributeTypeRegistry().contains( "cn" ) );
+ ObjectClass person = schemaManager.getRegistries().getObjectClassRegistry().lookup( "person" );
+ assertNotNull( person );
+ assertEquals( 2, person.getMustAttributeTypes().size() );
+ assertEquals( 4, person.getMayAttributeTypes().size() );
+ }
+
+ /**
+ * Try to load a quirky schema. This schema has a lot of issues that violate the
+ * standards. Therefore load the schema in relaxed mode. We should be able to work
+ * with this schema anyway. E.g. the loader and schema manager should not die on
+ * null pointer or similar trivial error.
+ */
+ @Test
+ public void testLoadQuirkySchema() throws Exception
+ {
+ LdapConnection connection = createFakeConnection( "src/test/resources/schema-quirky.ldif" );
+ DefaultSchemaLoader loader = new DefaultSchemaLoader( connection, true );
+ Collection<Schema> allEnabled = loader.getAllEnabled();
+ assertEquals( 1, allEnabled.size() );
+ Schema schema = allEnabled.iterator().next();
+ assertNotNull( schema );
+// assertEquals( 26, schema.getContent().size() );
+
+ SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+ boolean loaded = schemaManager.loadAllEnabledRelaxed();
+
+ if ( !loaded )
+ {
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+ }
+
+ assertTrue ( "Surprisingly no errors after load", schemaManager.getErrors().size() > 0 );
+
+ assertTrue( schemaManager.getRegistries().getAttributeTypeRegistry().contains( "cn" ) );
+ ObjectClass person = schemaManager.getRegistries().getObjectClassRegistry().lookup( "person" );
+ assertNotNull( person );
+ assertEquals( 2, person.getMustAttributeTypes().size() );
+ assertEquals( 5, person.getMayAttributeTypes().size() );
+ }
+
+
+ private LdapConnection createFakeConnection( final String schemaFileName )
+ {
+ return new LdapConnection()
+ {
+
+ @Override
+ public void unBind() throws LdapException
+ {
+ }
+
+
+ @Override
+ public void setTimeOut( long timeOut )
+ {
+ }
+
+
+ @Override
+ public void setSchemaManager( SchemaManager schemaManager )
+ {
+ }
+
+
+ @Override
+ public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter )
+ {
+ }
+
+
+ @Override
+ public SearchCursor search( SearchRequest searchRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
+ throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void rename( String entryDn, String newRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void moveAndRename( String entryDn, String newDn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void move( String entryDn, String newSuperiorDn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void modify( String dn, Modification... modifications ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void modify( Dn dn, Modification... modifications ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
+ {
+ return lookup(new Dn(dn));
+ }
+
+
+ @Override
+ public Entry lookup( String dn, String... attributes ) throws LdapException
+ {
+ return lookup(new Dn(dn));
+ }
+
+
+ @Override
+ public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
+ {
+ return lookup(dn);
+ }
+
+
+ @Override
+ public Entry lookup( Dn dn, String... attributes ) throws LdapException
+ {
+ return lookup(dn);
+ }
+
+
+ @Override
+ public Entry lookup( String dn ) throws LdapException
+ {
+ return lookup(new Dn(dn));
+ }
+
+
+ @Override
+ public Entry lookup( Dn dn ) throws LdapException
+ {
+ if (dn.isRootDse()) {
+ Entry entry = new DefaultEntry( dn );
+ entry.add( SchemaConstants.SUBSCHEMA_SUBENTRY_AT, SCHEMA_DN );
+ return entry;
+ } else if (dn.toString().equals( SCHEMA_DN )) {
+ Entry entry = loadSchemaEntry( schemaFileName );
+ return entry;
+ } else {
+ throw new UnsupportedOperationException("Unexpected DN "+dn);
+ }
+ }
+
+
+ @Override
+ public void loadSchemaRelaxed() throws LdapException
+ {
+ }
+
+
+ @Override
+ public void loadSchema() throws LdapException
+ {
+ }
+
+
+ @Override
+ public boolean isRequestCompleted( int messageId )
+ {
+ return true;
+ }
+
+
+ @Override
+ public boolean isControlSupported( String controlOID ) throws LdapException
+ {
+ return true;
+ }
+
+
+ @Override
+ public boolean isConnected()
+ {
+ return true;
+ }
+
+
+ @Override
+ public boolean isAuthenticated()
+ {
+ return false;
+ }
+
+
+ @Override
+ public List<String> getSupportedControls() throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public SchemaManager getSchemaManager()
+ {
+ return null;
+ }
+
+
+ @Override
+ public Entry getRootDse( String... attributes ) throws LdapException
+ {
+ return lookup( Dn.ROOT_DSE );
+ }
+
+
+ @Override
+ public Entry getRootDse() throws LdapException
+ {
+ return lookup( Dn.ROOT_DSE );
+ }
+
+
+ @Override
+ public LdapApiService getCodecService()
+ {
+ return null;
+ }
+
+
+ @Override
+ public BinaryAttributeDetector getBinaryAttributeDetector()
+ {
+ return null;
+ }
+
+
+ @Override
+ public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public ExtendedResponse extended( Oid oid ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public ExtendedResponse extended( String oid ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public boolean exists( Dn dn ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean exists( String dn ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean doesFutureExistFor( int messageId )
+ {
+ return false;
+ }
+
+
+ @Override
+ public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public void delete( Dn dn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void delete( String dn ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public boolean connect() throws LdapException
+ {
+ return true;
+ }
+
+
+ @Override
+ public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public boolean compare( String dn, String attributeName, String value ) throws LdapException
+ {
+ return false;
+ }
+
+
+ @Override
+ public void close() throws IOException
+ {
+ }
+
+
+ @Override
+ public BindResponse bind( BindRequest bindRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public void bind( Dn name, String credentials ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void bind( Dn name ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void bind( String name, String credentials ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void bind( String name ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void bind() throws LdapException
+ {
+ }
+
+
+ @Override
+ public void anonymousBind() throws LdapException
+ {
+ }
+
+
+ @Override
+ public AddResponse add( AddRequest addRequest ) throws LdapException
+ {
+ return null;
+ }
+
+
+ @Override
+ public void add( Entry entry ) throws LdapException
+ {
+ }
+
+
+ @Override
+ public void abandon( AbandonRequest abandonRequest )
+ {
+ }
+
+
+ @Override
+ public void abandon( int messageId )
+ {
+ }
+ };
+ }
+
+ private Entry loadSchemaEntry( String schemaFileName )
+ {
+ LdifEntry ldifEntry = null;
+ try
+ {
+ InputStream in = new FileInputStream( schemaFileName );
+ LdifReader ldifReader = new LdifReader( in );
+ if (ldifReader.hasNext())
+ {
+ ldifEntry = ldifReader.next();
+ }
+
+ ldifReader.close();
+ }
+ catch ( IOException e )
+ {
+ throw new IllegalStateException( "IO error with " + schemaFileName , e );
+ }
+ catch (LdapException e ) {
+ throw new IllegalStateException( "LDAP error with " + schemaFileName , e );
+ }
+ if (ldifEntry == null) {
+ throw new IllegalStateException( "No entry in LDIF " + schemaFileName );
+ }
+ return ldifEntry.getEntry();
+ }
+}
diff --git a/ldap/client/api/src/test/resources/schema-minimal.ldif b/ldap/client/api/src/test/resources/schema-minimal.ldif
new file mode 100644
index 0000000..9f082c3
--- /dev/null
+++ b/ldap/client/api/src/test/resources/schema-minimal.ldif
@@ -0,0 +1,73 @@
+#############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#############################################################################
+# Minimal correct schema
+dn: cn=schema
+objectClass: top
+objectClass: subentry
+objectClass: subschema
+cn: schema
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )
+matchingRules: ( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch' SYN
+ TAX 1.3.6.1.4.1.1466.115.121.1.26 )
+matchingRules: ( 2.5.13.0 NAME 'objectIdentifierMatch' SYNTAX 1.3.6.1.4.1.1466
+ .115.121.1.38 )
+matchingRules: ( 2.5.13.1 NAME 'distinguishedNameMatch' SYNTAX 1.3.6.1.4.1.146
+ 6.115.121.1.12 )
+matchingRules: ( 2.5.13.2 NAME 'caseIgnoreMatch' SYNTAX 1.3.6.1.4.1.1466.115.1
+ 21.1.15 )
+matchingRules: ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' SYNTAX 1.3.6.1.4.1.
+ 1466.115.121.1.58 )
+matchingRules: ( 2.5.13.17 NAME 'octetStringMatch' SYNTAX 1.3.6.1.4.1.1466.115
+ .121.1.40 )
+matchingRules: ( 2.5.13.20 NAME 'telephoneNumberMatch' SYNTAX 1.3.6.1.4.1.1466
+ .115.121.1.50 )
+matchingRules: ( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' SYNTAX 1.3.6.
+ 1.4.1.1466.115.121.1.58 )
+attributeTypes: ( 2.5.4.0 NAME 'objectClass' DESC 'RFC4512: object classes of
+ the entity' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.
+ 38 )
+attributeTypes: ( 2.5.4.13 NAME 'description' DESC 'RFC4519: descriptive infor
+ mation' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.
+ 6.1.4.1.1466.115.121.1.15{1024} )
+attributeTypes: ( 2.5.4.20 NAME 'telephoneNumber' DESC 'RFC2256: Telephone Num
+ ber' EQUALITY telephoneNumberMatch SUBSTR telephoneNumberSubstringsMatch SYNT
+ AX 1.3.6.1.4.1.1466.115.121.1.50{32} )
+attributeTypes: ( 2.5.4.41 NAME 'name' DESC 'RFC4519: common supertype of name
+ attributes' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX
+ 1.3.6.1.4.1.1466.115.121.1.15{32768} )
+attributeTypes: ( 2.5.4.49 NAME 'distinguishedName' DESC 'RFC4519: common supe
+ rtype of DN attributes' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.14
+ 66.115.121.1.12 )
+attributeTypes: ( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC4519: common nam
+ e(s) for which the entity is known by' SUP name )
+attributeTypes: ( 2.5.4.4 NAME ( 'sn' 'surname' ) DESC 'RFC2256: last (family)
+ name(s) for which the entity is known by' SUP name )
+attributeTypes: ( 2.5.4.34 NAME 'seeAlso' DESC 'RFC4519: DN of related object'
+ SUP distinguishedName )
+attributeTypes: ( 2.5.4.35 NAME 'userPassword' DESC 'RFC4519/2307: password of
+ user' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )
+objectClasses: ( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRAC
+ T MUST objectClass )
+objectClasses: ( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCT
+ URAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ descri
+ ption ) )
diff --git a/ldap/client/api/src/test/resources/schema-quirky.ldif b/ldap/client/api/src/test/resources/schema-quirky.ldif
new file mode 100644
index 0000000..9acd3cd
--- /dev/null
+++ b/ldap/client/api/src/test/resources/schema-quirky.ldif
@@ -0,0 +1,75 @@
+#############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#############################################################################
+# Quirky schema. There are a lot of issues with the schema. It is not
+# standard-compliant.
+dn: cn=schema
+objectClass: top
+objectClass: subentry
+objectClass: subschema
+cn: schema
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )
+ldapSyntaxes: ( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )
+# We do not have syntax 1.3.6.1.4.1.1466.115.121.1.38, 40 and 58
+matchingRules: ( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch' SYN
+ TAX 1.3.6.1.4.1.1466.115.121.1.26 )
+matchingRules: ( 2.5.13.0 NAME 'objectIdentifierMatch' SYNTAX 1.3.6.1.4.1.1466
+ .115.121.1.38 )
+matchingRules: ( 2.5.13.1 NAME 'distinguishedNameMatch' SYNTAX 1.3.6.1.4.1.146
+ 6.115.121.1.12 )
+matchingRules: ( 2.5.13.2 NAME 'caseIgnoreMatch' SYNTAX 1.3.6.1.4.1.1466.115.1
+ 21.1.15 )
+matchingRules: ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' SYNTAX 1.3.6.1.4.1.
+ 1466.115.121.1.58 )
+matchingRules: ( 2.5.13.17 NAME 'octetStringMatch' SYNTAX 1.3.6.1.4.1.1466.115
+ .121.1.40 )
+matchingRules: ( 2.5.13.20 NAME 'telephoneNumberMatch' SYNTAX 1.3.6.1.4.1.1466
+ .115.121.1.50 )
+ # No definition for telephoneNumberSubstringsMatch (2.5.13.21)
+attributeTypes: ( 2.5.4.0 NAME 'objectClass' DESC 'RFC4512: object classes of
+ the entity' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.
+ 38 )
+ # No definition for 'description' attribute (2.5.4.13)
+attributeTypes: ( 2.5.4.20 NAME 'telephoneNumber' DESC 'RFC2256: Telephone Num
+ ber' EQUALITY telephoneNumberMatch SUBSTR telephoneNumberSubstringsMatch SYNT
+ AX 1.3.6.1.4.1.1466.115.121.1.50{32} )
+attributeTypes: ( 2.5.4.41 NAME 'name' DESC 'RFC4519: common supertype of name
+ attributes' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX
+ 1.3.6.1.4.1.1466.115.121.1.15{32768} )
+attributeTypes: ( 2.5.4.49 NAME 'distinguishedName' DESC 'RFC4519: common supe
+ rtype of DN attributes' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.14
+ 66.115.121.1.12 )
+attributeTypes: ( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC4519: common nam
+ e(s) for which the entity is known by' SUP name )
+# 'sn' definition has no syntax
+attributeTypes: ( 2.5.4.4 NAME 'sn' )
+attributeTypes: ( 2.5.4.34 NAME 'seeAlso' DESC 'RFC4519: DN of related object'
+ SUP distinguishedName )
+# userPassword has matching rule, but it does not have syntax
+attributeTypes: ( 2.5.4.35 NAME 'userPassword' DESC 'RFC4519/2307: password of
+ user' EQUALITY octetStringMatch )
+objectClasses: ( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRAC
+ T MUST objectClass )
+# subSn is a subtype of sn which does not have a syntax OID
+attributeTypes: ( 1.3.6.1.4.1.45689.1.4.300.1 NAME 'subSn' SUP sn )
+# subPassword is a subtype of userPassword which does has syntax OID, but has no
+# syntax definition
+attributeTypes: ( 1.3.6.1.4.1.45689.1.4.300.2 NAME 'subPassword' SUP userPassword )
+objectClasses: ( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCT
+ URAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ descri
+ ption $ subSn $ subPassword ) )
diff --git a/ldap/client/pom.xml b/ldap/client/pom.xml
index d24b854..f8f2032 100644
--- a/ldap/client/pom.xml
+++ b/ldap/client/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-client-parent</artifactId>
diff --git a/ldap/codec/core/pom.xml b/ldap/codec/core/pom.xml
index f58dbdd..7ebba0d 100644
--- a/ldap/codec/core/pom.xml
+++ b/ldap/codec/core/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-codec-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-codec-core</artifactId>
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/AttributeValueAssertion.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/AttributeValueAssertion.java
index be1eefa..b1d3707 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/AttributeValueAssertion.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/AttributeValueAssertion.java
@@ -140,7 +140,7 @@
*/
public String toString( String tabs )
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( tabs ).append( "AttributeValueAssertion\n" );
sb.append( tabs ).append( " Assertion description : '" );
@@ -161,7 +161,7 @@
*/
public String toStringRFC2254( int filterType )
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( attributeDesc );
@@ -198,6 +198,7 @@
*
* @return An AttributeValueAssertion String
*/
+ @Override
public String toString()
{
return toString( "" );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/BasicControlDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/BasicControlDecorator.java
index eab8421..019bec6 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/BasicControlDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/BasicControlDecorator.java
@@ -40,7 +40,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class BasicControlDecorator<E> extends ControlDecorator<Control>
+public class BasicControlDecorator extends ControlDecorator<Control>
{
/**
* Creates a new instance of BasicControlDecorator, decorating a
@@ -58,6 +58,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
return null;
@@ -67,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int computeLength()
{
// Call the super class to compute the global control length
@@ -86,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapMessageGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapMessageGrammar.java
index c3713b9..c54978b 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapMessageGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapMessageGrammar.java
@@ -146,7 +146,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public final class LdapMessageGrammar<E> extends
+public final class LdapMessageGrammar extends
AbstractGrammar<LdapMessageContainer<MessageDecorator<? extends Message>>>
{
/** The logger */
@@ -157,7 +157,7 @@
/** The instance of grammar. LdapMessageGrammar is a singleton */
private static Grammar<LdapMessageContainer<MessageDecorator<? extends Message>>> instance =
- new LdapMessageGrammar<LdapMessageContainer<MessageDecorator<? extends Message>>>();
+ new LdapMessageGrammar();
/**
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapStatesEnum.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapStatesEnum.java
index 6d2e7e1..7fee3ee 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapStatesEnum.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/LdapStatesEnum.java
@@ -20,8 +20,6 @@
package org.apache.directory.api.ldap.codec;
-import org.apache.directory.api.asn1.ber.Asn1Container;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -156,37 +154,15 @@
/**
* Get the grammar name
*
- * @param grammar
- * The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "LDAP_MESSAGE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar
- * The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<Asn1Container> grammar )
- {
- if ( grammar instanceof LdapMessageGrammar )
- {
- return "LDAP_MESSAGE_GRAMMAR";
- }
- else
- {
- return "UNKNOWN GRAMMAR";
- }
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -194,13 +170,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "LDAP_MESSAGE_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "LDAP_MESSAGE_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -210,6 +187,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSaslCredentials.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSaslCredentials.java
index 9280a05..a10def7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSaslCredentials.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSaslCredentials.java
@@ -26,7 +26,6 @@
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator;
import org.apache.directory.api.ldap.model.message.BindRequest;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,7 +72,7 @@
// credentials
if ( tlv.getLength() == 0 )
{
- bindRequestMessage.setCredentials( StringConstants.EMPTY_BYTES );
+ bindRequestMessage.setCredentials( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSimpleAuth.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSimpleAuth.java
index a95b023..edc8092 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSimpleAuth.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindRequest/StoreSimpleAuth.java
@@ -26,7 +26,6 @@
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator;
import org.apache.directory.api.ldap.model.message.BindRequest;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,7 +78,7 @@
// We have to handle the special case of a 0 length simple
if ( tlv.getLength() == 0 )
{
- bindRequestMessage.setCredentials( StringConstants.EMPTY_BYTES );
+ bindRequestMessage.setCredentials( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindResponse/StoreServerSASLCreds.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindResponse/StoreServerSASLCreds.java
index faba3dc..92d59e5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindResponse/StoreServerSASLCreds.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/bindResponse/StoreServerSASLCreds.java
@@ -26,7 +26,6 @@
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.BindResponseDecorator;
import org.apache.directory.api.ldap.model.message.BindResponse;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,11 +68,11 @@
// We have to handle the special case of a 0 length server
// sasl credentials
- byte[] serverSaslCreds = null;
+ byte[] serverSaslCreds;
if ( tlv.getLength() == 0 )
{
- serverSaslCreds = StringConstants.EMPTY_BYTES;
+ serverSaslCreds = Strings.EMPTY_BYTES;
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/compareRequest/StoreCompareRequestEntryName.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/compareRequest/StoreCompareRequestEntryName.java
index 9bc7da3..439aadf 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/compareRequest/StoreCompareRequestEntryName.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/compareRequest/StoreCompareRequestEntryName.java
@@ -73,7 +73,7 @@
// Get the Value and store it in the CompareRequest
TLV tlv = container.getCurrentTLV();
- Dn entry = null;
+ Dn entry;
// We have to handle the special case of a 0 length matched
// Dn
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/InitControls.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/InitControls.java
index 8d7e759..98f410f 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/InitControls.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/InitControls.java
@@ -35,6 +35,8 @@
* <pre>
* ... },
* controls [0] Controls OPTIONAL }
+ *
+ * Controls ::= SEQUENCE OF control Control
* </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -64,18 +66,23 @@
TLV tlv = container.getCurrentTLV();
int expectedLength = tlv.getLength();
- // The Length should be null
- if ( expectedLength == 0 )
+ // The Length can be null
+ if ( expectedLength != 0 )
{
- LOG.error( "The length of controls must not be null" );
-
- // This will generate a PROTOCOL_ERROR
- throw new DecoderException( "The length of controls must not be null" );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "A new list of controls has been initialized" );
+ }
+ }
+ else
+ {
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "An empty list of controls has been initialized" );
+ }
}
- if ( IS_DEBUG )
- {
- LOG.debug( "A new list of controls has been initialized" );
- }
+ // We can have an END transition
+ container.setGrammarEndAllowed( true );
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlCriticality.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlCriticality.java
index 497dbd9..c221fe0 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlCriticality.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlCriticality.java
@@ -73,7 +73,7 @@
TLV tlv = container.getCurrentTLV();
// Get the current control
- Control control = null;
+ Control control;
MessageDecorator<? extends Message> message = container.getMessage();
control = message.getCurrentControl();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlValue.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlValue.java
index 29b9155..d4d26d5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlValue.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/StoreControlValue.java
@@ -29,7 +29,6 @@
import org.apache.directory.api.ldap.codec.api.MessageDecorator;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.Message;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,7 +80,7 @@
// Store the value - have to handle the special case of a 0 length value
if ( tlv.getLength() == 0 )
{
- control.setValue( StringConstants.EMPTY_BYTES );
+ control.setValue( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/delRequest/InitDelRequest.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/delRequest/InitDelRequest.java
index 62f6a29..59d0a56 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/delRequest/InitDelRequest.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/delRequest/InitDelRequest.java
@@ -84,7 +84,7 @@
// We have to handle the special case of a 0 length matched
// Dn
- Dn entry = null;
+ Dn entry;
if ( tlv.getLength() == 0 )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedRequest/StoreExtendedRequestValue.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedRequest/StoreExtendedRequestValue.java
index cae2c31..831964a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedRequest/StoreExtendedRequestValue.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedRequest/StoreExtendedRequestValue.java
@@ -25,7 +25,7 @@
import org.apache.directory.api.asn1.ber.tlv.TLV;
import org.apache.directory.api.ldap.codec.api.ExtendedRequestDecorator;
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,7 +72,7 @@
// value
if ( tlv.getLength() == 0 )
{
- extendedRequest.setRequestValue( StringConstants.EMPTY_BYTES );
+ extendedRequest.setRequestValue( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/InitExtendedResponse.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/InitExtendedResponse.java
index fbb4bf2..37d22b2 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/InitExtendedResponse.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/InitExtendedResponse.java
@@ -58,7 +58,7 @@
public void action( LdapMessageContainer<ExtendedResponseDecorator<?>> container ) throws DecoderException
{
// Now, we can allocate the ExtendedResponse Object
- ExtendedResponseDecorator<?> extendedResponse = new ExtendedResponseDecorator<ExtendedResponseImpl>(
+ ExtendedResponseDecorator<?> extendedResponse = new ExtendedResponseDecorator<>(
container.getLdapCodecService(), new ExtendedResponseImpl( container.getMessageId() ) );
container.setMessage( extendedResponse );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
index e64e3d7..3b3cf3c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
@@ -70,7 +70,7 @@
public void action( LdapMessageContainer<ExtendedResponseDecorator<?>> container ) throws DecoderException
{
// We can allocate the ExtendedResponse Object
- ExtendedResponse extendedResponse = null;
+ ExtendedResponse extendedResponse;
// Get the Value and store it in the ExtendedResponse
TLV tlv = container.getCurrentTLV();
@@ -91,8 +91,8 @@
extendedResponse = LdapApiServiceFactory.getSingleton().newExtendedResponse( responseName,
container.getMessageId(), null );
- ( ( ExtendedResponseDecorator<?> ) extendedResponse ).setLdapResult( ( ( LdapResultDecorator ) ( container
- .getMessage().getLdapResult() ) ) );
+ ( ( ExtendedResponseDecorator<?> ) extendedResponse ).setLdapResult( ( LdapResultDecorator ) ( container
+ .getMessage().getLdapResult() ) );
container.setMessage( LdapApiServiceFactory.getSingleton().decorate( extendedResponse ) );
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseValue.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseValue.java
index 407fab6..9a4ef87 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseValue.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseValue.java
@@ -25,7 +25,7 @@
import org.apache.directory.api.asn1.ber.tlv.TLV;
import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,7 +72,7 @@
// OID
if ( tlv.getLength() == 0 )
{
- extendedResponse.setResponseValue( StringConstants.EMPTY_BYTES );
+ extendedResponse.setResponseValue( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
index b185d0f..53085eb 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
@@ -26,7 +26,6 @@
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.IntermediateResponseDecorator;
import org.apache.directory.api.ldap.model.message.IntermediateResponse;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,7 +74,7 @@
// value
if ( tlv.getLength() == 0 )
{
- intermediateResponse.setResponseValue( StringConstants.EMPTY_BYTES );
+ intermediateResponse.setResponseValue( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/AddReferral.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/AddReferral.java
index 0eb5784..0dc7f66 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/AddReferral.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/AddReferral.java
@@ -104,7 +104,7 @@
if ( IS_DEBUG )
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( String url : ldapResult.getReferral().getLdapUrls() )
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreErrorMessage.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreErrorMessage.java
index ecf4ec9..844e16a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreErrorMessage.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreErrorMessage.java
@@ -69,7 +69,7 @@
{
// Get the Value and store it in the BindResponse
TLV tlv = container.getCurrentTLV();
- String errorMessage = null;
+ String errorMessage;
// We have to handle the special case of a 0 length error
// message
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreMatchedDN.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreMatchedDN.java
index 4abcbc3..1aaa467 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreMatchedDN.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/ldapResult/StoreMatchedDN.java
@@ -73,8 +73,8 @@
{
// Get the Value and store it in the BindResponse
TLV tlv = container.getCurrentTLV();
- Dn matchedDn = null;
- ResultCodeEnum resultCode = null;
+ Dn matchedDn;
+ ResultCodeEnum resultCode;
ResultResponse response = ( ResultResponse ) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestEntryName.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestEntryName.java
index 9c05096..41fe5f5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestEntryName.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestEntryName.java
@@ -76,7 +76,7 @@
// We have to handle the special case of a 0 length matched
// Dn
- Dn entry = null;
+ Dn entry;
if ( tlv.getLength() == 0 )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestNewRdn.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestNewRdn.java
index 32dd41f..0c46b63 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestNewRdn.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyDnRequest/StoreModifyDnRequestNewRdn.java
@@ -80,7 +80,7 @@
// We have to handle the special case of a 0 length matched
// newDN
- Rdn newRdn = null;
+ Rdn newRdn;
if ( tlv.getLength() == 0 )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/AddModifyRequestAttribute.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/AddModifyRequestAttribute.java
index ab935fb..d4a497d 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/AddModifyRequestAttribute.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/AddModifyRequestAttribute.java
@@ -79,7 +79,7 @@
TLV tlv = container.getCurrentTLV();
// Store the value. It can't be null
- String type = null;
+ String type;
if ( tlv.getLength() == 0 )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java
index 2122f71..a40e2a5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java
@@ -25,7 +25,6 @@
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.ModifyRequestDecorator;
import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,7 +63,7 @@
TLV tlv = container.getCurrentTLV();
// Store the value. It can't be null
- byte[] value = StringConstants.EMPTY_BYTES;
+ byte[] value = Strings.EMPTY_BYTES;
try
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestBaseObject.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestBaseObject.java
index ebf63ac..e5fac47 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestBaseObject.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestBaseObject.java
@@ -71,7 +71,7 @@
TLV tlv = container.getCurrentTLV();
// We have to check that this is a correct Dn
- Dn baseObject = null;
+ Dn baseObject;
// We have to handle the special case of a 0 length base
// object,
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestTypesOnly.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestTypesOnly.java
index 8215246..0267631 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestTypesOnly.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/StoreSearchRequestTypesOnly.java
@@ -94,8 +94,8 @@
if ( IS_DEBUG )
{
- LOG.debug( "The search will return {}", ( searchRequest.getTypesOnly() ? "only attributs type"
- : "attributes types and values" ) );
+ LOG.debug( "The search will return {}", searchRequest.getTypesOnly() ? "only attributs type"
+ : "attributes types and values" );
}
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/InitAssertionValueFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/InitAssertionValueFilter.java
index 47d9fa2..7f4a32a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/InitAssertionValueFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/InitAssertionValueFilter.java
@@ -30,7 +30,6 @@
import org.apache.directory.api.ldap.model.entry.BinaryValue;
import org.apache.directory.api.ldap.model.entry.StringValue;
import org.apache.directory.api.ldap.model.entry.Value;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,16 +68,7 @@
TLV tlv = container.getCurrentTLV();
// The value can be null.
- Value<?> assertionValue = null;
-
- if ( tlv.getLength() != 0 )
- {
- assertionValue = new BinaryValue( tlv.getValue().getData() );
- }
- else
- {
- assertionValue = new BinaryValue( StringConstants.EMPTY_BYTES );
- }
+ Value<?> assertionValue;
AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter )
searchRequestDecorator.getTerminalFilter();
@@ -92,7 +82,7 @@
}
else
{
- assertionValue = new BinaryValue( StringConstants.EMPTY_BYTES );
+ assertionValue = new BinaryValue( Strings.EMPTY_BYTES );
}
assertion.setAssertionValue( assertionValue );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java
index 8bc602e..17fee52 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java
@@ -66,6 +66,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
SearchRequestDecorator searchRequest = container.getMessage();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/CodecControl.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/CodecControl.java
index 8ced9d3..a6fc80f 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/CodecControl.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/CodecControl.java
@@ -29,6 +29,8 @@
* The codec uses this interface to add additional information to LDAP Model
* Control objects during encoding and decoding.
*
+ * @param <E> The control being handled by this codec
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface CodecControl<E extends Control> extends Control, Decorator<E>
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecoder.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecoder.java
deleted file mode 100644
index 43c6d43..0000000
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecoder.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.directory.api.ldap.codec.api;
-
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.DecoderException;
-import org.apache.directory.api.ldap.model.message.Control;
-
-
-/**
- * An interface for decoders of controls.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public interface ControlDecoder<E extends Control>
-{
- /**
- * Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.
- *
- * @param controlBytes the encoded control bytes
- * @return the decoded Asn1Object for the control
- * @throws DecoderException if anything goes wrong
- */
- Asn1Object decode( byte[] controlBytes ) throws DecoderException;
-}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecorator.java
index 72b2457..02660bd 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlDecorator.java
@@ -63,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E getDecorated()
{
return decorated;
@@ -70,7 +71,9 @@
/**
- * {@inheritDoc}
+ * Set the control to be decorated.
+ *
+ * @param decorated The decorated control
*/
public void setDecorated( E decorated )
{
@@ -81,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapApiService getCodecService()
{
return codec;
@@ -92,10 +96,11 @@
// ------------------------------------------------------------------------
/**
- * Get the OID
+ * Get the control OID
*
* @return A string which represent the control oid
*/
+ @Override
public String getOid()
{
return decorated.getOid();
@@ -105,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasValue()
{
return value != null;
@@ -116,6 +122,7 @@
*
* @return The control value
*/
+ @Override
public byte[] getValue()
{
return value;
@@ -127,6 +134,7 @@
*
* @param value The encoded control value to store
*/
+ @Override
public void setValue( byte[] value )
{
if ( value != null )
@@ -147,6 +155,7 @@
*
* @return <code>true</code> if the criticality flag is true.
*/
+ @Override
public boolean isCritical()
{
return decorated.isCritical();
@@ -158,6 +167,7 @@
*
* @param criticality The criticality value
*/
+ @Override
public void setCritical( boolean criticality )
{
decorated.setCritical( criticality );
@@ -167,10 +177,10 @@
// ------------------------------------------------------------------------
// CodecControl Methods
// ------------------------------------------------------------------------
-
/**
* {@inheritDoc}
*/
+ @Override
public int computeLength()
{
return 0;
@@ -180,10 +190,10 @@
// ------------------------------------------------------------------------
// Object Method Overrides
// ------------------------------------------------------------------------
-
/**
* @see Object#hashCode()
*/
+ @Override
public int hashCode()
{
return decorated.hashCode();
@@ -193,6 +203,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
if ( decorated == null )
@@ -209,6 +220,7 @@
/**
* Return a String representing a Control
*/
+ @Override
public String toString()
{
return decorated.toString();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlFactory.java
index d147a47..8335f1c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ControlFactory.java
@@ -29,11 +29,9 @@
* then registered with the codec and used by the codec to encode and decode
* those controls.
*
- * TODO must review this interface - too many methods - implementors should not
- * have to implement so many methods.
- *
+ * @param <C> The Control to create
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
*/
public interface ControlFactory<C extends Control>
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/Decorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/Decorator.java
index a04970e..1a67cbb 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/Decorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/Decorator.java
@@ -29,6 +29,8 @@
* The codec uses this interface to add additional information to LDAP Model
* objects during encoding and decoding,
*
+ * @param <E> The element to decorate
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface Decorator<E>
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java
index 3c12d25..dccc852 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/DefaultConfigurableBinaryAttributeDetector.java
@@ -66,7 +66,7 @@
implements ConfigurableBinaryAttributeDetector
{
/** A set of binary Attribute ID */
- private Set<String> binaryAttributes = new ConcurrentHashSet<String>();
+ private Set<String> binaryAttributes = new ConcurrentHashSet<>();
/** A list of all the known binary attributes */
public static final String[] DEFAULT_BINARY_ATTRIBUTES = new String[]
@@ -137,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isBinary( String attributeId )
{
boolean isBinary = super.isBinary( attributeId );
@@ -155,6 +156,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addBinaryAttribute( String... binaryAttributes )
{
if ( binaryAttributes != null )
@@ -171,6 +173,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void removeBinaryAttribute( String... binaryAttributes )
{
if ( binaryAttributes != null )
@@ -187,6 +190,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setBinaryAttributes( String... binaryAttributes )
{
this.binaryAttributes.clear();
@@ -195,9 +199,11 @@
if ( binaryAttributes == null )
{
// Reseting to the default list of binary attributes
- binaryAttributes = DEFAULT_BINARY_ATTRIBUTES;
+ addBinaryAttribute( DEFAULT_BINARY_ATTRIBUTES );
}
-
- addBinaryAttribute( binaryAttributes );
+ else
+ {
+ addBinaryAttribute( binaryAttributes );
+ }
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
index 2d2b6db..7c5a49e 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
@@ -35,6 +35,8 @@
/**
* A decorator for the ExtendedRequest message
*
+ * @param <Q> The extended request to decorate
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ExtendedRequestDecorator<Q extends ExtendedRequest>
@@ -69,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getRequestName()
{
return getDecorated().getRequestName();
@@ -78,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest setRequestName( String oid )
{
getDecorated().setRequestName( oid );
@@ -87,7 +91,9 @@
/**
- * {@inheritDoc}
+ * Gets the Extended request payload
+ *
+ * @return The extended payload
*/
public byte[] getRequestValue()
{
@@ -96,7 +102,9 @@
/**
- * {@inheritDoc}
+ * sets the Extended request payload
+ *
+ * @param requestValue The extended payload
*/
public void setRequestValue( byte[] requestValue )
{
@@ -107,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -118,6 +127,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addControl( Control control )
{
return ( ExtendedRequest ) super.addControl( control );
@@ -127,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addAllControls( Control[] controls )
{
return ( ExtendedRequest ) super.addAllControls( controls );
@@ -136,6 +147,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest removeControl( Control control )
{
return ( ExtendedRequest ) super.removeControl( control );
@@ -162,6 +174,7 @@
* Length(ExtendedRequest) = Length(0x77) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
requestNameBytes = Strings.getBytesUtf8( getRequestName() );
@@ -189,6 +202,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedResponseDecorator.java
index f4c9fe0..584c69c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedResponseDecorator.java
@@ -35,6 +35,8 @@
/**
* A decorator for the ExtendedResponse message
*
+ * @param <R> The extended response to decorate
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ExtendedResponseDecorator<R extends ExtendedResponse> extends ResponseDecorator<R>
@@ -69,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getResponseName()
{
return getDecorated().getResponseName();
@@ -78,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setResponseName( String oid )
{
getDecorated().setResponseName( oid );
@@ -85,7 +89,9 @@
/**
- * {@inheritDoc}
+ * Gets the Extended response payload
+ *
+ * @return The extended payload
*/
public byte[] getResponseValue()
{
@@ -94,7 +100,9 @@
/**
- * {@inheritDoc}
+ * sets the Extended response payload
+ *
+ * @param responseValue The extended payload
*/
public void setResponseValue( byte[] responseValue )
{
@@ -125,6 +133,7 @@
*
* @return The ExtendedResponse length
*/
+ @Override
public int computeLength()
{
int ldapResultLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -164,6 +173,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
index d204bd0..9e47836 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
@@ -39,6 +39,7 @@
*/
public interface LdapApiService
{
+ /** The default codec factory */
String DEFAULT_PROTOCOL_CODEC_FACTORY =
"org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolCodecFactory";
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiServiceFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiServiceFactory.java
index 587823e..6de8065 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiServiceFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiServiceFactory.java
@@ -46,9 +46,11 @@
private static boolean usingStandaloneImplementation;
+ /**
+ * Private constructor
+ */
private LdapApiServiceFactory()
{
- // TODO Auto-generated constructor stub
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapCodecConstants.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapCodecConstants.java
index 5a7a317..4c47473 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapCodecConstants.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapCodecConstants.java
@@ -27,13 +27,6 @@
*/
public final class LdapCodecConstants
{
- /**
- * Private constructor.
- */
- private LdapCodecConstants()
- {
- }
-
/** The scope constants */
public static final int SCOPE_BASE_OBJECT = 0;
@@ -168,4 +161,12 @@
public static final int APPROX_MATCH_FILTER_TAG = 0xA8;
public static final int EXTENSIBLE_MATCH_FILTER_TAG = 0xA9;
+
+
+ /**
+ * Private constructor.
+ */
+ private LdapCodecConstants()
+ {
+ }
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapDecoder.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapDecoder.java
index 00ae6b3..448f9fb 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapDecoder.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapDecoder.java
@@ -115,87 +115,4 @@
throw new DecoderException( I18n.err( I18n.ERR_04063 ) );
}
}
-
- /**
- * Decode an incoming buffer into LDAP messages. The result can be 0, 1 or many
- * LDAP messages, which will be stored into the array the caller has created.
- *
- * @param buffer The incoming byte buffer
- * @param messageContainer The LdapMessageContainer which will be used to store the
- * message being decoded. If the message is not fully decoded, the ucrrent state
- * is stored into this container
- * @param decodedMessages The list of decoded messages
- * @throws Exception If the decoding failed
- *
- public void decode( ByteBuffer buffer, LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer, List<Message> decodedMessages ) throws DecoderException
- {
- buffer.mark();
-
- while ( buffer.hasRemaining() )
- {
- try
- {
- if ( IS_DEBUG )
- {
- LOG.debug( "Decoding the PDU : " );
-
- int size = buffer.limit();
- int position = buffer.position();
- int pduLength = size - position;
-
- byte[] array = new byte[pduLength];
-
- System.arraycopy(buffer.array(), position, array, 0, pduLength);
-
- buffer.position( size );
-
- if ( array.length == 0 )
- {
- LOG.debug( "NULL buffer, what the HELL ???" );
- }
- else
- {
- LOG.debug( Strings.dumpBytes(array) );
- }
-
- buffer.reset();
- }
-
- asn1Decoder.decode( buffer, messageContainer );
-
- if ( messageContainer.getState() == TLVStateEnum.PDU_DECODED )
- {
- if ( IS_DEBUG )
- {
- LOG.debug( "Decoded LdapMessage : " + messageContainer.getMessage() );
- }
-
- Message message = messageContainer.getMessage();
-
- decodedMessages.add( message );
-
- messageContainer.clean();
- }
- }
- catch ( DecoderException de )
- {
- buffer.clear();
- messageContainer.clean();
-
- if ( de instanceof ResponseCarryingException )
- {
- // Transform the DecoderException message to a MessageException
- ResponseCarryingMessageException rcme = new ResponseCarryingMessageException( de.getMessage() );
- rcme.setResponse( ( ( ResponseCarryingException ) de ).getResponse() );
-
- throw rcme;
- }
- else
- {
- // TODO : This is certainly not the way we should handle such an exception !
- throw new ResponseCarryingException( de.getMessage() );
- }
- }
- }
- }*/
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
index df5c0a5..abfde1f 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
@@ -211,9 +211,7 @@
}
catch ( EncoderException ee )
{
- MessageEncoderException exception = new MessageEncoderException( message.getMessageId(), ee.getMessage(), ee );
-
- throw exception;
+ throw new MessageEncoderException( message.getMessageId(), ee.getMessage(), ee );
}
buffer.flip();
@@ -312,7 +310,7 @@
{
Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes();
- if ( ( ldapUrlsBytes != null ) && ( ldapUrlsBytes.size() != 0 ) )
+ if ( ( ldapUrlsBytes != null ) && ( !ldapUrlsBytes.isEmpty() ) )
{
// Encode the referrals sequence
// The referrals length MUST have been computed before !
@@ -340,7 +338,7 @@
{
Collection<String> ldapUrls = referral.getLdapUrls();
- if ( ( ldapUrls != null ) && ( ldapUrls.size() != 0 ) )
+ if ( ( ldapUrls != null ) && ( !ldapUrls.isEmpty() ) )
{
int referralLength = 0;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
index 471e134..e1034ee 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapMessageContainer.java
@@ -32,6 +32,8 @@
* When dealing with an encoding PDU, we will obtain a LdapMessage in the
* container.
*
+ * @param <E> The decorated message
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LdapMessageContainer<E extends MessageDecorator<? extends Message>> extends AbstractContainer
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageDecorator.java
index f393963..6665078 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageDecorator.java
@@ -72,7 +72,8 @@
/**
* A decorator for the generic LDAP Message
*
- * TODO make this class abstract, after finishing switch and all types and make default blow an EncoderException
+ * @param <E> The message to decorate
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class MessageDecorator<E extends Message> implements Message, Decorator<E>, Asn1Object
@@ -96,6 +97,26 @@
private final LdapApiService codec;
+ /**
+ * Makes a Message an Decorator object.
+ *
+ * @param codec The LDAP Service instance to use
+ * @param decoratedMessage The message to decorate
+ */
+ protected MessageDecorator( LdapApiService codec, E decoratedMessage )
+ {
+ this.codec = codec;
+ this.decoratedMessage = decoratedMessage;
+ controls = new HashMap<>();
+ }
+
+
+ /**
+ * Return the decorator for a given message
+ * @param codec The LdapApiService instance
+ * @param decoratedMessage The decorated message
+ * @return The decorator
+ */
public static MessageDecorator<? extends Message> getDecorator( LdapApiService codec, Message decoratedMessage )
{
if ( decoratedMessage instanceof MessageDecorator )
@@ -103,7 +124,7 @@
return ( MessageDecorator<?> ) decoratedMessage;
}
- MessageDecorator<?> decorator = null;
+ MessageDecorator<?> decorator;
switch ( decoratedMessage.getType() )
{
@@ -210,20 +231,6 @@
/**
- * Makes a Message an Decorator object.
- *
- * @param codec The LDAP Service instance to use
- * @param decoratedMessage The message to decorate
- */
- protected MessageDecorator( LdapApiService codec, E decoratedMessage )
- {
- this.codec = codec;
- this.decoratedMessage = decoratedMessage;
- controls = new HashMap<String, Control>();
- }
-
-
- /**
* @param controlsLength the encoded controls length
*/
public void setControlsLength( int controlsLength )
@@ -273,10 +280,10 @@
//-------------------------------------------------------------------------
// The Message methods
//-------------------------------------------------------------------------
-
/**
* {@inheritDoc}
*/
+ @Override
public MessageTypeEnum getType()
{
return decoratedMessage.getType();
@@ -286,6 +293,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, Control> getControls()
{
return controls;
@@ -295,6 +303,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Control getControl( String oid )
{
return controls.get( oid );
@@ -304,6 +313,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasControl( String oid )
{
return controls.containsKey( oid );
@@ -314,6 +324,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Message addControl( Control control )
{
Control decorated;
@@ -341,6 +352,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message addAllControls( Control[] controls )
{
for ( Control control : controls )
@@ -355,6 +367,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message removeControl( Control control )
{
decoratedMessage.removeControl( control );
@@ -367,6 +380,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getMessageId()
{
return decoratedMessage.getMessageId();
@@ -376,6 +390,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object get( Object key )
{
return decoratedMessage.get( key );
@@ -385,6 +400,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object put( Object key, Object value )
{
return decoratedMessage.put( key, value );
@@ -394,6 +410,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message setMessageId( int messageId )
{
decoratedMessage.setMessageId( messageId );
@@ -405,6 +422,7 @@
/**
* Delegates to the toString() method of the decorated Message.
*/
+ @Override
public String toString()
{
return decoratedMessage.toString();
@@ -414,6 +432,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E getDecorated()
{
return decoratedMessage;
@@ -423,6 +442,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapApiService getCodecService()
{
return codec;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageEncoderException.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageEncoderException.java
index 497fe51..21b9ad2 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageEncoderException.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/MessageEncoderException.java
@@ -34,7 +34,7 @@
private static final long serialVersionUID = -4634398228257729537L;
/** The message ID */
- private int messageId;
+ private final int messageId;
/**
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/SchemaBinaryAttributeDetector.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/SchemaBinaryAttributeDetector.java
index f47cd47..7314dd3 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/SchemaBinaryAttributeDetector.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/SchemaBinaryAttributeDetector.java
@@ -41,6 +41,11 @@
}
+ /**
+ * Create an instance of SchemaBinaryAttributeDetector.
+ *
+ * @param schemaManager The SchemaManager to use
+ */
public SchemaBinaryAttributeDetector( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
@@ -58,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isBinary( String attributeId )
{
String attrId = Strings.toLowerCaseAscii( attributeId );
@@ -78,7 +84,7 @@
LdapSyntax ldapSyntax = attributeType.getSyntax();
- return ( ( ldapSyntax != null ) && !ldapSyntax.isHumanReadable() );
+ return ( ldapSyntax != null ) && !ldapSyntax.isHumanReadable();
}
return false;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeDecorator.java
index cf82139..46803b2 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeDecorator.java
@@ -53,12 +53,17 @@
/**
* @return the control length.
*/
+ @Override
public int computeLength()
{
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
return this;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeFactory.java
index 3d894d2..c89f4c7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/cascade/CascadeFactory.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return Cascade.OID;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<Cascade> newCodecControl()
{
return new CascadeDecorator( codec, new CascadeImpl() );
@@ -71,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<Cascade> newCodecControl( Cascade control )
{
return new CascadeDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITDecorator.java
index 4e05910..7aaabd0 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITDecorator.java
@@ -53,12 +53,17 @@
/**
* @return 0 every time.
*/
+ @Override
public int computeLength()
{
return 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
return this;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
index c3ab18e..6c840cd 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return ManageDsaIT.OID;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ManageDsaIT> newCodecControl()
{
return new ManageDsaITDecorator( codec, new ManageDsaITImpl() );
@@ -71,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ManageDsaIT> newCodecControl( ManageDsaIT control )
{
return new ManageDsaITDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzDecorator.java
index 7d6c13d..2a5f3e8 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzDecorator.java
@@ -79,7 +79,7 @@
*/
private ProxiedAuthz getProxiedAuthz()
{
- return ( ProxiedAuthz ) getDecorated();
+ return getDecorated();
}
@@ -91,6 +91,7 @@
*
* @return the control length.
*/
+ @Override
public int computeLength()
{
int valueLength = 0;
@@ -112,6 +113,7 @@
* @return A ByteBuffer that contains the encoded PDU
* @throws EncoderException If anything goes wrong.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -131,6 +133,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
@@ -164,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getAuthzId()
{
return getProxiedAuthz().getAuthzId();
@@ -173,6 +177,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setAuthzId( String authzId )
{
getProxiedAuthz().setAuthzId( authzId );
@@ -182,6 +187,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
getProxiedAuthz().setAuthzId( Strings.utf8ToString( controlBytes ) );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzFactory.java
index 89b87ba..2c4fc29 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return ProxiedAuthz.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ProxiedAuthz> newCodecControl()
{
return new ProxiedAuthzDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ProxiedAuthz> newCodecControl( ProxiedAuthz control )
{
return new ProxiedAuthzDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeContainer.java
index 8d4b5ce..e5468fb 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeContainer.java
@@ -112,6 +112,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeDecorator.java
index aa1c38f..beb3477 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeDecorator.java
@@ -48,7 +48,7 @@
*/
public class EntryChangeDecorator extends ControlDecorator<EntryChange> implements EntryChange
{
-
+ /** Default value when no change number is provided */
public static final int UNDEFINED_CHANGE_NUMBER = -1;
/** A temporary storage for the previous Dn */
@@ -93,7 +93,7 @@
*/
private EntryChange getEntryChange()
{
- return ( EntryChange ) getDecorated();
+ return getDecorated();
}
@@ -110,6 +110,7 @@
*
* @return the control length.
*/
+ @Override
public int computeLength()
{
int changeTypesLength = 1 + 1 + 1;
@@ -142,6 +143,7 @@
* @return A ByteBuffer that contains the encoded PDU
* @throws EncoderException If anything goes wrong.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -173,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
@@ -214,6 +217,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ChangeType getChangeType()
{
return getEntryChange().getChangeType();
@@ -223,6 +227,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setChangeType( ChangeType changeType )
{
getEntryChange().setChangeType( changeType );
@@ -232,6 +237,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getPreviousDn()
{
return getEntryChange().getPreviousDn();
@@ -241,6 +247,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setPreviousDn( Dn previousDn )
{
getEntryChange().setPreviousDn( previousDn );
@@ -250,6 +257,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public long getChangeNumber()
{
return getEntryChange().getChangeNumber();
@@ -259,6 +267,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setChangeNumber( long changeNumber )
{
getEntryChange().setChangeNumber( changeNumber );
@@ -268,6 +277,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
index 7b80f17..c2ccc54 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return EntryChange.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<EntryChange> newCodecControl()
{
return new EntryChangeDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<EntryChange> newCodecControl( EntryChange control )
{
return new EntryChangeDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeStates.java
index b5f54d0..ab951f9 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.search.entryChange;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -72,23 +71,6 @@
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof EntryChangeGrammar )
- {
- return "EC_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -96,13 +78,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "EC_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "EC_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -112,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public EntryChangeStates getStartState()
{
return START_STATE;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsContainer.java
index b9cff9a..5b4ccdc 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsContainer.java
@@ -77,6 +77,11 @@
}
+ /**
+ * Decorate the PageResult control
+ *
+ * @param control The PageResult control instance
+ */
public void decorate( PagedResults control )
{
if ( control instanceof PagedResultsDecorator )
@@ -105,6 +110,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsDecorator.java
index d30a33c..d20a419 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsDecorator.java
@@ -92,6 +92,7 @@
*
* @return the control length.
*/
+ @Override
public int computeLength()
{
int sizeLength = 1 + 1 + BerValue.getNbBytes( getSize() );
@@ -121,6 +122,7 @@
* @return A ByteBuffer that contains the encoded PDU
* @throws EncoderException If anything goes wrong.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -142,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
@@ -173,6 +176,7 @@
/**
* @return The requested or returned number of entries
*/
+ @Override
public int getSize()
{
return getDecorated().getSize();
@@ -184,6 +188,7 @@
*
* @param size The number of entries
*/
+ @Override
public void setSize( int size )
{
getDecorated().setSize( size );
@@ -193,6 +198,7 @@
/**
* @return The stored cookie
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -204,6 +210,7 @@
*
* @param cookie The cookie to store in this control
*/
+ @Override
public void setCookie( byte[] cookie )
{
// Copy the bytes
@@ -223,6 +230,7 @@
/**
* @return The integer value for the current cookie
*/
+ @Override
public int getCookieValue()
{
int value = 0;
@@ -290,9 +298,10 @@
/**
* Return a String representing this PagedSearchControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Paged Search Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
@@ -307,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
index 41016e1..4837847 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PagedResults.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PagedResults> newCodecControl()
{
return new PagedResultsDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PagedResults> newCodecControl( PagedResults control )
{
return new PagedResultsDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsGrammar.java
index b8f39e2..545dbf2 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsGrammar.java
@@ -30,7 +30,7 @@
import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -150,7 +150,7 @@
if ( container.getCurrentTLV().getLength() == 0 )
{
- container.getDecorator().setCookie( StringConstants.EMPTY_BYTES );
+ container.getDecorator().setCookie( Strings.EMPTY_BYTES );
}
else
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsStates.java
index 2d49c32..64f484c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedResultsStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.search.pagedSearch;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -59,33 +58,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "PAGED_SEARCH_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof PagedResultsGrammar )
- {
- return "PAGEDSEARCH_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -93,13 +74,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "PAGED_SEARCH_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "PAGED_SEARCH_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -109,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PagedResultsStates getStartState()
{
return START_STATE;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchContainer.java
index 2aebc61..1943af5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchContainer.java
@@ -110,6 +110,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchDecorator.java
index 0149d4b..ebd448d 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchDecorator.java
@@ -92,6 +92,7 @@
*
* @return the control length.
*/
+ @Override
public int computeLength()
{
int changeTypesLength = 1 + 1 + BerValue.getNbBytes( getChangeTypes() );
@@ -99,9 +100,8 @@
int returnRCsLength = 1 + 1 + 1;
psearchSeqLength = changeTypesLength + changesOnlyLength + returnRCsLength;
- int valueLength = 1 + TLV.getNbBytes( psearchSeqLength ) + psearchSeqLength;
-
- return valueLength;
+
+ return 1 + TLV.getNbBytes( psearchSeqLength ) + psearchSeqLength;
}
@@ -112,6 +112,7 @@
* @return A ByteBuffer that contains the encoded PDU
* @throws EncoderException If anything goes wrong.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -134,13 +135,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
{
try
{
- computeLength();
+ valueLength = computeLength();
ByteBuffer buffer = ByteBuffer.allocate( valueLength );
// Now encode the PagedSearch specific part
@@ -153,7 +155,7 @@
value = buffer.array();
}
- catch ( Exception e )
+ catch ( EncoderException ee )
{
return null;
}
@@ -165,52 +167,84 @@
private PersistentSearch getPersistentSearch()
{
- return ( PersistentSearch ) getDecorated();
+ return getDecorated();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangesOnly( boolean changesOnly )
{
getPersistentSearch().setChangesOnly( changesOnly );
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isChangesOnly()
{
return getPersistentSearch().isChangesOnly();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setReturnECs( boolean returnECs )
{
getPersistentSearch().setReturnECs( returnECs );
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isReturnECs()
{
return getPersistentSearch().isReturnECs();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangeTypes( int changeTypes )
{
getPersistentSearch().setChangeTypes( changeTypes );
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public int getChangeTypes()
{
return getPersistentSearch().getChangeTypes();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isNotificationEnabled( ChangeType changeType )
{
return getPersistentSearch().isNotificationEnabled( changeType );
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void enableNotification( ChangeType changeType )
{
getPersistentSearch().enableNotification( changeType );
@@ -220,6 +254,17 @@
/**
* {@inheritDoc}
*/
+ @Override
+ public void disableNotification( ChangeType changeType )
+ {
+ getPersistentSearch().disableNotification( changeType );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
index 66abe64..089104c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
@@ -27,7 +27,7 @@
/**
- *
+ * A factory to create a PersistentSearch control
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
@@ -37,6 +37,11 @@
private LdapApiService codec;
+ /**
+ * Create a new PersistentSearchFactory instance
+ *
+ * @param codec The LdapApiService instance
+ */
public PersistentSearchFactory( LdapApiService codec )
{
this.codec = codec;
@@ -46,6 +51,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PersistentSearch.OID;
@@ -55,6 +61,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PersistentSearch> newCodecControl()
{
return new PersistentSearchDecorator( codec );
@@ -64,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PersistentSearch> newCodecControl( PersistentSearch control )
{
return new PersistentSearchDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchStates.java
index 6e9096b..1c52cee 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PersistentSearchStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.search.persistentSearch;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -71,23 +70,6 @@
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof PersistentSearchGrammar )
- {
- return "PSEARCH_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -95,13 +77,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "PSEARCH_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "PSEARCH_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -111,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PersistentSearchStates getStartState()
{
return START_STATE;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesContainer.java
index 64379b4..d290bbf 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesContainer.java
@@ -83,6 +83,7 @@
/**
* Clean the current container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesDecorator.java
index 925ef51..bc2453c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesDecorator.java
@@ -78,6 +78,7 @@
*
* @return the control length.
*/
+ @Override
public int computeLength()
{
return 1 + 1 + 1;
@@ -91,6 +92,7 @@
* @return A ByteBuffer that contains the encoded PDU
* @throws org.apache.directory.api.asn1.EncoderException If anything goes wrong.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -108,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
@@ -132,12 +135,20 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isVisible()
{
return getDecorated().isVisible();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setVisibility( boolean visibility )
{
getDecorated().setVisibility( visibility );
@@ -147,6 +158,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesFactory.java
index 62ace93..18dd584 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesFactory.java
@@ -54,6 +54,7 @@
*
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return Subentries.OID;
@@ -64,6 +65,7 @@
*
* {@inheritDoc}
*/
+ @Override
public CodecControl<Subentries> newCodecControl()
{
return new SubentriesDecorator( codec );
@@ -74,6 +76,7 @@
*
* {@inheritDoc}
*/
+ @Override
public CodecControl<Subentries> newCodecControl( Subentries control )
{
return new SubentriesDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesStates.java
index d4c2d61..6f23ab0 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubentriesStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.search.subentries;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -54,33 +53,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SUB_ENTRY_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<SubentriesContainer> grammar )
- {
- if ( grammar instanceof SubentriesGrammar )
- {
- return "SUB_ENTRY_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -88,13 +69,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SUB_ENTRY_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "SUB_ENTRY_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -104,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SubentriesStates getStartState()
{
return START_STATE;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestContainer.java
index 5744663..edf3632 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestContainer.java
@@ -71,7 +71,9 @@
/**
- * {@inheritDoc}
+ * Decorate a SortRequest control
+ *
+ * @param control The control to decorate
*/
public void decorate( SortRequest control )
{
@@ -107,6 +109,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestDecorator.java
index 8fcf9cd..4ab89c1 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestDecorator.java
@@ -52,10 +52,12 @@
private int sortReqLen = 0;
- private List<Integer> sortKeyLenList = new ArrayList<Integer>();
+ private List<Integer> sortKeyLenList = new ArrayList<>();
+ /** ASN.1 BER tag for the forward ordering rule */
public static final int ORDERING_RULE_TAG = 0x80;
+ /** ASN.1 BER tag for the backward ordering rule */
public static final int REVERSE_ORDER_TAG = 0x81;
@@ -181,6 +183,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestFactory.java
index 408de4f..980bbd3 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SortRequest.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SortRequest> newCodecControl()
{
return new SortRequestDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SortRequest> newCodecControl( SortRequest control )
{
return new SortRequestDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
index 7d60d43..1a438ef 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
@@ -39,7 +39,14 @@
/**
- * Grammar used for decoding a SortRequestControl.
+ * Grammar used for decoding a SortRequestControl. It's defined in https://tools.ietf.org/html/rfc2891
+ *
+ * <pre>
+ * SortKeyList ::= SEQUENCE OF SEQUENCE {
+ * attributeType AttributeDescription,
+ * orderingRule [0] MatchingRuleId OPTIONAL,
+ * reverseOrder [1] BOOLEAN DEFAULT FALSE }
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -105,8 +112,6 @@
}
catch ( BooleanDecoderException bde )
{
- //String msg = I18n.err( I18n.ERR_04050 );
- //LOG.error( msg, e );
throw new DecoderException( bde.getMessage(), bde );
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestStates.java
index 088d6f5..98705e7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.sort;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -31,50 +30,39 @@
*/
public enum SortRequestStates implements States
{
+ /** Initial state */
START_STATE,
+ /** SortKeyList ::= SEQUENCE OF transition */
SEQUENCE_OF_SEQUENCE_STATE,
+ /** SortKeyList ::= SEQUENCE OF SEQUENCE transition */
SORT_KEY_SEQUENCE_STATE,
+ /** attributeType AttributeDescription transition */
AT_DESC_STATE,
+ /** orderingRule [0] MatchingRuleId OPTIONAL transition */
ORDER_RULE_STATE,
+ /** reverseOrder [1] BOOLEAN DEFAULT FALSE transition */
REVERSE_ORDER_STATE,
+ /** Final state */
END_STATE;
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SORT_REQUEST_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof SortRequestGrammar )
- {
- return "SORT_REQUEST_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -82,21 +70,26 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isEndState()
{
- return ( this == END_STATE );
+ return this == END_STATE;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Enum<?> getStartState()
{
return START_STATE;
}
-
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseContainer.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseContainer.java
index 80014d2..14e8406 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseContainer.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseContainer.java
@@ -67,7 +67,9 @@
/**
- * {@inheritDoc}
+ * Decorate the SortResponse control
+ *
+ * @param control The Sort Response control to decorate
*/
public void decorate( SortResponse control )
{
@@ -103,10 +105,10 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
control = null;
}
-
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseDecorator.java
index 9e97575..408c6c1 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseDecorator.java
@@ -135,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseFactory.java
index 9e4146d..fcd2c3c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SortResponse.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SortResponse> newCodecControl()
{
return new SortResponseDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SortResponse> newCodecControl( SortResponse control )
{
return new SortResponseDecorator( codec, control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
index 23121a0..e4891dd 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
@@ -33,7 +33,33 @@
/**
- * Grammar for decoding SortResponseControl.
+ * Grammar for decoding SortResponseControl. It's defined in https://tools.ietf.org/html/rfc2891
+ *
+ * <pre>
+ * SortResult ::= SEQUENCE {
+ * sortResult ENUMERATED {
+ * success (0), -- results are sorted
+ * operationsError (1), -- server internal failure
+ * timeLimitExceeded (3), -- timelimit reached before
+ * -- sorting was completed
+ * strongAuthRequired (8), -- refused to return sorted
+ * -- results via insecure
+ * -- protocol
+ * adminLimitExceeded (11), -- too many matching entries
+ $ -- for the server to sort
+ * noSuchAttribute (16), -- unrecognized attribute
+ * -- type in sort key
+ * inappropriateMatching (18), -- unrecognized or
+ * -- inappropriate matching
+ * -- rule in sort key
+ * insufficientAccessRights (50), -- refused to return sorted
+ * -- results to this client
+ * busy (51), -- too busy to process
+ * unwillingToPerform (53), -- unable to sort
+ * other (80)
+ * },
+ * attributeType [0] AttributeDescription OPTIONAL }
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseStates.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseStates.java
index fa9155f..9e3b354 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseStates.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseStates.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.codec.controls.sort;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -31,46 +30,33 @@
*/
public enum SortResponseStates implements States
{
+ /** Initialstate */
START_STATE,
+ /** SortResult ::= SEQUENCE transition */
SEQUENCE_STATE,
+ /** sortResult ENUMERATED transition */
RESULT_CODE_STATE,
+ /** attributeType [0] AttributeDescription OPTIONAL transition */
AT_DESC_STATE,
+ /** Final state */
END_STATE;
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SORT_RESPONSE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof SortResponseGrammar )
- {
- return "SORT_RESPONSE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -78,14 +64,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name();
}
@Override
public boolean isEndState()
{
- return ( this == END_STATE );
+ return this == END_STATE;
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/StoreSortResponseResultCode.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/StoreSortResponseResultCode.java
index 2985ef7..956e4df 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/StoreSortResponseResultCode.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/StoreSortResponseResultCode.java
@@ -28,6 +28,8 @@
/**
* The action used to store the result code of a SortResponseControl
*
+ * @param <C> The Asn1Container type to use
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class StoreSortResponseResultCode<C extends Asn1Container> extends AbstractReadInteger<C>
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonRequestDecorator.java
index 55263d1..bcb91f5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonRequestDecorator.java
@@ -58,6 +58,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getAbandoned()
{
return getDecorated().getAbandoned();
@@ -67,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest setAbandoned( int requestId )
{
getDecorated().setAbandoned( requestId );
@@ -78,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -89,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest addControl( Control control )
{
return ( AbandonRequest ) super.addControl( control );
@@ -98,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest addAllControls( Control[] controls )
{
return ( AbandonRequest ) super.addAllControls( controls );
@@ -107,6 +112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest removeControl( Control control )
{
return ( AbandonRequest ) super.removeControl( control );
@@ -120,6 +126,7 @@
/**
* Encode the Abandon protocolOp part
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
@@ -154,10 +161,9 @@
* Length(AbandonRequest) = Length(0x50) + 1 + Length(abandoned MessageId)
* </pre>
*/
+ @Override
public int computeLength()
{
- int length = 1 + 1 + BerValue.getNbBytes( getAbandoned() );
-
- return length;
+ return 1 + 1 + BerValue.getNbBytes( getAbandoned() );
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableRequestDecorator.java
index e6fa4fd..21f6194 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableRequestDecorator.java
@@ -27,6 +27,8 @@
/**
* A decorator for the LdapResultResponse message
+ *
+ * @param <M> The Request to decorate
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -60,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void abandon()
{
getAbandonableRequest().abandon();
@@ -69,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAbandoned()
{
return getAbandonableRequest().isAbandoned();
@@ -78,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonableRequest addAbandonListener( AbandonListener listener )
{
getAbandonableRequest().addAbandonListener( listener );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableResultResponseRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableResultResponseRequestDecorator.java
index 032d692..6dbe8c1 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableResultResponseRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AbandonableResultResponseRequestDecorator.java
@@ -27,6 +27,8 @@
/**
* A decorator for the LdapResultResponse message
+ *
+ * @param <M> The message response to decorate
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -48,6 +50,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasResponse()
{
return getDecorated().hasResponse();
@@ -57,6 +60,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ResultResponse getResultResponse()
{
return getDecorated().getResultResponse();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
index 10f4fc9..e3f26e7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
@@ -88,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -99,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest addControl( Control control )
{
return ( AddRequest ) super.addControl( control );
@@ -108,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest addAllControls( Control[] controls )
{
return ( AddRequest ) super.addAllControls( controls );
@@ -117,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest removeControl( Control control )
{
return ( AddRequest ) super.removeControl( control );
@@ -130,6 +134,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getEntryDn()
{
return getDecorated().getEntryDn();
@@ -139,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setEntryDn( Dn entry )
{
getDecorated().setEntryDn( entry );
@@ -150,6 +156,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getEntry()
{
return getDecorated().getEntry();
@@ -159,6 +166,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setEntry( Entry entry )
{
getDecorated().setEntry( entry );
@@ -276,6 +284,7 @@
* +--> 0x04 L7-m-n value
* </pre>
*/
+ @Override
public int computeLength()
{
AddRequest addRequest = getDecorated();
@@ -297,15 +306,15 @@
if ( entry.size() != 0 )
{
- attributesLength = new LinkedList<Integer>();
- attributeIds = new LinkedList<byte[]>();
- valuesLength = new LinkedList<Integer>();
+ attributesLength = new LinkedList<>();
+ attributeIds = new LinkedList<>();
+ valuesLength = new LinkedList<>();
// Compute the attributes length
for ( Attribute attribute : entry )
{
- int localAttributeLength = 0;
- int localValuesLength = 0;
+ int localAttributeLength;
+ int localValuesLength;
// Get the type length
byte[] attributeIdBytes = Strings.getBytesUtf8( attribute.getUpId() );
@@ -381,6 +390,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
@@ -431,7 +441,7 @@
BerValue.encode( buffer, Strings.EMPTY_BYTES );
}
- // Go to the next attribute number;
+ // Go to the next attribute number
attributeNumber++;
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddResponseDecorator.java
index c53ca7c..c34d1ba 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddResponseDecorator.java
@@ -59,7 +59,7 @@
*/
public AddResponse getAddResponse()
{
- return ( AddResponse ) getDecorated();
+ return getDecorated();
}
@@ -80,6 +80,7 @@
* Length(AddResponse) = Length(0x69) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
AddResponse addResponse = getAddResponse();
@@ -97,6 +98,7 @@
* @return The encoded response
* @throws EncoderException If teh encoding failed
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindRequestDecorator.java
index d323321..f758b1a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindRequestDecorator.java
@@ -76,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -87,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest addControl( Control control )
{
return ( BindRequest ) super.addControl( control );
@@ -96,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest addAllControls( Control[] controls )
{
return ( BindRequest ) super.addAllControls( controls );
@@ -105,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest removeControl( Control control )
{
return ( BindRequest ) super.removeControl( control );
@@ -118,6 +122,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSimple()
{
return getDecorated().isSimple();
@@ -127,6 +132,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getSimple()
{
return getDecorated().getSimple();
@@ -136,6 +142,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setSimple( boolean isSimple )
{
getDecorated().setSimple( isSimple );
@@ -147,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCredentials()
{
return getDecorated().getCredentials();
@@ -156,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setCredentials( String credentials )
{
getDecorated().setCredentials( credentials );
@@ -167,6 +176,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setCredentials( byte[] credentials )
{
getDecorated().setCredentials( credentials );
@@ -178,6 +188,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getName()
{
return getDecorated().getName();
@@ -187,6 +198,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setName( String name )
{
getDecorated().setName( name );
@@ -198,6 +210,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getDn()
{
return getDecorated().getDn();
@@ -207,6 +220,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setDn( Dn dn )
{
getDecorated().setDn( dn );
@@ -218,6 +232,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isVersion3()
{
return getDecorated().isVersion3();
@@ -227,6 +242,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getVersion3()
{
return getDecorated().getVersion3();
@@ -236,6 +252,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setVersion3( boolean isVersion3 )
{
getDecorated().setVersion3( isVersion3 );
@@ -247,6 +264,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSaslMechanism()
{
return getDecorated().getSaslMechanism();
@@ -256,6 +274,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setSaslMechanism( String saslMechanism )
{
getDecorated().setSaslMechanism( saslMechanism );
@@ -284,6 +303,7 @@
* Length(0x04) + Length(L2) + L2 + Length(authentication)
* </pre>
*/
+ @Override
public int computeLength()
{
// Initialized with version
@@ -365,6 +385,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindResponseDecorator.java
index 55a3709..32210f8 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/BindResponseDecorator.java
@@ -61,6 +61,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getServerSaslCreds()
{
return getDecorated().getServerSaslCreds();
@@ -70,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setServerSaslCreds( byte[] serverSaslCreds )
{
getDecorated().setServerSaslCreds( serverSaslCreds );
@@ -93,6 +95,7 @@
* Length(BindResponse) = Length(0x61) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
BindResponse bindResponse = getDecorated();
@@ -124,6 +127,7 @@
* @return The encoded response
* @throws EncoderException when encoding operations fail
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
BindResponse bindResponse = getDecorated();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareRequestDecorator.java
index 6fd13d7..0e2e5d9 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareRequestDecorator.java
@@ -78,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return getDecorated().getName();
@@ -87,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setName( Dn name )
{
getDecorated().setName( name );
@@ -98,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> getAssertionValue()
{
return getDecorated().getAssertionValue();
@@ -107,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAssertionValue( String value )
{
getDecorated().setAssertionValue( value );
@@ -118,6 +122,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAssertionValue( byte[] value )
{
getDecorated().setAssertionValue( value );
@@ -129,6 +134,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getAttributeId()
{
return getDecorated().getAttributeId();
@@ -138,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAttributeId( String attrId )
{
getDecorated().setAttributeId( attrId );
@@ -149,6 +156,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -160,6 +168,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest addControl( Control control )
{
return ( CompareRequest ) super.addControl( control );
@@ -169,6 +178,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest addAllControls( Control[] controls )
{
return ( CompareRequest ) super.addAllControls( controls );
@@ -178,6 +188,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest removeControl( Control control )
{
return ( CompareRequest ) super.removeControl( control );
@@ -208,6 +219,7 @@
*
* @return The CompareRequest PDU's length
*/
+ @Override
public int computeLength()
{
// The entry Dn
@@ -250,6 +262,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareResponseDecorator.java
index f488c96..bd672a7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/CompareResponseDecorator.java
@@ -62,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isTrue()
{
return getDecorated().isTrue();
@@ -86,6 +87,7 @@
* Length(CompareResponse) = Length(0x6F) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
compareResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -99,8 +101,8 @@
*
* @param buffer The buffer where to put the PDU
*/
- public ByteBuffer encode( ByteBuffer buffer )
- throws EncoderException
+ @Override
+ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteRequestDecorator.java
index 16092b3..6679995 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteRequestDecorator.java
@@ -65,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return getDecorated().getName();
@@ -74,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest setName( Dn name )
{
getDecorated().setName( name );
@@ -85,6 +87,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -96,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest addControl( Control control )
{
return ( DeleteRequest ) super.addControl( control );
@@ -105,6 +109,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest addAllControls( Control[] controls )
{
return ( DeleteRequest ) super.addAllControls( controls );
@@ -114,6 +119,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest removeControl( Control control )
{
return ( DeleteRequest ) super.removeControl( control );
@@ -134,6 +140,7 @@
* Length(DelRequest) = Length(0x4A) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
dnBytes = Strings.getBytesUtf8( getName().getName() );
@@ -154,6 +161,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteResponseDecorator.java
index 8e0b109..7e65b49 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/DeleteResponseDecorator.java
@@ -73,6 +73,7 @@
* Length(DelResponse) = Length(0x6B) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
deleteResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -86,6 +87,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/IntermediateResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/IntermediateResponseDecorator.java
index ce155c5..b303d25 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/IntermediateResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/IntermediateResponseDecorator.java
@@ -70,6 +70,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getResponseName()
{
return getDecorated().getResponseName();
@@ -79,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setResponseName( String oid )
{
getDecorated().setResponseName( oid );
@@ -88,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getResponseValue()
{
return getDecorated().getResponseValue();
@@ -97,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setResponseValue( byte[] value )
{
getDecorated().setResponseValue( value );
@@ -124,6 +128,7 @@
*
* @return The IntermediateResponse length
*/
+ @Override
public int computeLength()
{
intermediateResponseLength = 0;
@@ -159,6 +164,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/LdapResultDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/LdapResultDecorator.java
index c7dac3f..935b341 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/LdapResultDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/LdapResultDecorator.java
@@ -80,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ResultCodeEnum getResultCode()
{
return decoratedLdapResult.getResultCode();
@@ -89,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setResultCode( ResultCodeEnum resultCode )
{
decoratedLdapResult.setResultCode( resultCode );
@@ -98,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getMatchedDn()
{
return decoratedLdapResult.getMatchedDn();
@@ -107,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMatchedDn( Dn dn )
{
decoratedLdapResult.setMatchedDn( dn );
@@ -116,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getDiagnosticMessage()
{
return decoratedLdapResult.getDiagnosticMessage();
@@ -125,6 +130,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDiagnosticMessage( String diagnosticMessage )
{
decoratedLdapResult.setDiagnosticMessage( diagnosticMessage );
@@ -134,6 +140,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReferral()
{
return decoratedLdapResult.isReferral();
@@ -143,6 +150,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Referral getReferral()
{
return decoratedLdapResult.getReferral();
@@ -152,6 +160,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReferral( Referral referral )
{
decoratedLdapResult.setReferral( referral );
@@ -161,6 +170,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return decoratedLdapResult.toString();
@@ -196,6 +206,7 @@
* Length(L2) + L2 + Length(0x83) + Length(L3) + L3
* </pre>
*/
+ @Override
public int computeLength()
{
if ( decoratedLdapResult.isDefaultSuccess() )
@@ -204,7 +215,7 @@
return DEFAULT_SUCCESS.length;
}
- int ldapResultLength = 0;
+ int ldapResultLength;
// The result code
ldapResultLength = 1 + 1 + BerValue.getNbBytes( getResultCode().getValue() );
@@ -242,6 +253,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -288,6 +300,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapResult getDecorated()
{
return decoratedLdapResult;
@@ -297,6 +310,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapApiService getCodecService()
{
return codec;
@@ -306,6 +320,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDefaultSuccess()
{
return decoratedLdapResult.isDefaultSuccess();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnRequestDecorator.java
index 5482aa1..3765ea9 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnRequestDecorator.java
@@ -67,6 +67,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return getDecorated().getName();
@@ -76,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setName( Dn name )
{
getDecorated().setName( name );
@@ -87,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Rdn getNewRdn()
{
return getDecorated().getNewRdn();
@@ -96,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
getDecorated().setNewRdn( newRdn );
@@ -107,6 +111,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getDeleteOldRdn()
{
return getDecorated().getDeleteOldRdn();
@@ -116,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setDeleteOldRdn( boolean deleteOldRdn )
{
getDecorated().setDeleteOldRdn( deleteOldRdn );
@@ -127,6 +133,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getNewSuperior()
{
return getDecorated().getNewSuperior();
@@ -136,6 +143,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setNewSuperior( Dn newSuperior )
{
getDecorated().setNewSuperior( newSuperior );
@@ -147,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isMove()
{
return getDecorated().isMove();
@@ -156,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -167,6 +177,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest addControl( Control control )
{
return ( ModifyDnRequest ) super.addControl( control );
@@ -176,6 +187,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest addAllControls( Control[] controls )
{
return ( ModifyDnRequest ) super.addAllControls( controls );
@@ -185,6 +197,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest removeControl( Control control )
{
return ( ModifyDnRequest ) super.removeControl( control );
@@ -217,6 +230,7 @@
*
* @return The PDU's length of a ModifyDN Request
*/
+ @Override
public int computeLength()
{
int newRdnlength = Strings.getBytesUtf8( getNewRdn().getName() ).length;
@@ -251,6 +265,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnResponseDecorator.java
index 59f4376..d524a49 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyDnResponseDecorator.java
@@ -71,6 +71,7 @@
* Length(ModifyDNResponse) = Length(0x6D) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
modifyDnResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -84,6 +85,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
index b545ab7..6a6e34f 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
@@ -152,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return getDecorated().getName();
@@ -161,6 +162,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest setName( Dn name )
{
getDecorated().setName( name );
@@ -172,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<Modification> getModifications()
{
return getDecorated().getModifications();
@@ -181,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addModification( Modification mod )
{
getDecorated().addModification( mod );
@@ -192,6 +196,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest removeModification( Modification mod )
{
getDecorated().removeModification( mod );
@@ -203,6 +208,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( String attributeName, String... attributeValue )
{
getDecorated().remove( attributeName, attributeValue );
@@ -225,6 +231,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( Attribute attr )
{
getDecorated().remove( attr );
@@ -236,6 +243,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( String attributeName )
{
getDecorated().remove( attributeName );
@@ -247,6 +255,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addModification( Attribute attr, ModificationOperation modOp )
{
getDecorated().addModification( attr, modOp );
@@ -258,6 +267,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest add( String attributeName, String... attributeValue )
{
getDecorated().add( attributeName, attributeValue );
@@ -280,6 +290,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest add( Attribute attr )
{
getDecorated().add( attr );
@@ -291,6 +302,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest replace( String attributeName )
{
getDecorated().replace( attributeName );
@@ -302,6 +314,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest replace( String attributeName, String... attributeValue )
{
getDecorated().replace( attributeName, attributeValue );
@@ -324,6 +337,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest replace( Attribute attr )
{
getDecorated().replace( attr );
@@ -335,6 +349,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -346,6 +361,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addControl( Control control )
{
return ( ModifyRequest ) super.addControl( control );
@@ -355,6 +371,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addAllControls( Control[] controls )
{
return ( ModifyRequest ) super.addAllControls( controls );
@@ -364,6 +381,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest removeControl( Control control )
{
return ( ModifyRequest ) super.removeControl( control );
@@ -415,6 +433,7 @@
* +--> 0x04 L8-2-n attributeValue
* </pre>
*/
+ @Override
public int computeLength()
{
// Initialized with name
@@ -426,11 +445,11 @@
Collection<Modification> modifications = getModifications();
- if ( ( modifications != null ) && ( modifications.size() != 0 ) )
+ if ( ( modifications != null ) && ( !modifications.isEmpty() ) )
{
- changeLength = new LinkedList<Integer>();
- modificationLength = new LinkedList<Integer>();
- valuesLength = new LinkedList<Integer>();
+ changeLength = new LinkedList<>();
+ modificationLength = new LinkedList<>();
+ valuesLength = new LinkedList<>();
for ( Modification modification : modifications )
{
@@ -505,6 +524,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
@@ -523,7 +543,7 @@
// The modifications list
Collection<Modification> modifications = getModifications();
- if ( ( modifications != null ) && ( modifications.size() != 0 ) )
+ if ( ( modifications != null ) && ( !modifications.isEmpty() ) )
{
int modificationNumber = 0;
@@ -569,7 +589,7 @@
}
}
- // Go to the next modification number;
+ // Go to the next modification number
modificationNumber++;
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyResponseDecorator.java
index 43a79a8..e9d332e 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyResponseDecorator.java
@@ -72,6 +72,7 @@
* Length(ModifyResponse) = Length(0x67) + Length(L1) + L1
* </pre>
*/
+ @Override
public int computeLength()
{
modifyResponseLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -85,6 +86,7 @@
*
* @param buffer The buffer where to put the PDU
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/RequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/RequestDecorator.java
index 4a866ca..1711096 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/RequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/RequestDecorator.java
@@ -27,9 +27,9 @@
/**
* A decorator for the LdapResultResponse message
+ *
+ * @param <M> The request to decorate
*
- * TODO make this extend AbstractDsmlMessageDecorator instead of codec's
- * MessageDecorator.
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class RequestDecorator<M extends Request> extends MessageDecorator<M> implements Request
@@ -49,6 +49,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasResponse()
{
return ( getDecorated() ).hasResponse();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResponseDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResponseDecorator.java
index de7c487..c73351a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResponseDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResponseDecorator.java
@@ -28,6 +28,8 @@
/**
* A decorator for the Response message. It will store the LdapResult.
+ *
+ * @param <M> The response to be decorated
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -47,13 +49,14 @@
{
super( codec, decoratedMessage );
- ldapResultDecorator = new LdapResultDecorator( codec, ( ( ResultResponse ) decoratedMessage ).getLdapResult() );
+ ldapResultDecorator = new LdapResultDecorator( codec, ( decoratedMessage ).getLdapResult() );
}
/**
* @return the ldapResultDecorator
*/
+ @Override
public LdapResult getLdapResult()
{
return ldapResultDecorator;
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResultResponseRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResultResponseRequestDecorator.java
index 9795cad..1bf397d 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResultResponseRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ResultResponseRequestDecorator.java
@@ -28,6 +28,8 @@
/**
* A decorator for the LdapResultResponse message
*
+ * @param <M> The request to be decorated
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class ResultResponseRequestDecorator<M extends ResultResponseRequest>
@@ -48,6 +50,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasResponse()
{
return getDecorated().hasResponse();
@@ -57,6 +60,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ResultResponse getResultResponse()
{
return getDecorated().getResultResponse();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
index af49905..900818d 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
@@ -126,6 +126,9 @@
}
+ /**
+ * @return The current search filter
+ */
public Filter getCurrentFilter()
{
return currentFilter;
@@ -179,6 +182,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setFilter( ExprNode filter )
{
topFilter = transform( filter );
@@ -190,6 +194,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setFilter( String filter ) throws LdapException
{
getDecorated().setFilter( filter );
@@ -329,7 +334,7 @@
// Transform OR, AND or NOT leaves
if ( filter instanceof ConnectorFilter )
{
- BranchNode branch = null;
+ BranchNode branch;
if ( filter instanceof AndFilter )
{
@@ -339,7 +344,7 @@
{
branch = new OrNode();
}
- else if ( filter instanceof NotFilter )
+ else
{
branch = new NotNode();
}
@@ -415,7 +420,7 @@
if ( substrFilter.getAnySubstrings() != null )
{
- anyString = new ArrayList<String>();
+ anyString = new ArrayList<>();
for ( String any : substrFilter.getAnySubstrings() )
{
@@ -475,7 +480,7 @@
{
filter = new OrFilter();
}
- else if ( exprNode instanceof NotNode )
+ else
{
filter = new NotFilter();
}
@@ -655,7 +660,7 @@
return false;
}
- if ( ( o == null ) || ( o instanceof SearchRequestDecorator ) )
+ if ( !( o instanceof SearchRequestDecorator ) )
{
return false;
}
@@ -707,6 +712,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MessageTypeEnum[] getResponseTypes()
{
return getDecorated().getResponseTypes();
@@ -716,6 +722,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getBase()
{
return getDecorated().getBase();
@@ -725,6 +732,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setBase( Dn baseDn )
{
getDecorated().setBase( baseDn );
@@ -736,6 +744,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchScope getScope()
{
return getDecorated().getScope();
@@ -745,6 +754,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setScope( SearchScope scope )
{
getDecorated().setScope( scope );
@@ -756,6 +766,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AliasDerefMode getDerefAliases()
{
return getDecorated().getDerefAliases();
@@ -765,6 +776,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setDerefAliases( AliasDerefMode aliasDerefAliases )
{
getDecorated().setDerefAliases( aliasDerefAliases );
@@ -776,6 +788,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public long getSizeLimit()
{
return getDecorated().getSizeLimit();
@@ -785,6 +798,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setSizeLimit( long entriesMax )
{
getDecorated().setSizeLimit( entriesMax );
@@ -796,6 +810,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeLimit()
{
return getDecorated().getTimeLimit();
@@ -805,6 +820,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setTimeLimit( int secondsMax )
{
getDecorated().setTimeLimit( secondsMax );
@@ -816,6 +832,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getTypesOnly()
{
return getDecorated().getTypesOnly();
@@ -825,6 +842,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setTypesOnly( boolean typesOnly )
{
getDecorated().setTypesOnly( typesOnly );
@@ -836,6 +854,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExprNode getFilter()
{
return getDecorated().getFilter();
@@ -845,6 +864,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getAttributes()
{
return getDecorated().getAttributes();
@@ -854,6 +874,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addAttributes( String... attributes )
{
getDecorated().addAttributes( attributes );
@@ -865,6 +886,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest removeAttribute( String attribute )
{
getDecorated().removeAttribute( attribute );
@@ -901,6 +923,7 @@
* +--> 0x04 L4-n Attribute description
* </pre>
*/
+ @Override
public int computeLength()
{
searchRequestLength = 0;
@@ -932,7 +955,7 @@
// The attributes description list
attributeDescriptionListLength = 0;
- if ( ( getAttributes() != null ) && ( getAttributes().size() != 0 ) )
+ if ( ( getAttributes() != null ) && ( !getAttributes().isEmpty() ) )
{
// Compute the attributes length
for ( String attribute : getAttributes() )
@@ -972,6 +995,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
@@ -1005,7 +1029,7 @@
buffer.put( UniversalTag.SEQUENCE.getValue() );
buffer.put( TLV.getBytes( attributeDescriptionListLength ) );
- if ( ( getAttributes() != null ) && ( getAttributes().size() != 0 ) )
+ if ( ( getAttributes() != null ) && ( !getAttributes().isEmpty() ) )
{
// encode each attribute
for ( String attribute : getAttributes() )
@@ -1023,30 +1047,50 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public SearchResultDone getResultResponse()
{
return ( SearchResultDone ) getDecorated().getResultResponse();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean hasResponse()
{
return getDecorated().hasResponse();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void abandon()
{
getDecorated().abandon();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isAbandoned()
{
return getDecorated().isAbandoned();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public SearchRequest addAbandonListener( AbandonListener listener )
{
getDecorated().addAbandonListener( listener );
@@ -1058,6 +1102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setMessageId( int messageId )
{
return ( SearchRequest ) super.setMessageId( messageId );
@@ -1067,6 +1112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addControl( Control control )
{
return ( SearchRequest ) super.addControl( control );
@@ -1076,6 +1122,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addAllControls( Control[] controls )
{
return ( SearchRequest ) super.addAllControls( controls );
@@ -1085,6 +1132,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest removeControl( Control control )
{
return ( SearchRequest ) super.removeControl( control );
@@ -1094,6 +1142,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isFollowReferrals()
{
return getDecorated().isFollowReferrals();
@@ -1103,6 +1152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest followReferrals()
{
return getDecorated().followReferrals();
@@ -1112,6 +1162,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isIgnoreReferrals()
{
return getDecorated().isIgnoreReferrals();
@@ -1121,6 +1172,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest ignoreReferrals()
{
return getDecorated().ignoreReferrals();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultDoneDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultDoneDecorator.java
index a7a12fc..bb6bece 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultDoneDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultDoneDecorator.java
@@ -72,6 +72,7 @@
* </pre>
*
*/
+ @Override
public int computeLength()
{
searchResultDoneLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();
@@ -87,6 +88,7 @@
* return The encoded response
* @throws EncoderException If the encoding failed
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultEntryDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultEntryDecorator.java
index bd6407c..0215d7c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultEntryDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultEntryDecorator.java
@@ -84,6 +84,9 @@
}
+ /**
+ * @return The current attribute
+ */
public Attribute getCurrentAttribute()
{
return currentAttribute;
@@ -144,6 +147,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getObjectName()
{
return getDecorated().getObjectName();
@@ -153,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setObjectName( Dn objectName )
{
getDecorated().setObjectName( objectName );
@@ -162,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getEntry()
{
return getDecorated().getEntry();
@@ -171,6 +177,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setEntry( Entry entry )
{
getDecorated().setEntry( entry );
@@ -221,6 +228,7 @@
* +--> 0x04 L7-m-n value
* </pre>
*/
+ @Override
public int computeLength()
{
Dn dn = getObjectName();
@@ -237,17 +245,17 @@
if ( ( entry != null ) && ( entry.size() != 0 ) )
{
- attributeLength = new LinkedList<Integer>();
- attributeIds = new LinkedList<byte[]>();
- valuesLength = new LinkedList<Integer>();
+ attributeLength = new LinkedList<>();
+ attributeIds = new LinkedList<>();
+ valuesLength = new LinkedList<>();
// Store those lists in the object
- valuesLength = new LinkedList<Integer>();
+ valuesLength = new LinkedList<>();
// Compute the attributes length
for ( Attribute attribute : entry )
{
- int localAttributeLength = 0;
+ int localAttributeLength;
int localValuesLength = 0;
// Get the type length
@@ -329,6 +337,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
@@ -375,7 +384,7 @@
}
}
- // Go to the next attribute number;
+ // Go to the next attribute number
attributeNumber++;
}
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultReferenceDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultReferenceDecorator.java
index dd858d9..497de34 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultReferenceDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchResultReferenceDecorator.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Referral getReferral()
{
return getDecorated().getReferral();
@@ -75,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReferral( Referral referral )
{
getDecorated().setReferral( referral );
@@ -106,6 +108,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
searchResultReferenceLength = 0;
@@ -139,6 +142,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
SearchResultReference searchResultReference = getDecorated();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SingleReplyRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SingleReplyRequestDecorator.java
index d4992d9..3ffd109 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SingleReplyRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SingleReplyRequestDecorator.java
@@ -30,6 +30,8 @@
/**
* A decorator for the LdapResultResponse message
*
+ * @param <M> The request to be decorated
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class SingleReplyRequestDecorator<M extends SingleReplyRequest>
@@ -50,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return getDecorated().getResponseType();
@@ -59,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void abandon()
{
( ( AbandonableRequest ) getDecorated() ).abandon();
@@ -68,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAbandoned()
{
return ( ( AbandonableRequest ) getDecorated() ).isAbandoned();
@@ -77,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonableRequest addAbandonListener( AbandonListener listener )
{
( ( AbandonableRequest ) getDecorated() ).addAbandonListener( listener );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/UnbindRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/UnbindRequestDecorator.java
index 5cf8932..e446a2e 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/UnbindRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/UnbindRequestDecorator.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest addControl( Control control )
{
return ( UnbindRequest ) super.addControl( control );
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest addAllControls( Control[] controls )
{
return ( UnbindRequest ) super.addAllControls( controls );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest removeControl( Control control )
{
return ( UnbindRequest ) super.removeControl( control );
@@ -100,6 +104,7 @@
* 0x42 00
* </pre>
*/
+ @Override
public int computeLength()
{
// Always 2
@@ -110,6 +115,7 @@
/**
* Encode the Unbind protocolOp part
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
try
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultActivator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultActivator.java
index 2ad9a14..a21cfc7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultActivator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultActivator.java
@@ -38,6 +38,9 @@
private ServiceRegistration<?> registration;
+ /**
+ * Creates a new instance of DefaultActivator
+ */
public DefaultActivator()
{
this.codec = new DefaultLdapCodecService();
@@ -47,6 +50,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void start( BundleContext bundleContext ) throws Exception
{
registration = bundleContext.registerService( LdapApiService.class.getName(), codec, null );
@@ -57,6 +61,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void stop( BundleContext bundleContext ) throws Exception
{
registration.unregister();
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
index e08b3d1..867f953 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
@@ -48,6 +48,8 @@
import org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory;
import org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory;
import org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory;
+import org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory;
+import org.apache.directory.api.ldap.codec.controls.sort.SortResponseFactory;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.ExtendedRequest;
import org.apache.directory.api.ldap.model.message.ExtendedRequestImpl;
@@ -61,6 +63,8 @@
import org.apache.directory.api.ldap.model.message.controls.PagedResults;
import org.apache.directory.api.ldap.model.message.controls.PersistentSearch;
import org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz;
+import org.apache.directory.api.ldap.model.message.controls.SortRequest;
+import org.apache.directory.api.ldap.model.message.controls.SortResponse;
import org.apache.directory.api.ldap.model.message.controls.Subentries;
import org.apache.directory.api.util.Strings;
import org.apache.directory.api.util.exception.NotImplementedException;
@@ -81,10 +85,10 @@
private static final Logger LOG = LoggerFactory.getLogger( DefaultLdapCodecService.class );
/** The map of registered {@link org.apache.directory.api.ldap.codec.api.ControlFactory}'s */
- private Map<String, ControlFactory<? extends Control>> controlFactories = new HashMap<String, ControlFactory<? extends Control>>();
+ private Map<String, ControlFactory<? extends Control>> controlFactories = new HashMap<>();
/** The map of registered {@link org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory}'s by request OID */
- private Map<String, ExtendedOperationFactory> extendedOperationsFactories = new HashMap<String, ExtendedOperationFactory>();
+ private Map<String, ExtendedOperationFactory> extendedOperationsFactories = new HashMap<>();
/** The registered ProtocolCodecFactory */
private ProtocolCodecFactory protocolCodecFactory;
@@ -131,6 +135,14 @@
ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( this );
controlFactories.put( subentriesFactory.getOid(), subentriesFactory );
LOG.info( "Registered pre-bundled control factory: {}", subentriesFactory.getOid() );
+
+ ControlFactory<SortRequest> sortRequestFactory = new SortRequestFactory( this );
+ controlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
+ LOG.info( "Registered pre-bundled control factory: {}", sortRequestFactory.getOid() );
+
+ ControlFactory<SortResponse> sortResponseFactory = new SortResponseFactory( this );
+ controlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
+ LOG.info( "Registered pre-bundled control factory: {}", sortResponseFactory.getOid() );
}
@@ -141,6 +153,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ControlFactory<?> registerControl( ControlFactory<?> factory )
{
return controlFactories.put( factory.getOid(), factory );
@@ -150,6 +163,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ControlFactory<?> unregisterControl( String oid )
{
return controlFactories.remove( oid );
@@ -159,6 +173,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> registeredControls()
{
return Collections.unmodifiableSet( controlFactories.keySet() ).iterator();
@@ -168,6 +183,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isControlRegistered( String oid )
{
return controlFactories.containsKey( oid );
@@ -177,6 +193,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> registeredExtendedRequests()
{
return Collections.unmodifiableSet( extendedOperationsFactories.keySet() ).iterator();
@@ -186,6 +203,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedOperationFactory registerExtendedRequest( ExtendedOperationFactory factory )
{
return extendedOperationsFactories.put( factory.getOid(), factory );
@@ -195,12 +213,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public ProtocolCodecFactory getProtocolCodecFactory()
{
return protocolCodecFactory;
}
+ @Override
public ProtocolCodecFactory registerProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory )
{
ProtocolCodecFactory oldFactory = this.protocolCodecFactory;
@@ -212,13 +232,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<? extends Control> newControl( String oid )
{
ControlFactory<?> factory = controlFactories.get( oid );
if ( factory == null )
{
- return new BasicControlDecorator<Control>( this, new OpaqueControl( oid ) );
+ return new BasicControlDecorator( this, new OpaqueControl( oid ) );
}
return factory.newCodecControl();
@@ -229,6 +250,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public CodecControl<? extends Control> newControl( Control control )
{
if ( control == null )
@@ -247,7 +269,7 @@
if ( factory == null )
{
- return new BasicControlDecorator<Control>( this, control );
+ return new BasicControlDecorator( this, control );
}
return factory.newCodecControl( control );
@@ -257,21 +279,22 @@
/**
* {@inheritDoc}
*/
+ @Override
public javax.naming.ldap.Control toJndiControl( Control control ) throws EncoderException
{
CodecControl<? extends Control> decorator = newControl( control );
ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
decorator.encode( bb );
bb.flip();
- BasicControl jndiControl =
- new BasicControl( control.getOid(), control.isCritical(), bb.array() );
- return jndiControl;
+
+ return new BasicControl( control.getOid(), control.isCritical(), bb.array() );
}
/**
* {@inheritDoc}
*/
+ @Override
public Control fromJndiControl( javax.naming.ldap.Control control ) throws DecoderException
{
@SuppressWarnings("rawtypes")
@@ -281,8 +304,8 @@
{
OpaqueControl ourControl = new OpaqueControl( control.getID() );
ourControl.setCritical( control.isCritical() );
- BasicControlDecorator<Control> decorator =
- new BasicControlDecorator<Control>( this, ourControl );
+ BasicControlDecorator decorator =
+ new BasicControlDecorator( this, ourControl );
decorator.setValue( control.getEncodedValue() );
return decorator;
}
@@ -300,6 +323,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Container newMessageContainer()
{
return new LdapMessageContainer<MessageDecorator<? extends Message>>( this );
@@ -309,6 +333,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedOperationFactory unregisterExtendedRequest( String oid )
{
return extendedOperationsFactories.remove( oid );
@@ -318,6 +343,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public javax.naming.ldap.ExtendedResponse toJndi( final ExtendedResponse modelResponse ) throws EncoderException
{
throw new NotImplementedException( "Figure out how to transform" );
@@ -327,6 +353,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse fromJndi( javax.naming.ldap.ExtendedResponse jndiResponse ) throws DecoderException
{
throw new NotImplementedException( "Figure out how to transform" );
@@ -336,17 +363,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest fromJndi( javax.naming.ldap.ExtendedRequest jndiRequest ) throws DecoderException
{
- ExtendedRequestDecorator<?> decorator =
- ( ExtendedRequestDecorator<?> ) newExtendedRequest( jndiRequest.getID(), jndiRequest.getEncodedValue() );
- return decorator;
+ return newExtendedRequest( jndiRequest.getID(), jndiRequest.getEncodedValue() );
}
/**
* {@inheritDoc}
*/
+ @Override
public javax.naming.ldap.ExtendedRequest toJndi( final ExtendedRequest modelRequest ) throws EncoderException
{
final String oid = modelRequest.getRequestName();
@@ -367,23 +394,26 @@
value = decorator.getRequestValue();
}
- javax.naming.ldap.ExtendedRequest jndiRequest = new javax.naming.ldap.ExtendedRequest()
+ return new javax.naming.ldap.ExtendedRequest()
{
private static final long serialVersionUID = -4160980385909987475L;
+ @Override
public String getID()
{
return oid;
}
+ @Override
public byte[] getEncodedValue()
{
return value;
}
+ @Override
public javax.naming.ldap.ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset,
int length ) throws NamingException
{
@@ -394,24 +424,25 @@
{
final ExtendedResponseDecorator<?> resp = ( ExtendedResponseDecorator<?> ) factory
.newResponse( berValue );
- javax.naming.ldap.ExtendedResponse jndiResponse = new javax.naming.ldap.ExtendedResponse()
+
+ return new javax.naming.ldap.ExtendedResponse()
{
private static final long serialVersionUID = -7686354122066100703L;
+ @Override
public String getID()
{
return oid;
}
+ @Override
public byte[] getEncodedValue()
{
return resp.getResponseValue();
}
};
-
- return jndiResponse;
}
catch ( DecoderException de )
{
@@ -422,8 +453,6 @@
}
}
};
-
- return jndiRequest;
}
@@ -431,6 +460,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public <E extends ExtendedResponse> E newExtendedResponse( String responseName, int messageId,
byte[] serializedResponse )
throws DecoderException
@@ -461,9 +491,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest newExtendedRequest( String oid, byte[] value )
{
- ExtendedRequest req = null;
+ ExtendedRequest req;
ExtendedOperationFactory extendedRequestFactory = extendedOperationsFactories.get( oid );
@@ -488,9 +519,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequestDecorator<?> decorate( ExtendedRequest decoratedMessage )
{
- ExtendedRequestDecorator<?> req = null;
+ ExtendedRequestDecorator<?> req;
ExtendedOperationFactory extendedRequestFactory = extendedOperationsFactories.get( decoratedMessage
.getRequestName() );
@@ -501,7 +533,7 @@
}
else
{
- req = new ExtendedRequestDecorator<ExtendedRequest>( this, decoratedMessage );
+ req = new ExtendedRequestDecorator<>( this, decoratedMessage );
}
return req;
@@ -511,9 +543,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponseDecorator<?> decorate( ExtendedResponse decoratedMessage )
{
- ExtendedResponseDecorator<?> resp = null;
+ ExtendedResponseDecorator<?> resp;
ExtendedOperationFactory extendedRequestFactory = extendedOperationsFactories.get( decoratedMessage
.getResponseName() );
@@ -524,7 +557,7 @@
}
else
{
- resp = new ExtendedResponseDecorator<ExtendedResponse>( this, decoratedMessage );
+ resp = new ExtendedResponseDecorator<>( this, decoratedMessage );
}
return resp;
@@ -534,6 +567,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isExtendedOperationRegistered( String oid )
{
return extendedOperationsFactories.containsKey( oid );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AndFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AndFilter.java
index b34e242..5e3661b 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AndFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AndFilter.java
@@ -83,6 +83,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
filtersLength = super.computeLength();
@@ -103,6 +104,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -132,9 +134,10 @@
*
* @return The AND filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( '&' ).append( super.toString() );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AttributeValueAssertionFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AttributeValueAssertionFilter.java
index b6abe24..917b830 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AttributeValueAssertionFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/AttributeValueAssertionFilter.java
@@ -140,6 +140,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
avaLength = 0;
@@ -149,7 +150,7 @@
org.apache.directory.api.ldap.model.entry.Value<?> assertionValue = assertion.getAssertionValue();
- int assertionValueLength = 0;
+ int assertionValueLength;
assertionValueLength = assertionValue.getBytes().length;
@@ -180,6 +181,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -241,6 +243,7 @@
*
* @return The item filter string
*/
+ @Override
public String toString()
{
return assertion != null ? assertion.toStringRFC2254( filterType ) : "";
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ConnectorFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ConnectorFilter.java
index b10ffcf..9b74ea8 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ConnectorFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ConnectorFilter.java
@@ -75,7 +75,7 @@
if ( filterSet == null )
{
- filterSet = new ArrayList<Filter>();
+ filterSet = new ArrayList<>();
}
filterSet.add( filter );
@@ -99,11 +99,12 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
int connectorFilterLength = 0;
- if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+ if ( ( filterSet != null ) && ( !filterSet.isEmpty() ) )
{
for ( Filter filter : filterSet )
{
@@ -126,6 +127,7 @@
* @return The PDU.
* @throws EncoderException If the encoding failed
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -134,7 +136,7 @@
}
// encode each filter
- if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+ if ( ( filterSet != null ) && ( !filterSet.isEmpty() ) )
{
for ( Filter filter : filterSet )
{
@@ -152,11 +154,12 @@
*
* @return The composite filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
- if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+ if ( ( filterSet != null ) && ( !filterSet.isEmpty() ) )
{
for ( Filter filter : filterSet )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ExtensibleMatchFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ExtensibleMatchFilter.java
index 15cb3eb..4098274 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ExtensibleMatchFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/ExtensibleMatchFilter.java
@@ -209,6 +209,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
if ( matchingRule != null )
@@ -258,6 +259,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -330,10 +332,11 @@
*
* @return An Extended Filter String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if ( type != null )
{
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/NotFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/NotFilter.java
index e402d6e..977dc13 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/NotFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/NotFilter.java
@@ -63,6 +63,7 @@
*
* @param filter The Filter to add
*/
+ @Override
public void addFilter( Filter filter ) throws DecoderException
{
if ( filterSet != null )
@@ -115,6 +116,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
filtersLength = super.computeLength();
@@ -134,6 +136,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -163,9 +166,10 @@
*
* @return The NOT filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( '!' ).append( super.toString() );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/OrFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/OrFilter.java
index 4ddcaa6..dfded38 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/OrFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/OrFilter.java
@@ -83,6 +83,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
filtersLength = super.computeLength();
@@ -102,6 +103,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -131,10 +133,11 @@
*
* @return The OR filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( '|' ).append( super.toString() );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/PresentFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/PresentFilter.java
index 2540c75..bf4c957 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/PresentFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/PresentFilter.java
@@ -99,6 +99,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
attributeDescriptionBytes = Strings.getBytesUtf8( attributeDescription );
@@ -113,6 +114,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -141,10 +143,11 @@
*
* @return The Present filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( attributeDescription ).append( "=*" );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
index 0b6fd07..cd1d885 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/search/SubstringFilter.java
@@ -65,7 +65,7 @@
private String initialSubstrings;
/** The any filter. It's a list of LdapString */
- private List<String> anySubstrings = new ArrayList<String>( 1 );
+ private List<String> anySubstrings = new ArrayList<>( 1 );
/** The final filter */
private String finalSubstrings;
@@ -227,6 +227,7 @@
*
* @return The encoded length
*/
+ @Override
public int computeLength()
{
// The type
@@ -286,6 +287,7 @@
* @param buffer The buffer where to put the PDU
* @return The PDU.
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -306,7 +308,7 @@
buffer.put( UniversalTag.SEQUENCE.getValue() );
buffer.put( TLV.getBytes( substringsFilterSequenceLength ) );
- if ( ( initialSubstrings == null ) && ( ( anySubstrings == null ) || ( anySubstrings.size() == 0 ) )
+ if ( ( initialSubstrings == null ) && ( ( anySubstrings == null ) || anySubstrings.isEmpty() )
&& ( finalSubstrings == null ) )
{
throw new EncoderException( I18n.err( I18n.ERR_04058 ) );
@@ -356,10 +358,11 @@
*
* @return The substring filter string
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if ( initialSubstrings != null )
{
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
index 0dcbc10..f6e0c9e 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/LdapControlTest.java
@@ -64,114 +64,31 @@
ByteBuffer stream = ByteBuffer.allocate( 0x64 );
stream.put( new byte[]
- { 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
- 0x02,
- 0x01,
- 0x03, // messageID MessageID
- 0x50,
- 0x01,
- 0x02, // CHOICE { ..., abandonRequest
- // AbandonRequest,...
- ( byte ) 0xA0,
- 0x5A, // controls [0] Controls OPTIONAL }
- 0x30,
- 0x1A, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04,
- 0x0D,
- '1',
- '.',
- '3',
- '.',
- '6',
- '.',
- '1',
- '.',
- '5',
- '.',
- '5',
- '.',
- '1',
- // criticality BOOLEAN DEFAULT FALSE,
- 0x01,
- 0x01,
- ( byte ) 0xFF,
- // controlValue OCTET STRING OPTIONAL }
- 0x04,
- 0x06,
- 'a',
- 'b',
- 'c',
- 'd',
- 'e',
- 'f',
- 0x30,
- 0x17, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04,
- 0x0D,
- '1',
- '.',
- '3',
- '.',
- '6',
- '.',
- '1',
- '.',
- '5',
- '.',
- '5',
- '.',
- '2',
- // controlValue OCTET STRING OPTIONAL }
- 0x04,
- 0x06,
- 'g',
- 'h',
- 'i',
- 'j',
- 'k',
- 'l',
- 0x30,
- 0x12, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04,
- 0x0D,
- '1',
- '.',
- '3',
- '.',
- '6',
- '.',
- '1',
- '.',
- '5',
- '.',
- '5',
- '.',
- '3',
- // criticality BOOLEAN DEFAULT FALSE}
- 0x01,
- 0x01,
- ( byte ) 0xFF,
- 0x30,
- 0x0F, // Control ::= SEQUENCE {
- // controlType LDAPOID}
- 0x04,
- 0x0D,
- '1',
- '.',
- '3',
- '.',
- '6',
- '.',
- '1',
- '.',
- '5',
- '.',
- '5',
- '.',
- '4' } );
+ {
+ 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x03, // messageID MessageID
+ 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ // AbandonRequest,...
+ ( byte ) 0xA0, 0x5A, // controls [0] Controls OPTIONAL }
+ 0x30, 0x1A, // Control ::= SEQUENCE {
+ 0x04, 0x0D, // controlType LDAPOID,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+ 0x01, 0x01, ( byte ) 0xFF, // criticality BOOLEAN DEFAULT FALSE,
+ 0x04, 0x06, // controlValue OCTET STRING OPTIONAL }
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ 0x30, 0x17, // Control ::= SEQUENCE {
+ 0x04, 0x0D, // controlType LDAPOID,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ 0x04, 0x06, // controlValue OCTET STRING OPTIONAL }
+ 'g', 'h', 'i', 'j', 'k', 'l',
+ 0x30, 0x12, // Control ::= SEQUENCE {
+ 0x04, 0x0D, // controlType LDAPOID,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
+ 0x01, 0x01, ( byte ) 0xFF, // criticality BOOLEAN DEFAULT FALSE}
+ 0x30, 0x0F, // Control ::= SEQUENCE {
+ 0x04, 0x0D, // controlType LDAPOID}
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4'
+ } );
stream.flip();
@@ -261,6 +178,88 @@
}
}
+
+ /**
+ * Test the decoding of a Request with an empty list of controls
+ */
+ @Test
+ public void testDecodeRequestWithEmptyControls()
+ {
+ Asn1Decoder ldapDecoder = new Asn1Decoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x0A );
+ stream.put( new byte[]
+ {
+ 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x03, // messageID MessageID
+ 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ // AbandonRequest,...
+ ( byte ) 0xA0, 0x00 // controls [0] Controls OPTIONAL }
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessageContainer Container
+ LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
+ new LdapMessageContainer<AbandonRequestDecorator>( codec );
+
+ // Decode the PDU
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ de.printStackTrace();
+ fail( de.getMessage() );
+ }
+
+ // Check that everything is OK
+ AbandonRequestDecorator abandonRequest = ldapMessageContainer.getMessage();
+
+ // Copy the message
+ AbandonRequest internalAbandonRequest = new AbandonRequestImpl( abandonRequest.getAbandoned() );
+ internalAbandonRequest.setMessageId( abandonRequest.getMessageId() );
+
+ assertEquals( 3, abandonRequest.getMessageId() );
+ assertEquals( 2, abandonRequest.getAbandoned() );
+
+ // Check the Controls
+ Map<String, Control> controls = abandonRequest.getControls();
+
+ assertEquals( 0, controls.size() );
+
+ // Check the encoding
+ try
+ {
+ ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );
+
+ // Check the length, which should be 2 bytes shorter, as we don't encode teh empty control
+ assertEquals( 0x08, bb.limit() );
+
+ // Don't check the PDU, as control are in a Map, and can be in a different order
+ // So we decode the generated PDU, and we compare it with the initial message
+ try
+ {
+ ldapDecoder.decode( bb, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ de.printStackTrace();
+ fail( de.getMessage() );
+ }
+
+ AbandonRequest abandonRequest2 = ldapMessageContainer.getMessage();
+
+ assertEquals( abandonRequest, abandonRequest2 );
+ }
+ catch ( EncoderException ee )
+ {
+ ee.printStackTrace();
+ fail( ee.getMessage() );
+ }
+ }
+
/**
* Test the decoding of a Request with null OID controls
diff --git a/ldap/codec/pom.xml b/ldap/codec/pom.xml
index bf12cac..ce2e4c9 100644
--- a/ldap/codec/pom.xml
+++ b/ldap/codec/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-codec-parent</artifactId>
diff --git a/ldap/codec/standalone/pom.xml b/ldap/codec/standalone/pom.xml
index 35ffbf2..be1d624 100644
--- a/ldap/codec/standalone/pom.xml
+++ b/ldap/codec/standalone/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-codec-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-codec-standalone</artifactId>
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
index 687ffee..21a9163 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
@@ -184,7 +184,23 @@
}
- public static void loadStockExtendedOperations(
+ /**
+ * Load the standard extended operations :
+ * <ul>
+ * <li>cancel</li>
+ * <li>certGeneration</li>
+ * <li>gracefuShutdown</li>
+ * <li>storedProcedure</li>
+ * <li>gracefulDisconnect</li>
+ * <li>passwordModify</li>
+ * <li>whoAmI</li>
+ * <li>startTls</li>
+ * </ul>
+ *
+ * @param extendendOperationsFactories The map of extended operation factories
+ * @param apiService The LdapApiService to use
+ */
+ public static void loadStockExtendedOperations(
Map<String, ExtendedOperationFactory> extendendOperationsFactories, LdapApiService apiService )
{
CancelFactory cancelFactory = new CancelFactory( apiService );
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
index 11d70a7..ad76380 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
@@ -198,7 +198,7 @@
*/
private static List<String> getControlsFromSystemProperties() throws Exception
{
- List<String> controlsList = new ArrayList<String>();
+ List<String> controlsList = new ArrayList<>();
// Loading controls list from command line properties if it exists
String controlsString = System.getProperty( CONTROLS_LIST );
@@ -235,7 +235,7 @@
*/
private static List<String> getExtendedOperationsFromSystemProperties() throws Exception
{
- List<String> extendedOperationsList = new ArrayList<String>();
+ List<String> extendedOperationsList = new ArrayList<>();
// Loading extended operations from command line properties if it exists
String defaultExtendedOperationsList = System.getProperty( EXTENDED_OPERATIONS_LIST );
@@ -271,7 +271,7 @@
private void loadControls( List<String> controlsList ) throws Exception
{
// Adding all controls
- if ( controlsList.size() > 0 )
+ if ( !controlsList.isEmpty() )
{
for ( String controlFQCN : controlsList )
{
@@ -315,7 +315,7 @@
private void loadExtendedOperations( List<String> extendedOperationsList ) throws Exception
{
// Adding all extended operations
- if ( extendedOperationsList.size() > 0 )
+ if ( !extendedOperationsList.isEmpty() )
{
for ( String extendedOperationFQCN : extendedOperationsList )
{
diff --git a/ldap/extras/aci/pom.xml b/ldap/extras/aci/pom.xml
index f9f537e..25d58bc 100644
--- a/ldap/extras/aci/pom.xml
+++ b/ldap/extras/aci/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-aci</artifactId>
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItem.java
index 7fe0104..e518fce 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItem.java
@@ -126,7 +126,7 @@
*/
protected static Collection<MicroOperation> toMicroOperations( Collection<GrantAndDenial> grantsAndDenials )
{
- Set<MicroOperation> microOps = new HashSet<MicroOperation>();
+ Set<MicroOperation> microOps = new HashSet<>();
for ( GrantAndDenial grantAndDenial : grantsAndDenials )
{
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemChecker.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemChecker.java
index d82eee3..2c9bb62 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemChecker.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemChecker.java
@@ -26,6 +26,7 @@
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.StringConstants;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -82,7 +83,7 @@
*/
public synchronized void parse( String spec ) throws ParseException
{
- if ( spec == null || spec.trim().equals( "" ) )
+ if ( spec == null || StringConstants.EMPTY .equals( spec.trim() ) )
{
return;
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemParser.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemParser.java
index d20f803..7ad8ad5 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemParser.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemParser.java
@@ -27,6 +27,7 @@
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.normalizers.NameComponentNormalizer;
+import org.apache.directory.api.util.StringConstants;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -112,9 +113,9 @@
*/
public synchronized ACIItem parse( String spec ) throws ParseException
{
- ACIItem aCIItem = null;
+ ACIItem aCIItem;
- if ( spec == null || spec.trim().equals( "" ) )
+ if ( spec == null || StringConstants.EMPTY .equals( spec.trim() ) )
{
return null;
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemSyntaxChecker.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemSyntaxChecker.java
index 8a1187c..06baee2 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemSyntaxChecker.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ACIItemSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -37,34 +36,90 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ACIItemSyntaxChecker extends SyntaxChecker
+public final class ACIItemSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( ACIItemSyntaxChecker.class );
-
/** An instance of ACI Item Checker */
- private ACIItemChecker aciItemChecker;
+ private transient ACIItemChecker aciItemChecker;
+
+ /**
+ * A static instance of ACIItemSyntaxChecker
+ */
+ public static final ACIItemSyntaxChecker INSTANCE =
+ new ACIItemSyntaxChecker( SchemaConstants.ACI_ITEM_SYNTAX, null );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ACIItemSyntaxChecker>
+ {
+ /** The schemaManager to use */
+ private SchemaManager schemaManager;
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.ACI_ITEM_SYNTAX );
+ }
+
+
+ public Builder setSchemaManager( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+
+ return this;
+ }
+
+ /**
+ * Create a new instance of ACIItemSyntaxChecker
+ * @return A new instance of ACIItemSyntaxChecker
+ */
+ @Override
+ public ACIItemSyntaxChecker build()
+ {
+ return new ACIItemSyntaxChecker( oid, schemaManager );
+ }
+ }
/**
* Creates a new instance of ACIItemSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ * @param schemaManager The SchemaManager instance
*/
- public ACIItemSyntaxChecker()
+ private ACIItemSyntaxChecker( String oid, SchemaManager schemaManager )
{
- super( SchemaConstants.ACI_ITEM_SYNTAX );
+ super( oid );
+ aciItemChecker = new ACIItemChecker( schemaManager );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -83,7 +138,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -94,22 +153,21 @@
aciItemChecker.parse( strValue );
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
-
-
- /**
- * {@inheritDoc}
- */
- public void setSchemaManager( SchemaManager schemaManager )
- {
- aciItemChecker = new ACIItemChecker( schemaManager );
- }
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/GrantAndDenial.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/GrantAndDenial.java
index 0209712..1b5647b 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/GrantAndDenial.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/GrantAndDenial.java
@@ -124,7 +124,7 @@
private final boolean grant;
- private GrantAndDenial( MicroOperation microOperation, int code, boolean grant )
+ GrantAndDenial( MicroOperation microOperation, int code, boolean grant )
{
this.microOperation = microOperation;
this.code = code;
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemFirstACIItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemFirstACIItem.java
index bfbf6a4..531d950 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemFirstACIItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemFirstACIItem.java
@@ -147,9 +147,10 @@
*
* @return The list of created Tuples
*/
+ @Override
public Collection<ACITuple> toTuples()
{
- Collection<ACITuple> tuples = new ArrayList<ACITuple>();
+ Collection<ACITuple> tuples = new ArrayList<>();
for ( ItemPermission itemPermission : itemPermissions )
{
@@ -159,13 +160,13 @@
? itemPermission.getPrecedence()
: this.getPrecedence();
- if ( grants.size() > 0 )
+ if ( !grants.isEmpty() )
{
tuples.add( new ACITuple( itemPermission.getUserClasses(), getAuthenticationLevel(), protectedItems,
toMicroOperations( grants ), true, precedence ) );
}
- if ( denials.size() > 0 )
+ if ( !denials.isEmpty() )
{
tuples.add( new ACITuple( itemPermission.getUserClasses(), getAuthenticationLevel(), protectedItems,
toMicroOperations( denials ), false, precedence ) );
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemPermission.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemPermission.java
index f8d46e5..748ce25 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemPermission.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ItemPermission.java
@@ -40,13 +40,10 @@
/**
* Creates a new instance
*
- * @param precedence
- * the precedence of this permission (<tt>-1</tt> to use the
- * default)
- * @param grantsAndDenials
- * the collection of {@link GrantAndDenial}s
- * @param userClasses
- * the collection of {@link UserClass}es
+ * @param precedence the precedence of this permission (<tt>-1</tt> to use the
+ * default)
+ * @param grantsAndDenials the collection of {@link GrantAndDenial}s
+ * @param userClasses the collection of {@link UserClass}es
*/
public ItemPermission( Integer precedence, Collection<GrantAndDenial> grantsAndDenials,
Collection<UserClass> userClasses )
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/MicroOperation.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/MicroOperation.java
index 1663957..601089a 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/MicroOperation.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/MicroOperation.java
@@ -74,7 +74,7 @@
private final String name;
- private MicroOperation( String name )
+ MicroOperation( String name )
{
this.name = name;
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/Permission.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/Permission.java
index 1cb3903..4197aa5 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/Permission.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/Permission.java
@@ -59,9 +59,9 @@
{
this.precedence = precedence;
- Set<GrantAndDenial> tmpGrantsAndDenials = new HashSet<GrantAndDenial>();
- Set<GrantAndDenial> tmpGrants = new HashSet<GrantAndDenial>();
- Set<GrantAndDenial> tmpDenials = new HashSet<GrantAndDenial>();
+ Set<GrantAndDenial> tmpGrantsAndDenials = new HashSet<>();
+ Set<GrantAndDenial> tmpGrants = new HashSet<>();
+ Set<GrantAndDenial> tmpDenials = new HashSet<>();
for ( GrantAndDenial gad : grantsAndDenials )
{
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemChecker.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemChecker.java
index cbbec61..a3cb573 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemChecker.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemChecker.java
@@ -41,7 +41,7 @@
/**
* Creates a ReusableAntlrACIItemChecker instance.
*/
- public ReusableAntlrACIItemChecker( TokenStream lexer )
+ ReusableAntlrACIItemChecker( TokenStream lexer )
{
super( lexer );
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemCheckerLexer.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemCheckerLexer.java
index 2509e08..3f94d0a 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemCheckerLexer.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemCheckerLexer.java
@@ -55,7 +55,7 @@
* @param in
* the input to the lexer
*/
- public ReusableAntlrACIItemCheckerLexer( Reader in )
+ ReusableAntlrACIItemCheckerLexer( Reader in )
{
super( in );
savedCaseSensitive = getCaseSensitive();
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemLexer.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemLexer.java
index 77a0b49..3935abd 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemLexer.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemLexer.java
@@ -55,7 +55,7 @@
* @param in
* the input to the lexer
*/
- public ReusableAntlrACIItemLexer( Reader in )
+ ReusableAntlrACIItemLexer( Reader in )
{
super( in );
savedCaseSensitive = getCaseSensitive();
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemParser.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemParser.java
index 9dccaf0..6a5b389 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemParser.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ReusableAntlrACIItemParser.java
@@ -41,7 +41,7 @@
/**
* Creates a ReusableAntlrSubtreeSpecificationParser instance.
*/
- public ReusableAntlrACIItemParser( TokenStream lexer )
+ ReusableAntlrACIItemParser( TokenStream lexer )
{
super( lexer );
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
index 74c9119..6797f37 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
@@ -232,6 +232,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder buffer = new StringBuilder();
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserFirstACIItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserFirstACIItem.java
index 040757a..48aead3 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserFirstACIItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserFirstACIItem.java
@@ -165,9 +165,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<ACITuple> toTuples()
{
- Collection<ACITuple> tuples = new ArrayList<ACITuple>();
+ Collection<ACITuple> tuples = new ArrayList<>();
for ( UserPermission userPermission : userPermissions )
{
@@ -177,12 +178,12 @@
? userPermission.getPrecedence()
: this.getPrecedence();
- if ( grants.size() > 0 )
+ if ( !grants.isEmpty() )
{
tuples.add( new ACITuple( getUserClasses(), getAuthenticationLevel(), userPermission
.getProtectedItems(), toMicroOperations( grants ), true, precedence ) );
}
- if ( denials.size() > 0 )
+ if ( !denials.isEmpty() )
{
tuples.add( new ACITuple( getUserClasses(), getAuthenticationLevel(), userPermission
.getProtectedItems(), toMicroOperations( denials ), false, precedence ) );
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
index 4459db6..9fbb997 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
@@ -38,7 +38,6 @@
/** The attribute types. */
protected final Set<AttributeType> attributeTypes;
-
/**
* Creates a new instance.
*
@@ -69,12 +68,15 @@
{
int hash = 37;
- for ( AttributeType attributeType : attributeTypes )
+ if ( attributeTypes != null )
{
- hash = hash * 17 + attributeType.hashCode();
+ for ( AttributeType attributeType : attributeTypes )
+ {
+ hash = hash * 17 + attributeType.hashCode();
+ }
}
- hash = hash * 17 + this.getClass().getName().hashCode();
+ hash = hash * 17 + getClass().getName().hashCode();
return hash;
}
@@ -99,7 +101,28 @@
if ( getClass().isAssignableFrom( o.getClass() ) )
{
AbstractAttributeTypeProtectedItem that = ( AbstractAttributeTypeProtectedItem ) o;
- return this.attributeTypes.equals( that.attributeTypes );
+
+ if ( attributeTypes != null )
+ {
+ if ( ( that.attributeTypes == null ) || ( that.attributeTypes.size() != attributeTypes.size() ) )
+ {
+ return false;
+ }
+
+ for ( AttributeType attributeType : attributeTypes )
+ {
+ if ( !that.attributeTypes.contains( attributeType ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ return that.attributeTypes == null;
+ }
}
return false;
@@ -117,18 +140,21 @@
buf.append( "{ " );
boolean isFirst = true;
- for ( AttributeType attributeType : attributeTypes )
+ if ( attributeTypes != null )
{
- if ( isFirst )
+ for ( AttributeType attributeType : attributeTypes )
{
- isFirst = false;
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ buf.append( ", " );
+ }
+
+ buf.append( attributeType.getName() );
}
- else
- {
- buf.append( ", " );
- }
-
- buf.append( attributeType.getName() );
}
buf.append( " }" );
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesAndValuesItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesAndValuesItem.java
index 837c902..0525423 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesAndValuesItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesAndValuesItem.java
@@ -32,14 +32,6 @@
public class AllUserAttributeTypesAndValuesItem extends ProtectedItem
{
/**
- * Creates a new instance of AllUserAttributeTypesAndValuesItem.
- */
- public AllUserAttributeTypesAndValuesItem()
- {
- }
-
-
- /**
* {@inheritDoc}
*/
@Override
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesItem.java
index ed87a3e..9a52944 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AllUserAttributeTypesItem.java
@@ -32,14 +32,6 @@
public class AllUserAttributeTypesItem extends ProtectedItem
{
/**
- * Creates a new instance of AllUserAttributeTypesItem.
- */
- public AllUserAttributeTypesItem()
- {
- }
-
-
- /**
* {@inheritDoc}
*/
@Override
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AttributeValueItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AttributeValueItem.java
index 834ec64..8ae36a1 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AttributeValueItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AttributeValueItem.java
@@ -68,7 +68,15 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + attributes.hashCode();
+
+ if ( attributes != null )
+ {
+ for ( Attribute attribute : attributes )
+ {
+ hash = hash * 17 + attribute.hashCode();
+ }
+ }
+
return hash;
}
@@ -84,16 +92,31 @@
return true;
}
- if ( o == null )
- {
- return false;
- }
-
if ( o instanceof AttributeValueItem )
{
AttributeValueItem that = ( AttributeValueItem ) o;
- return this.attributes.equals( that.attributes );
+ if ( attributes != null )
+ {
+ if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) )
+ {
+ return false;
+ }
+
+ for ( Attribute attribute : attributes )
+ {
+ if ( !that.attributes.contains( attribute ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ return attributes == null;
+ }
}
return false;
@@ -103,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
@@ -111,20 +135,23 @@
boolean isFirst = true;
- for ( Attribute attribute : attributes )
+ if ( attributes != null )
{
- if ( isFirst )
+ for ( Attribute attribute : attributes )
{
- isFirst = false;
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ buf.append( ", " );
+ }
+
+ buf.append( attribute.getId() );
+ buf.append( '=' );
+ buf.append( attribute.get() );
}
- else
- {
- buf.append( ", " );
- }
-
- buf.append( attribute.getId() );
- buf.append( '=' );
- buf.append( attribute.get() );
}
buf.append( " }" );
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/ClassesItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/ClassesItem.java
index 2dd97be..e5524aa 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/ClassesItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/ClassesItem.java
@@ -39,7 +39,6 @@
/** The classes refinement. */
private final ExprNode classes;
-
/**
* Creates a new instance.
*
@@ -69,7 +68,16 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + getClass().getName().hashCode();
+
+ if ( classes != null )
+ {
+ hash = hash * 17 + classes.hashCode();
+ }
+ else
+ {
+ hash = hash * 17 + getClass().getName().hashCode();
+ }
+
return hash;
}
@@ -88,7 +96,13 @@
if ( o instanceof ClassesItem )
{
ClassesItem that = ( ClassesItem ) o;
- return this.classes.equals( that.classes );
+
+ if ( classes == null )
+ {
+ return that.classes == null;
+ }
+
+ return classes.equals( that.classes );
}
return false;
@@ -104,7 +118,11 @@
StringBuilder buf = new StringBuilder();
buf.append( "classes " );
- classes.printRefinementToBuffer( buf );
+
+ if ( classes != null )
+ {
+ classes.printRefinementToBuffer( buf );
+ }
return buf.toString();
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/EntryItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/EntryItem.java
index e32de1a..cf5ab2f 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/EntryItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/EntryItem.java
@@ -36,14 +36,6 @@
public class EntryItem extends ProtectedItem
{
/**
- * Creates a new instance of EntryItem.
- */
- public EntryItem()
- {
- }
-
-
- /**
* {@inheritDoc}
*/
@Override
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxImmSubItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxImmSubItem.java
index 78782bb..3deddc1 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxImmSubItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxImmSubItem.java
@@ -40,7 +40,6 @@
/** The maximum number of allowed subordinates */
private final int value;
-
/**
* Creates a new instance.
*
@@ -71,6 +70,7 @@
{
int hash = 37;
hash = hash * 17 + value;
+
return hash;
}
@@ -89,6 +89,7 @@
if ( o instanceof MaxImmSubItem )
{
MaxImmSubItem that = ( MaxImmSubItem ) o;
+
return this.value == that.value;
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
index 2eebe09..b3282bf 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
@@ -36,7 +36,6 @@
/** The maximum number of accepted values for this attributeType */
private int maxCount;
-
/**
* Creates a new instance.
*
@@ -81,7 +80,12 @@
{
int hash = 37;
hash = hash * 17 + maxCount;
- hash = hash * 17 + attributeType.hashCode();
+
+ if ( attributeType != null )
+ {
+ hash = hash * 17 + attributeType.hashCode();
+ }
+
return hash;
}
@@ -92,11 +96,6 @@
@Override
public boolean equals( Object o )
{
- if ( o == null )
- {
- return false;
- }
-
if ( this == o )
{
return true;
@@ -105,18 +104,20 @@
if ( o instanceof MaxValueCountElem )
{
MaxValueCountElem that = ( MaxValueCountElem ) o;
- if ( this.maxCount == that.maxCount )
+
+ if ( maxCount == that.maxCount )
{
- if ( this.attributeType == null )
+ if ( attributeType == null )
{
return that.attributeType == null;
}
else
{
- return this.attributeType.equals( that.attributeType );
+ return attributeType.equals( that.attributeType );
}
}
}
+
return false;
}
@@ -127,6 +128,22 @@
@Override
public String toString()
{
- return "{ type " + attributeType.getName() + ", maxCount " + maxCount + " }";
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "{ type " );
+
+ if ( attributeType != null )
+ {
+ sb.append( attributeType.getName() );
+ }
+ else
+ {
+ sb.append( "null" );
+ }
+
+ sb.append( ", maxCount " ).append( maxCount );
+ sb.append( "}" );
+
+ return sb.toString();
}
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountItem.java
index 4994332..3d277be 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountItem.java
@@ -43,7 +43,6 @@
/** The set of elements to protect */
private final Set<MaxValueCountElem> items;
-
/**
* Creates a new instance.
*
@@ -73,7 +72,22 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + items.hashCode();
+
+ if ( items != null )
+ {
+ for ( MaxValueCountElem item : items )
+ {
+ if ( item != null )
+ {
+ hash = hash * 17 + item.hashCode();
+ }
+ else
+ {
+ hash = hash * 17 + 37;
+ }
+ }
+ }
+
return hash;
}
@@ -89,15 +103,11 @@
return true;
}
- if ( o == null )
- {
- return false;
- }
-
if ( o instanceof MaxValueCountItem )
{
MaxValueCountItem that = ( MaxValueCountItem ) o;
- return this.items.equals( that.items );
+
+ return items.equals( that.items );
}
return false;
@@ -116,18 +126,21 @@
boolean isFirst = true;
- for ( MaxValueCountElem item : items )
+ if ( items != null )
{
- if ( isFirst )
+ for ( MaxValueCountElem item : items )
{
- isFirst = false;
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ buf.append( ", " );
+ }
+
+ buf.append( item.toString() );
}
- else
- {
- buf.append( ", " );
- }
-
- buf.append( item.toString() );
}
buf.append( "}" );
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RangeOfValuesItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RangeOfValuesItem.java
index ff00939..8e328e3 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RangeOfValuesItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RangeOfValuesItem.java
@@ -32,7 +32,6 @@
*/
public class RangeOfValuesItem extends ProtectedItem
{
-
/** The filter. */
private final ExprNode filter;
@@ -73,7 +72,12 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + filter.hashCode();
+
+ if ( filter != null )
+ {
+ hash = hash * 17 + filter.hashCode();
+ }
+
return hash;
}
@@ -92,7 +96,8 @@
if ( o instanceof RangeOfValuesItem )
{
RangeOfValuesItem that = ( RangeOfValuesItem ) o;
- return this.filter.equals( that.filter );
+
+ return filter.equals( that.filter );
}
return false;
@@ -102,12 +107,17 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
buf.append( "rangeOfValues " );
- buf.append( filter.toString() );
+
+ if ( filter != null )
+ {
+ buf.append( filter.toString() );
+ }
return buf.toString();
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByElem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByElem.java
index 1518b7e..79ce0bc 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByElem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByElem.java
@@ -36,7 +36,6 @@
/** The list of allowed AttributeType values */
private AttributeType valuesIn;
-
/**
* Creates a new instance.
*
@@ -80,8 +79,17 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + attributeType.hashCode();
- hash = hash * 17 + valuesIn.hashCode();
+
+ if ( attributeType != null )
+ {
+ hash = hash * 17 + attributeType.hashCode();
+ }
+
+ if ( valuesIn != null )
+ {
+ hash = hash * 17 + valuesIn.hashCode();
+ }
+
return hash;
}
@@ -92,11 +100,6 @@
@Override
public boolean equals( Object o )
{
- if ( o == null )
- {
- return false;
- }
-
if ( this == o )
{
return true;
@@ -105,37 +108,37 @@
if ( o instanceof RestrictedByElem )
{
RestrictedByElem that = ( RestrictedByElem ) o;
- if ( this.attributeType == null )
+
+ if ( attributeType == null )
{
if ( that.attributeType == null )
{
- if ( this.valuesIn == null )
+ if ( valuesIn == null )
{
return that.valuesIn == null;
}
else
{
- return this.valuesIn.equals( that.valuesIn );
+ return valuesIn.equals( that.valuesIn );
}
}
- return false;
}
else
{
- if ( this.attributeType.equals( that.attributeType ) )
+ if ( attributeType.equals( that.attributeType ) )
{
- if ( this.valuesIn == null )
+ if ( valuesIn == null )
{
return that.valuesIn == null;
}
else
{
- return this.valuesIn.equals( that.valuesIn );
+ return valuesIn.equals( that.valuesIn );
}
}
- return false;
}
}
+
return false;
}
@@ -146,6 +149,32 @@
@Override
public String toString()
{
- return "{ type " + attributeType.getName() + ", valuesIn " + valuesIn.getName() + " }";
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "{ type " );
+
+ if ( attributeType != null )
+ {
+ sb.append( attributeType.getName() );
+ }
+ else
+ {
+ sb.append( "null" );
+ }
+
+ sb.append( ", valuesIn " );
+
+ if ( valuesIn != null )
+ {
+ sb.append( valuesIn.getName() );
+ }
+ else
+ {
+ sb.append( "null" );
+ }
+
+ sb.append( "}" );
+
+ return sb.toString();
}
}
diff --git a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByItem.java b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByItem.java
index 92ac01e..36abfa7 100644
--- a/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByItem.java
+++ b/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/RestrictedByItem.java
@@ -44,7 +44,6 @@
/** The set of restricted elements */
private final Set<RestrictedByElem> items;
-
/**
* Creates a new instance.
*
@@ -74,7 +73,22 @@
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + items.hashCode();
+
+ if ( items != null )
+ {
+ for ( RestrictedByElem item : items )
+ {
+ if ( item != null )
+ {
+ hash = hash * 17 + item.hashCode();
+ }
+ else
+ {
+ hash = hash * 17 + 37;
+ }
+ }
+ }
+
return hash;
}
@@ -90,15 +104,36 @@
return true;
}
- if ( o == null )
- {
- return false;
- }
-
if ( o instanceof RestrictedByItem )
{
RestrictedByItem that = ( RestrictedByItem ) o;
- return this.items.equals( that.items );
+
+ if ( items != null )
+ {
+ if ( that.items == null )
+ {
+ return false;
+ }
+
+ if ( items.size() != that.items.size() )
+ {
+ return false;
+ }
+
+ for ( RestrictedByElem item : items )
+ {
+ if ( !that.items.contains( item ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ return that.items == null;
+ }
}
return false;
@@ -117,18 +152,21 @@
boolean isFirst = true;
- for ( RestrictedByElem item : items )
+ if ( items != null )
{
- if ( isFirst )
+ for ( RestrictedByElem item : items )
{
- isFirst = false;
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ buf.append( ", " );
+ }
+
+ buf.append( item.toString() );
}
- else
- {
- buf.append( ", " );
- }
-
- buf.append( item.toString() );
}
buf.append( '}' );
diff --git a/ldap/extras/codec-api/pom.xml b/ldap/extras/codec-api/pom.xml
index cbdb326..f97caac 100644
--- a/ldap/extras/codec-api/pom.xml
+++ b/ldap/extras/codec-api/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-codec-api</artifactId>
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SyncModifyDnType.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SyncModifyDnType.java
index 5df18a4..d89d917 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SyncModifyDnType.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SyncModifyDnType.java
@@ -28,8 +28,13 @@
*/
public enum SyncModifyDnType
{
+ /** A Move operation */
MOVE(0),
+
+ /** A Rename operation */
RENAME(1),
+
+ /** A Move and Rename operation */
MOVE_AND_RENAME(2);
/** Internal value for each tag */
@@ -39,7 +44,7 @@
/**
* Creates the value
*/
- private SyncModifyDnType( int value )
+ SyncModifyDnType( int value )
{
this.value = value;
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SynchronizationModeEnum.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SynchronizationModeEnum.java
index 1353e3c..4ef5bfc 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SynchronizationModeEnum.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/SynchronizationModeEnum.java
@@ -40,9 +40,16 @@
*/
public enum SynchronizationModeEnum
{
+ /** Unused */
UNUSED(0),
+
+ /** Refresh only mode */
REFRESH_ONLY(1),
+
+ /** Unused */
RESERVED(2),
+
+ /** Refresh and Persist mode */
REFRESH_AND_PERSIST(3);
/** The internal value */
@@ -55,7 +62,7 @@
*
* @param value the integer value of the enumeration.
*/
- private SynchronizationModeEnum( int value )
+ SynchronizationModeEnum( int value )
{
this.value = value;
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
index 0819c71..41a98ba 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
@@ -22,6 +22,8 @@
import org.apache.directory.api.ldap.model.message.Control;
+import java.util.EnumSet;
+import java.util.Set;
/**
* The DirSync control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
@@ -39,9 +41,9 @@
*
* Client side :
* realReplControlValue ::= SEQUENCE {
- * parentsFirst integer
- * maxReturnLength integer
- * cookie OCTET STRING
+ * flags integer
+ * maxBytes integer
+ * cookie OCTET STRING
* }
*
* or
@@ -49,7 +51,7 @@
* server side :
* realReplControlValue ::= SEQUENCE {
* flag integer
- * maxReturnLength integer
+ * maxBytes integer
* cookie OCTET STRING
* }
* </pre>
@@ -62,19 +64,6 @@
/** This control OID */
String OID = "1.2.840.113556.1.4.841";
-
- /**
- * @return 1 if the parents are guaranteed to be returned before the children.
- */
- int getParentFirst();
-
-
- /**
- * @param parentFirst The parentFirst flag. A value of 1 will tell the server to return the parents first.
- */
- void setParentFirst( int parentFirst );
-
-
/**
* @return The maximum length of attributes to be returned
*/
@@ -101,7 +90,7 @@
/**
- * @return The flag returned by the server. One of :
+ * @return The flags returned by the server. Zero or more of :
* <ul>
* <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
* <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
@@ -109,11 +98,23 @@
* <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
* </ul>
*/
- AdDirSyncFlag getFlag();
+ Set<AdDirSyncFlag> getFlags();
/**
- * @param flag The flag.
+ * @param flags The flags to be set. See {@link EnumSet} for how to generate EnumSets.
*/
- void setFlag( AdDirSyncFlag flag );
+ void setFlags( Set<AdDirSyncFlag> flags );
+
+
+ /**
+ * @param flag The flag to be added to the current collection of flags.
+ */
+ void addFlag( AdDirSyncFlag flag );
+
+
+ /**
+ * @param flag The flag to be removed from the current collection of flags.
+ */
+ void removeFlag( AdDirSyncFlag flag );
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java
index b25ac9c..54836bf 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java
@@ -19,6 +19,9 @@
*/
package org.apache.directory.api.ldap.extras.controls.ad;
+import java.util.EnumSet;
+import java.util.Set;
+
/**
* The flags used in the AdDirSync response.
*
@@ -26,22 +29,32 @@
*/
public enum AdDirSyncFlag
{
- DEFAULT (0x0000),
- LDAP_DIRSYNC_OBJECT_SECURITY (0x0001),
- LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800),
- LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000),
- LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF);
+ /** The Object Security flag */
+ LDAP_DIRSYNC_OBJECT_SECURITY( 0x0001, "Object Security" ),
- /** The interned value */
- private int value;
+ /** The Ancestors First Order flag */
+ LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER( 0x0800, "Ancestors First Order" ),
- /** A private constructor that associates a value to each flag */
- private AdDirSyncFlag( int value )
+ /** The Public Data Only flag */
+ LDAP_DIRSYNC_PUBLIC_DATA_ONLY( 0x2000, "Public Data Only" ),
+
+ /** The Incremental Values flag */
+ LDAP_DIRSYNC_INCREMENTAL_VALUES( 0x80000000, "Incremental Values" );
+
+ /** The int value */
+ private int value;
+
+ /** The string description **/
+ private String description;
+
+ /** A private constructor that associates a value and description to each flag */
+ AdDirSyncFlag( int value, String description )
{
this.value = value;
+ this.description = description;
}
-
-
+
+
/**
* @return The associated value of a given flag
*/
@@ -49,23 +62,50 @@
{
return value;
}
-
-
+
+
/**
- * Get back the flag associated with a given value
- * @param value The integer value
- * @return The associated flag
+ * @see Object#toString()
*/
- public static AdDirSyncFlag getFlag( int value )
+ @Override
+ public String toString()
{
- switch ( value )
+ return this.description;
+ }
+
+
+ /**
+ * Get back the combination of flags associated with a given value
+ * @param value The integer value
+ * @return a set of all flags associated with the integer value
+ */
+ public static Set<AdDirSyncFlag> getFlags( int value )
+ {
+ EnumSet<AdDirSyncFlag> result = EnumSet.noneOf( AdDirSyncFlag.class );
+ for ( AdDirSyncFlag flag : EnumSet.allOf( AdDirSyncFlag.class ) )
{
- case 0x0000 : return DEFAULT;
- case 0x0001 : return LDAP_DIRSYNC_OBJECT_SECURITY;
- case 0x0800 : return LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER;
- case 0x2000 : return LDAP_DIRSYNC_PUBLIC_DATA_ONLY;
- case 0x7FFFFFFF : return LDAP_DIRSYNC_INCREMENTAL_VALUES;
- default : return null;
+ if ( ( flag.getValue() & value ) == flag.getValue() )
+ {
+ result.add( flag );
+ }
}
+ return result;
+ }
+
+ /**
+ * Get back the bitmask (as an integer) associated with the given flags
+ * @param flags The AdDirSync flags
+ * @return a bitmask in integer form associated with the set of flags
+ */
+ public static int getBitmask( Set<AdDirSyncFlag> flags )
+ {
+ int mask = 0;
+
+ for ( AdDirSyncFlag flag : flags )
+ {
+ mask += flag.getValue();
+ }
+
+ return mask;
}
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
index 23f651a..f2ac998 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
@@ -21,6 +21,8 @@
package org.apache.directory.api.ldap.extras.controls.ad;
import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Set;
import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
import org.apache.directory.api.util.Strings;
@@ -32,14 +34,12 @@
*/
public class AdDirSyncImpl extends AbstractControl implements AdDirSync
{
- /** A flag used to tell the server to return the parent before the children */
- int parentFirst = 1;
-
- /** A flag used to indicate that there are more data to return */
- AdDirSyncFlag flag = AdDirSyncFlag.DEFAULT;
+ /** Flags used to control return values (client-to-server) or indicate that there are more data to return (server-to-client) */
+ private Set<AdDirSyncFlag> flags = EnumSet.noneOf( AdDirSyncFlag.class );
+
/** The maximum number of attributes to return */
- int maxReturnLength = 0;
+ private int maxReturnLength = 0;
/** The DirSync cookie */
private byte[] cookie;
@@ -52,46 +52,51 @@
super( OID, Boolean.TRUE );
}
-
- /**
- * {@inheritDoc}
- */
- public int getParentFirst()
- {
- return parentFirst;
- }
-
/**
* {@inheritDoc}
*/
- public void setParentFirst( int parentFirst )
+ @Override
+ public Set<AdDirSyncFlag> getFlags()
{
- this.parentFirst = parentFirst;
+ return flags;
}
/**
* {@inheritDoc}
*/
- public AdDirSyncFlag getFlag()
+ @Override
+ public void setFlags( Set<AdDirSyncFlag> flags )
{
- return flag;
+ this.flags = flags;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addFlag( AdDirSyncFlag flag )
+ {
+ flags.add( flag );
}
/**
* {@inheritDoc}
*/
- public void setFlag( AdDirSyncFlag flag )
+ @Override
+ public void removeFlag( AdDirSyncFlag flag )
{
- this.flag = flag;
+ flags.remove( flag );
}
/**
* {@inheritDoc}
*/
+ @Override
public int getMaxReturnLength()
{
return maxReturnLength;
@@ -101,6 +106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMaxReturnLength( int maxReturnLength )
{
this.maxReturnLength = maxReturnLength;
@@ -110,6 +116,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return cookie;
@@ -119,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
if ( cookie != null )
@@ -142,7 +150,7 @@
int h = 37;
h = h * 17 + super.hashCode();
- h = h * 17 + parentFirst;
+ h = h * 17 + AdDirSyncFlag.getBitmask( flags );
h = h * 17 + maxReturnLength;
if ( cookie != null )
@@ -176,7 +184,7 @@
AdDirSync otherControl = ( AdDirSync ) o;
return ( maxReturnLength == otherControl.getMaxReturnLength() )
- && ( parentFirst == otherControl.getParentFirst() )
+ && ( flags.equals( otherControl.getFlags() ) )
&& ( Arrays.equals( cookie, otherControl.getCookie() ) )
&& ( isCritical() == otherControl.isCritical() );
}
@@ -193,7 +201,8 @@
sb.append( " DirSync control :\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
sb.append( " critical : " ).append( isCritical() ).append( '\n' );
- sb.append( " parentFirst : '" ).append( getParentFirst() ).append( "'\n" );
+ sb.append( " flags : 0x" ).append( Integer.toHexString( AdDirSyncFlag.getBitmask( flags ) ) )
+ .append( ' ' ).append( flags.toString() ).append( "\n" );
sb.append( " maxReturnLength : '" ).append( getMaxReturnLength() ).append( "'\n" );
sb.append( " cookie : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyErrorEnum.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyErrorEnum.java
index 86d7fff..e9db930 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyErrorEnum.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyErrorEnum.java
@@ -22,32 +22,54 @@
/**
- * constants representing PasswordPolicyErrorS as stated in the <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy-10">draft</a>
+ * Constants representing PasswordPolicyErrors as stated in the <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy-10">draft</a>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum PasswordPolicyErrorEnum
{
+ /** The password has expired */
PASSWORD_EXPIRED(0),
+
+ /** The account is locked */
ACCOUNT_LOCKED(1),
+
+ /** */
CHANGE_AFTER_RESET(2),
+
+ /** the password modification is not allowed */
PASSWORD_MOD_NOT_ALLOWED(3),
- MUST_SUPPLY_OLD_PASSWORD(
- 4),
+
+ /** The ld password must be supplied */
+ MUST_SUPPLY_OLD_PASSWORD(4),
+
+ /** The password quality is not sufficient */
INSUFFICIENT_PASSWORD_QUALITY(5),
+
+ /** The password is too short */
PASSWORD_TOO_SHORT(6),
+
+ /** The password has been changed too recently to be used */
PASSWORD_TOO_YOUNG(7),
+
+ /** The password is in history */
PASSWORD_IN_HISTORY(8);
private int value;
- private PasswordPolicyErrorEnum( int value )
+ PasswordPolicyErrorEnum( int value )
{
this.value = value;
}
+ /**
+ * Get the PasswordPolicyErrorEnum gien its numeric value
+ *
+ * @param val The numeric value to retrieve
+ * @return The associated PasswordPolicyErrorEnum
+ */
public static PasswordPolicyErrorEnum get( int val )
{
switch ( val )
@@ -86,9 +108,11 @@
}
+ /**
+ * @return the PasswordPolicyError interned value
+ */
public int getValue()
{
return value;
}
-
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyImpl.java
index bae7f45..e4a6595 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyImpl.java
@@ -79,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PasswordPolicy.OID;
@@ -88,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isCritical()
{
return criticality;
@@ -97,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCritical( boolean isCritical )
{
this.criticality = isCritical;
@@ -107,6 +110,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void setResponse( PasswordPolicyResponse response )
{
this.response = response;
@@ -116,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasResponse()
{
return response != null;
@@ -126,6 +131,7 @@
*
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyResponse setResponse( boolean hasResponse )
{
PasswordPolicyResponse old = this.response;
@@ -146,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyResponse getResponse()
{
return response;
@@ -157,6 +164,7 @@
*
* @return A BindResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyResponseImpl.java
index d04203d..1a2304a 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyResponseImpl.java
@@ -41,6 +41,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeBeforeExpiration()
{
return timeBeforeExpiration;
@@ -50,6 +51,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeBeforeExpiration( int timeBeforeExpiration )
{
this.timeBeforeExpiration = timeBeforeExpiration;
@@ -59,6 +61,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getGraceAuthNRemaining()
{
return graceAuthNRemaining;
@@ -68,6 +71,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setGraceAuthNRemaining( int graceAuthNRemaining )
{
this.graceAuthNRemaining = graceAuthNRemaining;
@@ -77,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyErrorEnum getPasswordPolicyError()
{
return ppolicyError;
@@ -86,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setPasswordPolicyError( PasswordPolicyErrorEnum ppolicyError )
{
this.ppolicyError = ppolicyError;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
index 3ae65b8..14b83dd 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
@@ -65,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return cookie;
@@ -74,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
@@ -83,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDeletes()
{
return refreshDeletes;
@@ -92,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDeletes( boolean refreshDeletes )
{
this.refreshDeletes = refreshDeletes;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
index b928f95..456a9b2 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
@@ -76,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SynchronizationInfoEnum getType()
{
return type;
@@ -85,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setType( SynchronizationInfoEnum type )
{
this.type = type;
@@ -94,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return cookie;
@@ -103,6 +106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
@@ -112,6 +116,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDone()
{
return refreshDone;
@@ -121,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDone( boolean refreshDone )
{
this.refreshDone = refreshDone;
@@ -130,6 +136,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDeletes()
{
return refreshDeletes;
@@ -139,6 +146,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDeletes( boolean refreshDeletes )
{
this.refreshDeletes = refreshDeletes;
@@ -148,6 +156,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<byte[]> getSyncUUIDs()
{
return syncUUIDs;
@@ -157,6 +166,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSyncUUIDs( List<byte[]> syncUUIDs )
{
this.syncUUIDs = syncUUIDs;
@@ -166,11 +176,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addSyncUUID( byte[] syncUUID )
{
if ( syncUUIDs == null )
{
- syncUUIDs = new ArrayList<byte[]>();
+ syncUUIDs = new ArrayList<>();
}
syncUUIDs.add( syncUUID );
@@ -333,7 +344,7 @@
sb.append( " refreshDeletes : " ).append( isRefreshDeletes() ).append( '\n' );
sb.append( " syncUUIDS : " );
- if ( getSyncUUIDs().size() != 0 )
+ if ( !getSyncUUIDs().isEmpty() )
{
boolean isFirst = true;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
index 1b3a0f0..398ae8b 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
@@ -91,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return this.cookie;
@@ -100,6 +101,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
@@ -109,6 +111,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SynchronizationModeEnum getMode()
{
return mode;
@@ -118,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMode( SynchronizationModeEnum mode )
{
this.mode = mode;
@@ -127,6 +131,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReloadHint()
{
return isReloadHint;
@@ -136,6 +141,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReloadHint( boolean reloadHint )
{
this.isReloadHint = reloadHint;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SynchronizationInfoEnum.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SynchronizationInfoEnum.java
index f41334f..6d8009a 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SynchronizationInfoEnum.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SynchronizationInfoEnum.java
@@ -35,9 +35,16 @@
*/
public enum SynchronizationInfoEnum
{
+ /** A new cookie */
NEW_COOKIE(0),
+
+ /** The refresh delete phase */
REFRESH_DELETE(1),
+
+ /** The refresh present phase */
REFRESH_PRESENT(2),
+
+ /** The sync ID set */
SYNC_ID_SET(3);
/** The internal value */
@@ -50,7 +57,7 @@
*
* @param value the integer value of the enumeration.
*/
- private SynchronizationInfoEnum( int value )
+ SynchronizationInfoEnum( int value )
{
this.value = value;
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateTypeEnum.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateTypeEnum.java
index 0b63f78..18d6c9e 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateTypeEnum.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateTypeEnum.java
@@ -41,7 +41,20 @@
*/
public enum SyncStateTypeEnum
{
- PRESENT(0), ADD(1), MODIFY(2), DELETE(3), MODDN(4);
+ /** The entry is present */
+ PRESENT(0),
+
+ /** The entry has been added */
+ ADD(1),
+
+ /** The entry has been modified */
+ MODIFY(2),
+
+ /** The entry has been deleted */
+ DELETE(3),
+
+ /** The entry has been renamed */
+ MODDN(4);
/** the internal value */
private int value;
@@ -53,7 +66,7 @@
*
* @param value the integer value of the enumeration.
*/
- private SyncStateTypeEnum( int value )
+ SyncStateTypeEnum( int value )
{
this.value = value;
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
index d3f0e87..b37cddf 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
@@ -68,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return cookie;
@@ -77,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
@@ -86,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncStateTypeEnum getSyncStateType()
{
return type;
@@ -95,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSyncStateType( SyncStateTypeEnum syncStateType )
{
this.type = syncStateType;
@@ -104,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getEntryUUID()
{
return entryUuid;
@@ -113,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setEntryUUID( byte[] entryUUID )
{
this.entryUuid = entryUUID;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
index fc17bb5..a15248d 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
@@ -262,9 +262,10 @@
/**
* Return a String representing this VirtualListViewRequestImpl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Virtual List View Request Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java
index fa828e5..2fed285 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java
@@ -56,26 +56,58 @@
String OID = "2.16.840.1.113730.3.4.10";
+ /**
+ * @return the position in the list of entries
+ */
int getTargetPosition();
+ /**
+ * Sets the position in the list of entries
+ *
+ * @param targetPosition the position in the list of entries
+ */
void setTargetPosition( int targetPosition );
+ /**
+ * @return The number of returned entries
+ */
int getContentCount();
+ /**
+ * Sets the number of returned entries
+ *
+ * @param contentCount The number of returned entries
+ */
void setContentCount( int contentCount );
+ /**
+ * @return The VLV result
+ */
VirtualListViewResultCode getVirtualListViewResult();
+ /**
+ * Store the VLV result
+ *
+ * @param virtualListViewResultCode The result
+ */
void setVirtualListViewResult( VirtualListViewResultCode virtualListViewResultCode );
+ /**
+ * @return The context ID
+ */
byte[] getContextId();
+ /**
+ * Sets the context ID
+ *
+ * @param contextId The context ID
+ */
void setContextId( byte[] contextId );
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
index ac9e30a..ba06c69 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
@@ -59,6 +59,9 @@
private byte[] contextId;
+ /**
+ * Creates a new VirtualListViewResponseImpl instance
+ */
public VirtualListViewResponseImpl()
{
super( OID );
@@ -168,9 +171,10 @@
/**
* Return a String representing this VirtualListViewResponseImpl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Virtual List View Response Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java
index f4610f4..d15c422 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java
@@ -28,28 +28,40 @@
*/
public enum VirtualListViewResultCode
{
+ /** A success */
SUCCESS(0, "Success"),
+ /** The operation failed dur to some internal error */
OPERATIONSERROR(1, "Server internal failure"),
+ /** teh time limit has been exceeded */
TIMELIMITEXCEEDED(3, "Timelimit exceeded"),
+ /** The admin limit has been exceeded */
ADMINLIMITEXCEEDED(11, "Admin limit exceeded"),
+ /** The matching rule is inappropriate */
INAPPROPRIATEMATCHING(18, "Unrecognized or inappropriate matching rule"),
+ /** The access right are insufficient */
INSUFFICIENTACCESSRIGHTS(50, "Insufficient access rights"),
+ /** Unwilling to perform the operation */
UNWILLINGTOPERFORM(53, "Unwilling to perform"),
+ /** No Sort Control provided */
SORTCONTROLMISSING(60, "Sort control missing"),
+ /** The offset is incorrect */
OFFSETRANGEERROR(61, "Offset range error"),
+ /** SS is missing */
OPENLDAP_SSSMISSING(76, "SSS missing"), // OpenLDAP-specific error code
+ /** The range is invalid */
OPENLDAP_RANGEERRROR(77, "Range error"), // OpenLDAP-specific error code
+ /** Another error */
OTHER(80, "Other");
/** The associated value */
@@ -59,7 +71,7 @@
private String desc;
- private VirtualListViewResultCode( int value, String desc )
+ VirtualListViewResultCode( int value, String desc )
{
this.value = value;
this.desc = desc;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelRequestImpl.java
index e577105..cd7493e 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelRequestImpl.java
@@ -65,18 +65,21 @@
}
+ @Override
public int getCancelId()
{
return cancelId;
}
+ @Override
public void setCancelId( int cancelId )
{
this.cancelId = cancelId;
}
+ @Override
public CancelResponse getResultResponse()
{
if ( getResponse() == null )
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
index 47b1737..caaadd2 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
@@ -34,8 +34,9 @@
public class CancelResponseImpl extends ExtendedResponseImpl implements CancelResponse
{
/**
- * Create a new CancelResponse object
- * @param messageId The messageId
+ * Create a new CancelResponse instance
+ *
+ * @param messageId The request's messageId
* @param rcode the result code
*/
public CancelResponseImpl( int messageId, ResultCodeEnum rcode )
@@ -61,6 +62,11 @@
}
+ /**
+ * Create a new CancelResponse instance
+ *
+ * @param messageId The request's messageId
+ */
public CancelResponseImpl( int messageId )
{
super( messageId );
@@ -69,6 +75,9 @@
}
+ /**
+ * Create a new CancelResponse instance
+ */
public CancelResponseImpl()
{
super( CancelRequest.EXTENSION_OID );
@@ -83,6 +92,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return "";
@@ -114,6 +124,6 @@
return true;
}
- return ( obj instanceof CancelResponseImpl );
+ return obj instanceof CancelResponseImpl;
}
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequest.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequest.java
index 1842ad2..9accc30 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequest.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequest.java
@@ -42,24 +42,52 @@
String getTargetDN();
+ /**
+ * Sets the target DN
+ *
+ * @param targetDN The target DN
+ */
void setTargetDN( String targetDN );
+ /**
+ * @return The issuer's DN
+ */
String getIssuerDN();
+ /**
+ * Sets the issuer's DN
+ *
+ * @param issuerDN the issuer's DN
+ */
void setIssuerDN( String issuerDN );
+ /**
+ * @return The subect's DN
+ */
String getSubjectDN();
+ /**
+ * Sets the subect's DN
+ *
+ * @param subjectDN The subect's DN
+ */
void setSubjectDN( String subjectDN );
+ /**
+ * @return The Key algorithm
+ */
String getKeyAlgorithm();
+ /**
+ * Sets the Key algorithm
+ * @param keyAlgorithm The Key algorithm
+ */
void setKeyAlgorithm( String keyAlgorithm );
}
\ No newline at end of file
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequestImpl.java
index d34a2bf..cb44664 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationRequestImpl.java
@@ -79,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getTargetDN()
{
return targetDN;
@@ -88,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTargetDN( String targetDN )
{
this.targetDN = targetDN;
@@ -97,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getIssuerDN()
{
return issuerDN;
@@ -106,6 +109,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setIssuerDN( String issuerDN )
{
this.issuerDN = issuerDN;
@@ -115,6 +119,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSubjectDN()
{
return subjectDN;
@@ -124,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSubjectDN( String subjectDN )
{
this.subjectDN = subjectDN;
@@ -133,6 +139,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getKeyAlgorithm()
{
return keyAlgorithm;
@@ -142,6 +149,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setKeyAlgorithm( String keyAlgorithm )
{
this.keyAlgorithm = keyAlgorithm;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
index b349ef1..77dd0c0 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
@@ -33,6 +33,12 @@
*/
public class CertGenerationResponseImpl extends ExtendedResponseImpl implements CertGenerationResponse
{
+ /**
+ * Create a new CertGenerationResponseImpl instance
+ *
+ * @param messageId The request's message ID
+ * @param rcode The result code
+ */
public CertGenerationResponseImpl( int messageId, ResultCodeEnum rcode )
{
super( messageId, EXTENSION_OID );
@@ -54,6 +60,11 @@
}
+ /**
+ * Create a new CertGenerationResponseImpl instance
+ *
+ * @param messageId The request's message ID
+ */
public CertGenerationResponseImpl( int messageId )
{
super( messageId, EXTENSION_OID );
@@ -62,6 +73,9 @@
}
+ /**
+ * Create a new CertGenerationResponseImpl instance
+ */
public CertGenerationResponseImpl()
{
super( EXTENSION_OID );
@@ -76,6 +90,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return EXTENSION_OID;
@@ -89,6 +104,7 @@
* @param oid
* the OID of the extended response type.
*/
+ @Override
public void setResponseName( String oid )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
@@ -120,6 +136,6 @@
return true;
}
- return ( obj instanceof CertGenerationResponseImpl );
+ return obj instanceof CertGenerationResponseImpl;
}
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
index 504063a..cfdce97 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
@@ -70,7 +70,7 @@
this.timeOffline = timeOffline;
this.delay = delay;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append( "The server will disconnect and will be unavailable for " ).append( timeOffline );
buf.append( " minutes in " ).append( delay ).append( " seconds." );
@@ -86,6 +86,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return EXTENSION_OID;
@@ -98,6 +99,7 @@
*
* @param oid the OID of the extended response type.
*/
+ @Override
public void setResponseName( String oid )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
@@ -110,6 +112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getDelay()
{
return delay;
@@ -119,6 +122,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDelay( int delay )
{
this.delay = delay;
@@ -128,6 +132,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeOffline()
{
return timeOffline;
@@ -137,12 +142,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOffline( int timeOffline )
{
this.timeOffline = timeOffline;
}
+ @Override
public Referral getReplicatedContexts()
{
return replicatedContexts;
@@ -153,6 +160,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addReplicatedContexts( String replicatedContext )
{
replicatedContexts.addLdapUrl( replicatedContext );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownRequestImpl.java
index 8775828..5f7cfd8 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownRequestImpl.java
@@ -84,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getDelay()
{
return delay;
@@ -93,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDelay( int delay )
{
this.delay = delay;
@@ -102,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeOffline()
{
return timeOffline;
@@ -111,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOffline( int timeOffline )
{
this.timeOffline = timeOffline;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
index fea5533..1dab8ab 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
@@ -47,11 +47,7 @@
switch ( rcode )
{
case SUCCESS:
- break;
-
case OPERATIONS_ERROR:
- break;
-
case INSUFFICIENT_ACCESS_RIGHTS:
break;
@@ -99,6 +95,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return EXTENSION_OID;
@@ -112,6 +109,7 @@
* @param oid
* the OID of the extended response type.
*/
+ @Override
public void setResponseName( String oid )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
@@ -143,6 +141,6 @@
return true;
}
- return ( obj instanceof GracefulShutdownResponseImpl );
+ return obj instanceof GracefulShutdownResponseImpl;
}
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyRequestImpl.java
index aa87dff..8ff1cc7 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyRequestImpl.java
@@ -72,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getUserIdentity()
{
return userIdentity;
@@ -81,6 +82,7 @@
/**
* @param userIdentity the userIdentity to set
*/
+ @Override
public void setUserIdentity( byte[] userIdentity )
{
this.userIdentity = userIdentity;
@@ -90,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getOldPassword()
{
return oldPassword;
@@ -99,6 +102,7 @@
/**
* @param oldPassword the oldPassword to set
*/
+ @Override
public void setOldPassword( byte[] oldPassword )
{
this.oldPassword = oldPassword;
@@ -108,6 +112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getNewPassword()
{
return newPassword;
@@ -117,6 +122,7 @@
/**
* @param newPassword the newPassword to set
*/
+ @Override
public void setNewPassword( byte[] newPassword )
{
this.newPassword = newPassword;
@@ -141,6 +147,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
index dbb9162..3d9666b 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
@@ -98,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getGenPassword()
{
return genPassword;
@@ -117,6 +118,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsRequestImpl.java
index 60cd599..a81bcab 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsRequestImpl.java
@@ -69,6 +69,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "StartTLS extended request";
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
index 4cdb821..a2f7294 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
@@ -88,6 +88,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequest.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequest.java
index e68c165..80fb198 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequest.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequest.java
@@ -125,8 +125,16 @@
void addParameter( Object type, Object value );
+ /**
+ * Adds a parameter
+ *
+ * @param parameter The parameter to add
+ */
void addParameter( StoredProcedureParameter parameter );
+ /**
+ * @return The list of parameters for this stored procedure
+ */
List<StoredProcedureParameter> getParameters();
}
\ No newline at end of file
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequestImpl.java
index 28c6d08..57b0a1f 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureRequestImpl.java
@@ -28,7 +28,6 @@
import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.apache.directory.api.util.exception.NotImplementedException;
@@ -42,9 +41,9 @@
{
private String language = "Java";
- private byte[] procedure = StringConstants.EMPTY_BYTES;
+ private byte[] procedure = Strings.EMPTY_BYTES;
- private List<StoredProcedureParameter> parameters = new ArrayList<StoredProcedureParameter>();
+ private List<StoredProcedureParameter> parameters = new ArrayList<>();
/**
@@ -91,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getLanguage()
{
return language;
@@ -100,12 +100,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setLanguage( String language )
{
this.language = language;
}
+ @Override
public byte[] getProcedure()
{
if ( procedure == null )
@@ -119,6 +121,7 @@
}
+ @Override
public void setProcedure( byte[] procedure )
{
if ( procedure != null )
@@ -133,12 +136,14 @@
}
+ @Override
public List<StoredProcedureParameter> getParameters()
{
return parameters;
}
+ @Override
public void addParameter( StoredProcedureParameter parameter )
{
parameters.add( parameter );
@@ -146,7 +151,9 @@
/**
- * {@inheritDoc}
+ * Store the procedure's name
+ *
+ * @param procedure The procedure's name
*/
public void setProcedure( String procedure )
{
@@ -157,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getProcedureSpecification()
{
return Strings.utf8ToString( procedure );
@@ -166,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return parameters.size();
@@ -175,9 +184,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object getParameterType( int index )
{
- if ( !language.equals( "java" ) )
+ if ( !"java".equals( language ) )
{
return parameters.get( index ).getType();
}
@@ -187,11 +197,14 @@
/**
- * {@inheritDoc}
+ * Get the parameter type
+ *
+ * @param index The parameter position in the list of parameters
+ * @return The found parameter type
*/
public Object getParameterTypeString( int index )
{
- if ( !language.equals( "java" ) )
+ if ( !"java".equals( language ) )
{
Object obj = parameters.get( index ).getType();
@@ -208,6 +221,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Class<?> getJavaParameterType( int index )
{
throw new NotImplementedException( I18n.err( I18n.ERR_04175 ) );
@@ -217,9 +231,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object getParameterValue( int index )
{
- if ( !language.equals( "java" ) )
+ if ( !"java".equals( language ) )
{
return parameters.get( index ).getValue();
}
@@ -229,11 +244,14 @@
/**
- * {@inheritDoc}
+ * Get a parameter value
+ *
+ * @param index The position of the parameter in the list of parameters
+ * @return The paremeter's value
*/
public Object getParameterValueString( int index )
{
- if ( !language.equals( "java" ) )
+ if ( !"java".equals( language ) )
{
Object obj = parameters.get( index ).getValue();
@@ -242,7 +260,7 @@
String str = Strings.utf8ToString( ( byte[] ) obj );
String type = ( String ) getParameterTypeString( index );
- if ( type.equals( "int" ) )
+ if ( "int".equals( type ) )
{
try
{
@@ -268,6 +286,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object getJavaParameterValue( int index )
{
throw new NotImplementedException( I18n.err( I18n.ERR_04176 ) );
@@ -277,6 +296,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addParameter( Object type, Object value )
{
/**
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIRequestImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIRequestImpl.java
index 3e0c7f9..7fc0587 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIRequestImpl.java
@@ -69,6 +69,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "Who Am I extended request";
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
index d0ab435..680ce30 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
@@ -104,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getAuthzId()
{
return authzId;
@@ -113,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setAuthzId( byte[] authzId )
{
this.authzId = authzId;
@@ -122,22 +124,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDnAuthzId()
{
- if ( dn != null )
- {
- return true;
- }
- else
- {
- return false;
- }
+ return dn != null;
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isUserAuthzId()
{
return userId != null;
@@ -147,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getAuthzIdString()
{
return Strings.utf8ToString( authzId );
@@ -156,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getUserId()
{
return userId;
@@ -176,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getDn()
{
return dn;
@@ -196,6 +196,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/extras/codec/pom.xml b/ldap/extras/codec/pom.xml
index cbd2460..42b1a99 100644
--- a/ldap/extras/codec/pom.xml
+++ b/ldap/extras/codec/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-codec</artifactId>
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
index 75bbf09..7bf4c6e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
@@ -84,7 +84,7 @@
private BundleContext context;
- public LdapApiServiceTracker( BundleContext context )
+ LdapApiServiceTracker( BundleContext context )
{
this.context = context;
}
@@ -113,133 +113,132 @@
unregisterExtrasExtendedOps( ldapApiService );
}
+
+ /**
+ * Registers all the extras extended operations present in this control pack.
+ *
+ * @param codec The codec service.
+ */
+ private void registerExtrasExtendedOps( LdapApiService codec )
+ {
+ // --------------------------------------------------------------------
+ // Register Extended Request Factories
+ // --------------------------------------------------------------------
+
+ CancelFactory cancelFactory = new CancelFactory( codec );
+ codec.registerExtendedRequest( cancelFactory );
+
+ CertGenerationFactory certGenerationFactory = new CertGenerationFactory( codec );
+ codec.registerExtendedRequest( certGenerationFactory );
+
+ GracefulShutdownFactory gracefulShutdownFactory = new GracefulShutdownFactory( codec );
+ codec.registerExtendedRequest( gracefulShutdownFactory );
+
+ StoredProcedureFactory storedProcedureFactory = new StoredProcedureFactory( codec );
+ codec.registerExtendedRequest( storedProcedureFactory );
+
+ PasswordModifyFactory passwordModifyFactory = new PasswordModifyFactory( codec );
+ codec.registerExtendedRequest( passwordModifyFactory );
+
+ GracefulDisconnectFactory gracefulDisconnectFactory = new GracefulDisconnectFactory( codec );
+ codec.registerExtendedRequest( gracefulDisconnectFactory );
+
+ WhoAmIFactory whoAmIFactory = new WhoAmIFactory( codec );
+ codec.registerExtendedRequest( whoAmIFactory );
+
+ StartTlsFactory startTlsFactory = new StartTlsFactory( codec );
+ codec.registerExtendedRequest( startTlsFactory );
+ }
+
+
+ private void unregisterExtrasControls( LdapApiService codec )
+ {
+ codec.unregisterControl( SyncDoneValue.OID );
+ codec.unregisterControl( SyncInfoValue.OID );
+ codec.unregisterControl( SyncRequestValue.OID );
+ codec.unregisterControl( SyncStateValue.OID );
+ codec.unregisterControl( PasswordPolicy.OID );
+ codec.unregisterControl( AdDirSync.OID );
+ codec.unregisterControl( AdShowDeleted.OID );
+ }
+
+
+ private void unregisterExtrasExtendedOps( LdapApiService codec )
+ {
+ codec.unregisterExtendedRequest( CancelRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( CertGenerationRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( GracefulShutdownRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( StoredProcedureRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( GracefulDisconnectResponse.EXTENSION_OID );
+ codec.unregisterExtendedRequest( PasswordModifyRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( WhoAmIRequest.EXTENSION_OID );
+ codec.unregisterExtendedRequest( StartTlsRequest.EXTENSION_OID );
+ }
+
+
+ /**
+ * Registers all the extras controls present in this control pack.
+ *
+ * @param codec The codec service.
+ */
+ private void registerExtrasControls( LdapApiService codec )
+ {
+ ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( codec );
+ codec.registerControl( adDirSyncFactory );
+
+ ControlFactory<AdShowDeleted> adDeletedFactory = new AdShowDeletedFactory( codec );
+ codec.registerControl( adDeletedFactory );
+
+ ControlFactory<ChangeNotifications> changeNotificationsFactory = new ChangeNotificationsFactory( codec );
+ codec.registerControl( changeNotificationsFactory );
+
+ ControlFactory<PasswordPolicy> passwordPolicyFactory = new PasswordPolicyFactory( codec );
+ codec.registerControl( passwordPolicyFactory );
+
+ ControlFactory<PermissiveModify> permissiveModifyFactory = new PermissiveModifyFactory( codec );
+ codec.registerControl( permissiveModifyFactory );
+
+ ControlFactory<SyncDoneValue> syncDoneValuefactory = new SyncDoneValueFactory( codec );
+ codec.registerControl( syncDoneValuefactory );
+
+ ControlFactory<SyncInfoValue> syncInfoValueFactory = new SyncInfoValueFactory( codec );
+ codec.registerControl( syncInfoValueFactory );
+
+ ControlFactory<SyncRequestValue> syncRequestValueFactory = new SyncRequestValueFactory( codec );
+ codec.registerControl( syncRequestValueFactory );
+
+ ControlFactory<SyncStateValue> syncStateValuefactory = new SyncStateValueFactory( codec );
+ codec.registerControl( syncStateValuefactory );
+
+ ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory( codec );
+ codec.registerControl( virtualListViewRequestFactory );
+
+ ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
+ codec );
+ codec.registerControl( virtualListViewResponseFactory );
+ }
}
/**
* {@inheritDoc}
*/
+ @Override
public void start( BundleContext context ) throws Exception
{
LdapApiServiceTracker ldapApiServiceTracker = new LdapApiServiceTracker( context );
- serviceTracker = new ServiceTracker<LdapApiService, LdapApiService>(
+ serviceTracker = new ServiceTracker<>(
context, LdapApiService.class, ldapApiServiceTracker );
serviceTracker.open();
}
/**
- * Registers all the extras controls present in this control pack.
- *
- * @param codec The codec service.
- */
- private void registerExtrasControls( LdapApiService codec )
- {
- ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( codec );
- codec.registerControl( adDirSyncFactory );
-
- ControlFactory<AdShowDeleted> adDeletedFactory = new AdShowDeletedFactory( codec );
- codec.registerControl( adDeletedFactory );
-
- ControlFactory<ChangeNotifications> changeNotificationsFactory = new ChangeNotificationsFactory( codec );
- codec.registerControl( changeNotificationsFactory );
-
- ControlFactory<PasswordPolicy> passwordPolicyFactory = new PasswordPolicyFactory( codec );
- codec.registerControl( passwordPolicyFactory );
-
- ControlFactory<PermissiveModify> permissiveModifyFactory = new PermissiveModifyFactory( codec );
- codec.registerControl( permissiveModifyFactory );
-
- ControlFactory<SyncDoneValue> syncDoneValuefactory = new SyncDoneValueFactory( codec );
- codec.registerControl( syncDoneValuefactory );
-
- ControlFactory<SyncInfoValue> syncInfoValueFactory = new SyncInfoValueFactory( codec );
- codec.registerControl( syncInfoValueFactory );
-
- ControlFactory<SyncRequestValue> syncRequestValueFactory = new SyncRequestValueFactory( codec );
- codec.registerControl( syncRequestValueFactory );
-
- ControlFactory<SyncStateValue> syncStateValuefactory = new SyncStateValueFactory( codec );
- codec.registerControl( syncStateValuefactory );
-
- ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory( codec );
- codec.registerControl( virtualListViewRequestFactory );
-
- ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
- codec );
- codec.registerControl( virtualListViewResponseFactory );
-
-
- }
-
-
- /**
- * Registers all the extras extended operations present in this control pack.
- *
- * @param codec The codec service.
- */
- private void registerExtrasExtendedOps( LdapApiService codec )
- {
- // --------------------------------------------------------------------
- // Register Extended Request Factories
- // --------------------------------------------------------------------
-
- CancelFactory cancelFactory = new CancelFactory( codec );
- codec.registerExtendedRequest( cancelFactory );
-
- CertGenerationFactory certGenerationFactory = new CertGenerationFactory( codec );
- codec.registerExtendedRequest( certGenerationFactory );
-
- GracefulShutdownFactory gracefulShutdownFactory = new GracefulShutdownFactory( codec );
- codec.registerExtendedRequest( gracefulShutdownFactory );
-
- StoredProcedureFactory storedProcedureFactory = new StoredProcedureFactory( codec );
- codec.registerExtendedRequest( storedProcedureFactory );
-
- PasswordModifyFactory passwordModifyFactory = new PasswordModifyFactory( codec );
- codec.registerExtendedRequest( passwordModifyFactory );
-
- GracefulDisconnectFactory gracefulDisconnectFactory = new GracefulDisconnectFactory( codec );
- codec.registerExtendedRequest( gracefulDisconnectFactory );
-
- WhoAmIFactory whoAmIFactory = new WhoAmIFactory( codec );
- codec.registerExtendedRequest( whoAmIFactory );
-
- StartTlsFactory startTlsFactory = new StartTlsFactory( codec );
- codec.registerExtendedRequest( startTlsFactory );
- }
-
-
- /**
* {@inheritDoc}
*/
+ @Override
public void stop( BundleContext context ) throws Exception
{
serviceTracker.close();
}
-
-
- private void unregisterExtrasControls( LdapApiService codec )
- {
- codec.unregisterControl( SyncDoneValue.OID );
- codec.unregisterControl( SyncInfoValue.OID );
- codec.unregisterControl( SyncRequestValue.OID );
- codec.unregisterControl( SyncStateValue.OID );
- codec.unregisterControl( PasswordPolicy.OID );
- codec.unregisterControl( AdDirSync.OID );
- codec.unregisterControl( AdShowDeleted.OID );
- }
-
-
- private void unregisterExtrasExtendedOps( LdapApiService codec )
- {
- codec.unregisterExtendedRequest( CancelRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( CertGenerationRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( GracefulShutdownRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( StoredProcedureRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( GracefulDisconnectResponse.EXTENSION_OID );
- codec.unregisterExtendedRequest( PasswordModifyRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( WhoAmIRequest.EXTENSION_OID );
- codec.unregisterExtendedRequest( StartTlsRequest.EXTENSION_OID );
- }
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
index bbda665..4263c17 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
@@ -91,6 +91,9 @@
}
+ /**
+ * @return The LdapAPi service instance
+ */
public LdapApiService getCodecService()
{
return codec;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
index ad34820..6d32122 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
@@ -20,6 +20,7 @@
package org.apache.directory.api.ldap.extras.controls.ad_impl;
import java.nio.ByteBuffer;
+import java.util.Set;
import org.apache.directory.api.asn1.Asn1Object;
import org.apache.directory.api.asn1.DecoderException;
@@ -51,7 +52,7 @@
/**
- * Creates a new instance of AdDirSyncControlCodec.
+ * Creates a new instance of AdDirSyncDecorator.
*
* @param codec The LDAP Service to use
*/
@@ -76,42 +77,47 @@
/**
* {@inheritDoc}
*/
- public int getParentFirst()
+ @Override
+ public Set<AdDirSyncFlag> getFlags()
{
- return getDecorated().getParentFirst();
+ return getDecorated().getFlags();
}
/**
* {@inheritDoc}
*/
- public void setParentFirst( int parentFirst )
+ @Override
+ public void setFlags( Set<AdDirSyncFlag> flags )
{
- getDecorated().setParentFirst( parentFirst );
+ getDecorated().setFlags( flags );
}
/**
* {@inheritDoc}
*/
- public AdDirSyncFlag getFlag()
+ @Override
+ public void addFlag( AdDirSyncFlag flag )
{
- return getDecorated().getFlag();
+ getDecorated().addFlag( flag );
}
/**
* {@inheritDoc}
*/
- public void setFlag( AdDirSyncFlag flag )
+ @Override
+ public void removeFlag( AdDirSyncFlag flag )
{
- getDecorated().setFlag( flag );
+ getDecorated().removeFlag( flag );
}
/**
* {@inheritDoc}
*/
+ @Override
public int getMaxReturnLength()
{
return getDecorated().getMaxReturnLength();
@@ -121,6 +127,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMaxReturnLength( int maxReturnLength )
{
getDecorated().setMaxReturnLength( maxReturnLength );
@@ -130,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -139,6 +147,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
// Copy the bytes
@@ -160,7 +169,7 @@
* <pre>
* 0x30 L1
* |
- * +--> 0x02 0x0(1-4) nnn (parentFirst)
+ * +--> 0x02 0x0(1-4) nnn (flags)
* +--> 0x02 0x0(1-4) nnn (maxReturnLength)
* +--> 0x04 L2 xkcd!!!... (cookie)
* </pre>
@@ -168,11 +177,13 @@
@Override
public int computeLength()
{
- // the parentFirst flag length
- adDirSyncLength = 1 + TLV.getNbBytes( getParentFirst() ) + BerValue.getNbBytes( getParentFirst() );
+ // the flags length
+ int flagsLength = BerValue.getNbBytes( AdDirSyncFlag.getBitmask( getFlags() ) );
+ adDirSyncLength = 1 + TLV.getNbBytes( flagsLength ) + flagsLength;
// the maxReturnLength length
- adDirSyncLength += 1 + TLV.getNbBytes( getMaxReturnLength() ) + BerValue.getNbBytes( getMaxReturnLength() );
+ int maxReturnLengthLength = BerValue.getNbBytes( getMaxReturnLength() );
+ adDirSyncLength += 1 + TLV.getNbBytes( maxReturnLengthLength ) + maxReturnLengthLength;
// cookie's length
byte[] cookie = getCookie();
@@ -212,8 +223,8 @@
buffer.put( UniversalTag.SEQUENCE.getValue() );
buffer.put( TLV.getBytes( adDirSyncLength ) );
- // Encode the ParentFirst flag
- BerValue.encode( buffer, getParentFirst() );
+ // Encode the flags
+ BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
// Encode the MaxReturnLength
BerValue.encode( buffer, getMaxReturnLength() );
@@ -242,8 +253,8 @@
buffer.put( UniversalTag.SEQUENCE.getValue() );
buffer.put( TLV.getBytes( adDirSyncLength ) );
- // Encode the ParentFirst flag
- BerValue.encode( buffer, getParentFirst() );
+ // Encode the Flags flag
+ BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
// Encode the MaxReturnLength
BerValue.encode( buffer, getMaxReturnLength() );
@@ -266,6 +277,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
index 8ca8bbd..151388b 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return AdDirSync.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<AdDirSync> newCodecControl()
{
return new AdDirSyncDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<AdDirSync> newCodecControl( AdDirSync control )
{
return new AdDirSyncDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
index 18416bd..6772919 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
@@ -20,6 +20,8 @@
package org.apache.directory.api.ldap.extras.controls.ad_impl;
+import java.util.Set;
+
import org.apache.directory.api.asn1.DecoderException;
import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
import org.apache.directory.api.asn1.ber.grammar.Grammar;
@@ -117,9 +119,9 @@
{
int flagValue = IntegerDecoder.parse( value );
- AdDirSyncFlag flag = AdDirSyncFlag.getFlag( flagValue );
+ Set<AdDirSyncFlag> flags = AdDirSyncFlag.getFlags( flagValue );
- if ( flag == null )
+ if ( flags == null )
{
String msg = "Error while decoding the AdDirSync flag, unknown value : " + flagValue;
LOG.error( msg );
@@ -128,10 +130,10 @@
if ( IS_DEBUG )
{
- LOG.debug( "flag = {}", flagValue );
+ LOG.debug( "flags = {}", flags.toString() );
}
- container.getAdDirSyncControl().setFlag( flag );
+ container.getAdDirSyncControl().setFlags( flags );
}
catch ( IntegerDecoderException ide )
{
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
index 27c8111..aa14590 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.controls.ad_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -56,33 +55,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "AD_DIR_SYNC_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<AdDirSyncContainer> grammar )
- {
- if ( grammar instanceof AdDirSyncGrammar )
- {
- return "AD_DIR_SYNC_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -90,13 +71,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_GRAMMAR" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_GRAMMAR" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -106,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AdDirSyncStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedDecorator.java
index e4719e8..b17b374 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedDecorator.java
@@ -53,6 +53,7 @@
/**
* Returns the default control length.
*/
+ @Override
public int computeLength()
{
return 0;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedFactory.java
index e18f6c1..2259e99 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdShowDeletedFactory.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return AdShowDeleted.OID;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<AdShowDeleted> newCodecControl()
{
return new AdShowDeletedDecorator( codec, new AdShowDeletedImpl() );
@@ -71,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<AdShowDeleted> newCodecControl( AdShowDeleted control )
{
return new AdShowDeletedDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsDecorator.java
index 1f0da4f..f8fcff8 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsDecorator.java
@@ -53,6 +53,7 @@
/**
* Returns 0 every time.
*/
+ @Override
public int computeLength()
{
return 0;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
return this;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsFactory.java
index 1a336cf..6aa82c3 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/changeNotifications_impl/ChangeNotificationsFactory.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return ChangeNotifications.OID;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ChangeNotifications> newCodecControl()
{
return new ChangeNotificationsDecorator( codec, new ChangeNotificationsImpl() );
@@ -71,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<ChangeNotifications> newCodecControl( ChangeNotifications control )
{
return new ChangeNotificationsDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyDecorator.java
index 49b40b8..9ad67ee 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyDecorator.java
@@ -53,6 +53,7 @@
/**
* Returns the default control length.
*/
+ @Override
public int computeLength()
{
return 0;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyFactory.java
index b92739e..3a28652 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/permissiveModify_impl/PermissiveModifyFactory.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PermissiveModify.OID;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PermissiveModify> newCodecControl()
{
return new PermissiveModifyDecorator( codec, new PermissiveModifyImpl() );
@@ -71,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<PermissiveModify> newCodecControl( PermissiveModify control )
{
return new PermissiveModifyDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyContainer.java
index 65f530c..ba1a6fa 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyContainer.java
@@ -37,6 +37,11 @@
private PasswordPolicyDecorator control;
+ /**
+ * Creates a new StoredProcedureContainer instance
+ *
+ * @param codec The LDAP Service to use
+ */
public PasswordPolicyContainer( LdapApiService codec )
{
super();
@@ -46,6 +51,12 @@
}
+ /**
+ * Creates a new StoredProcedureContainer instance
+ *
+ * @param codec The LDAP Service to use
+ * @param ppolicyResponse The PasswordPolicy response
+ */
public PasswordPolicyContainer( LdapApiService codec, PasswordPolicy ppolicyResponse )
{
super();
@@ -64,12 +75,20 @@
}
+ /**
+ * @return The decorated PasswordPolicy control
+ */
public PasswordPolicyDecorator getPasswordPolicyResponseControl()
{
return control;
}
+ /**
+ * Sets the password policy control
+ *
+ * @param control The decorated PasswordPolicy control
+ */
public void setPasswordPolicyResponseControl( PasswordPolicyDecorator control )
{
this.control = control;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
index 9f21ced..713f978 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
@@ -52,18 +52,35 @@
private int warningLength = 0;
+ /**
+ * Creates a new instance of PasswordPolicyDecorator.
+ *
+ * @param codec The LDAP Service to use
+ */
public PasswordPolicyDecorator( LdapApiService codec )
{
super( codec, new PasswordPolicyImpl() );
}
+ /**
+ * Creates a new instance of PasswordPolicyDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param hasResponse The hasResponse flag
+ */
public PasswordPolicyDecorator( LdapApiService codec, boolean hasResponse )
{
super( codec, new PasswordPolicyImpl( hasResponse ) );
}
+ /**
+ * Creates a new instance of PasswordPolicyDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param policy The asswordPolicy to use
+ */
public PasswordPolicyDecorator( LdapApiService codec, PasswordPolicy policy )
{
super( codec, policy );
@@ -220,6 +237,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
if ( !hasResponse() )
@@ -238,6 +256,7 @@
*
* {@inheritDoc}
*/
+ @Override
public boolean hasResponse()
{
return getDecorated().hasResponse();
@@ -248,6 +267,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void setResponse( PasswordPolicyResponse response )
{
getDecorated().setResponse( response );
@@ -258,6 +278,7 @@
*
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyResponse setResponse( boolean hasResponse )
{
return getDecorated().setResponse( hasResponse );
@@ -268,6 +289,7 @@
*
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyResponse getResponse()
{
return getDecorated().getResponse();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyFactory.java
index b00e544..08e1ef0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyFactory.java
@@ -53,6 +53,7 @@
*
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PasswordPolicy.OID;
@@ -63,6 +64,7 @@
*
* {@inheritDoc}
*/
+ @Override
public CodecControl<PasswordPolicy> newCodecControl()
{
return new PasswordPolicyDecorator( codec );
@@ -73,6 +75,7 @@
*
* {@inheritDoc}
*/
+ @Override
public CodecControl<PasswordPolicy> newCodecControl( PasswordPolicy control )
{
return new PasswordPolicyDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyGrammar.java
index 990ae6e..536db13 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyGrammar.java
@@ -125,6 +125,9 @@
}
+ /**
+ * @return the singleton instance of the PasswordPolicyGrammar
+ */
public static Grammar<PasswordPolicyContainer> getInstance()
{
return INSTANCE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyStates.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyStates.java
index df3142a..1663479 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyStates.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyStates.java
@@ -21,7 +21,6 @@
package org.apache.directory.api.ldap.extras.controls.ppolicy_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -32,49 +31,55 @@
*/
public enum PasswordPolicyStates implements States
{
+ /** Initial state */
START_STATE,
+
+ /** PasswordPolicyResponseValue ::= SEQUENCE transition */
PPOLICY_SEQ_STATE,
+
+ /** warning [0] CHOICE transition */
PPOLICY_WARNING_TAG_STATE,
+
+ /** timeBeforeExpiration [0] INTEGER (0 .. maxInt) transition */
PPOLICY_TIME_BEFORE_EXPIRATION_STATE,
+
+ /** graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL transition */
PPOLICY_GRACE_AUTHNS_REMAINING_STATE,
+
+ /** error [1] ENUMERATED transition */
PPOLICY_ERROR_TAG_STATE,
+
+ /** end state */
END_STATE;
- /**
- * {@inheritDoc}
- */
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof PasswordPolicyGrammar )
- {
- return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
- }
-
- return "UNKNOWN_GRAMMAR";
- }
-
/**
- * {@inheritDoc}
+ * Get the grammar name
+ *
+ * @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
}
/**
- * {@inheritDoc}
+ * Get the string representing the state
+ *
+ * @param state The state number
+ * @return The String representing the state
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : name() );
+ return ( state == END_STATE.ordinal() ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -84,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordPolicyStates getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyTags.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyTags.java
index 2411d1b..3f6b6d4 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyTags.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyTags.java
@@ -28,25 +28,31 @@
*/
public enum PasswordPolicyTags
{
- // warning [0]
+ /** warning [0] */
PPOLICY_WARNING_TAG(0xA0),
- // error [1]
+
+ /** error [1] */
PPOLICY_ERROR_TAG(0x81),
- // timeBeforeExpiration [0]
+
+ /** timeBeforeExpiration [0] */
TIME_BEFORE_EXPIRATION_TAG(0x80),
- // graceAuthNsRemaining [1]
+
+ /** graceAuthNsRemaining [1] */
GRACE_AUTHNS_REMAINING_TAG(0x81);
/** Internal value for each tag */
private int value;
- private PasswordPolicyTags( int value )
+ PasswordPolicyTags( int value )
{
this.value = value;
}
+ /**
+ * @return The numeric value associated with the PasswordPolicy tag
+ */
public int getValue()
{
return value;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/StoreError.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/StoreError.java
index 213a003..08d242a 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/StoreError.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/StoreError.java
@@ -28,6 +28,8 @@
/**
* The action used to store the error
*
+ * @param <C> The container type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class StoreError<C extends Asn1Container> extends AbstractReadInteger<C>
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueContainer.java
index 5e020c7..527e33b 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueContainer.java
@@ -91,6 +91,9 @@
}
+ /**
+ * @return The LDAP API service
+ */
public LdapApiService getCodecService()
{
return codec;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueDecorator.java
index 0739dc6..dae0e98 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueDecorator.java
@@ -182,6 +182,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -191,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
// Copy the bytes
@@ -210,6 +212,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDeletes()
{
return getDecorated().isRefreshDeletes();
@@ -219,6 +222,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDeletes( boolean refreshDeletes )
{
getDecorated().setRefreshDeletes( refreshDeletes );
@@ -228,6 +232,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueFactory.java
index da629c1..6564b1f 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SyncDoneValue.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncDoneValue> newCodecControl()
{
return new SyncDoneValueDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncDoneValue> newCodecControl( SyncDoneValue control )
{
return new SyncDoneValueDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueStatesEnum.java
index a7c1539..b24775e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncDoneValueStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.controls.syncrepl_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -53,33 +52,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SYNC_DONE_VALUE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<SyncDoneValueContainer> grammar )
- {
- if ( grammar instanceof SyncDoneValueGrammar )
- {
- return "SYNC_DONE_VALUE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -87,13 +68,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SYNC_DONE_VALUE_GRAMMAR" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "SYNC_DONE_VALUE_GRAMMAR" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -103,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncDoneValueStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueContainer.java
index 06c1631..1cf1aa2 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueContainer.java
@@ -92,6 +92,9 @@
}
+ /**
+ * @return The LDAP API service
+ */
public LdapApiService getCodecService()
{
return codec;
@@ -101,6 +104,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
index 56f4f70..83e649a 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueDecorator.java
@@ -53,6 +53,9 @@
/** An instance of this decoder */
private static final Asn1Decoder DECODER = new Asn1Decoder();
+ /** The global length for this control */
+ private int syncInfoValueLength;
+
/**
* The constructor for this codec. Dont't forget to set the type.
@@ -91,13 +94,11 @@
setType( type );
}
- /** The global length for this control */
- private int syncInfoValueLength;
-
-
+
/**
* {@inheritDoc}
*/
+ @Override
public SynchronizationInfoEnum getType()
{
return getDecorated().getType();
@@ -107,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setType( SynchronizationInfoEnum type )
{
this.getDecorated().setType( type );
@@ -122,6 +124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -131,6 +134,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
// Copy the bytes
@@ -150,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDone()
{
return getDecorated().isRefreshDone();
@@ -159,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDone( boolean refreshDone )
{
getDecorated().setRefreshDone( refreshDone );
@@ -168,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRefreshDeletes()
{
return getDecorated().isRefreshDeletes();
@@ -177,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRefreshDeletes( boolean refreshDeletes )
{
getDecorated().setRefreshDeletes( refreshDeletes );
@@ -186,6 +194,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<byte[]> getSyncUUIDs()
{
return getDecorated().getSyncUUIDs();
@@ -195,6 +204,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSyncUUIDs( List<byte[]> syncUUIDs )
{
getDecorated().setSyncUUIDs( syncUUIDs );
@@ -204,6 +214,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addSyncUUID( byte[] syncUUID )
{
getDecorated().addSyncUUID( syncUUID );
@@ -291,7 +302,7 @@
// The syncUUIDs if any
syncUUIDsLength = 0;
- if ( getSyncUUIDs().size() != 0 )
+ if ( !getSyncUUIDs().isEmpty() )
{
for ( byte[] syncUUID : getSyncUUIDs() )
{
@@ -410,7 +421,7 @@
buffer.put( TLV.getBytes( syncUUIDsLength ) );
// Loop on the UUIDs if any
- if ( getSyncUUIDs().size() != 0 )
+ if ( !getSyncUUIDs().isEmpty() )
{
for ( byte[] syncUUID : getSyncUUIDs() )
{
@@ -521,7 +532,7 @@
buffer.put( TLV.getBytes( syncUUIDsLength ) );
// Loop on the UUIDs if any
- if ( getSyncUUIDs().size() != 0 )
+ if ( !getSyncUUIDs().isEmpty() )
{
for ( byte[] syncUUID : getSyncUUIDs() )
{
@@ -550,6 +561,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
@@ -562,6 +574,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return getDecorated().toString();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueFactory.java
index fe669aa..8648d80 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SyncInfoValue.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncInfoValue> newCodecControl()
{
return new SyncInfoValueDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncInfoValue> newCodecControl( SyncInfoValue control )
{
return new SyncInfoValueDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueStatesEnum.java
index 957b02e..44c2dca 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.controls.syncrepl_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -86,33 +85,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SYNC_INFO_VALUE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<SyncInfoValueContainer> grammar )
- {
- if ( grammar instanceof SyncInfoValueGrammar )
- {
- return "SYNC_INFO_VALUE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -120,13 +101,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SYNC_INFO_VALUE_END_STATE" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "SYNC_INFO_VALUE_END_STATE" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -136,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncInfoValueStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueTags.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueTags.java
index e712733..e0afcde 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueTags.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncInfoValueTags.java
@@ -27,10 +27,16 @@
*/
public enum SyncInfoValueTags
{
- /** The tags */
+ /** A new cookie */
NEW_COOKIE_TAG(0x0080),
+
+ /** Refresh delete phase */
REFRESH_DELETE_TAG(0x00A1),
+
+ /** Refresh present phase */
REFRESH_PRESENT_TAG(0x00A2),
+
+ /** Sync ID set */
SYNC_ID_SET_TAG(0x00A3);
/** Internal value for each tag */
@@ -41,7 +47,7 @@
* Create the private instance
* @param value The internal tag value
*/
- private SyncInfoValueTags( int value )
+ SyncInfoValueTags( int value )
{
this.value = value;
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueContainer.java
index 21d1f40..fed4dc0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueContainer.java
@@ -86,6 +86,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueDecorator.java
index eceb119..9c13047 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueDecorator.java
@@ -52,12 +52,23 @@
private static final Asn1Decoder DECODER = new Asn1Decoder();
+ /**
+ * Create a new SyncRequestValueDecorator instance
+ *
+ * @param codec The LDAP API service to use
+ */
public SyncRequestValueDecorator( LdapApiService codec )
{
super( codec, new SyncRequestValueImpl() );
}
+ /**
+ * Create a new SyncRequestValueDecorator instance
+ *
+ * @param codec The LDAP API service to use
+ * @param control The decorated SyncRequestValue control
+ */
public SyncRequestValueDecorator( LdapApiService codec, SyncRequestValue control )
{
super( codec, control );
@@ -67,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SynchronizationModeEnum getMode()
{
return getDecorated().getMode();
@@ -76,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMode( SynchronizationModeEnum mode )
{
getDecorated().setMode( mode );
@@ -85,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -94,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
// Copy the bytes
@@ -113,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReloadHint()
{
return getDecorated().isReloadHint();
@@ -122,6 +138,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReloadHint( boolean reloadHint )
{
getDecorated().setReloadHint( reloadHint );
@@ -256,6 +273,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueFactory.java
index 4055020..17feb82 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SyncRequestValue.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncRequestValue> newCodecControl()
{
return new SyncRequestValueDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncRequestValue> newCodecControl( SyncRequestValue control )
{
return new SyncRequestValueDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueStatesEnum.java
index 81a71eb..ed3049d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncRequestValueStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.controls.syncrepl_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -62,33 +61,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SYNC_REQUEST_VALUE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<SyncRequestValueContainer> grammar )
- {
- if ( grammar instanceof SyncRequestValueGrammar )
- {
- return "SYNC_REQUEST_VALUE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -96,13 +77,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SYNC_REQUEST_VALUE_END_STATE" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "SYNC_REQUEST_VALUE_END_STATE" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -112,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncRequestValueStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueContainer.java
index c8e13d7..eb8eb09 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueContainer.java
@@ -86,6 +86,7 @@
/**
* Clean the container
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueDecorator.java
index 7a0fc7f..1cbeb4d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueDecorator.java
@@ -51,12 +51,23 @@
private static final Asn1Decoder DECODER = new Asn1Decoder();
+ /**
+ * Creates a new instance of SyncStateValueDecorator.
+ *
+ * @param codec The LDAP Service to use
+ */
public SyncStateValueDecorator( LdapApiService codec )
{
super( codec, new SyncStateValueImpl() );
}
+ /**
+ * Creates a new instance of SyncStateValueDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param value The SyncState value to use
+ */
public SyncStateValueDecorator( LdapApiService codec, SyncStateValue value )
{
super( codec, value );
@@ -66,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCookie()
{
return getDecorated().getCookie();
@@ -75,6 +87,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCookie( byte[] cookie )
{
getDecorated().setCookie( cookie );
@@ -84,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncStateTypeEnum getSyncStateType()
{
return getDecorated().getSyncStateType();
@@ -93,6 +107,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSyncStateType( SyncStateTypeEnum syncStateType )
{
getDecorated().setSyncStateType( syncStateType );
@@ -102,6 +117,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getEntryUUID()
{
return getDecorated().getEntryUUID();
@@ -111,6 +127,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setEntryUUID( byte[] entryUUID )
{
getDecorated().setEntryUUID( entryUUID );
@@ -234,6 +251,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueFactory.java
index 3032117..7f0cb97 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueFactory.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return SyncStateValue.OID;
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncStateValue> newCodecControl()
{
return new SyncStateValueDecorator( codec );
@@ -70,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CodecControl<SyncStateValue> newCodecControl( SyncStateValue control )
{
return new SyncStateValueDecorator( codec, control );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueStatesEnum.java
index e801767..8268e05 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl_impl/SyncStateValueStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.controls.syncrepl_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -59,33 +58,15 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "SYNC_REQUEST_VALUE_GRAMMAR";
}
/**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<SyncStateValueContainer> grammar )
- {
- if ( grammar instanceof SyncStateValueGrammar )
- {
- return "SYNC_STATE_VALUE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
* Get the string representing the state
*
* @param state The state number
@@ -93,13 +74,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "SYNC_STATE_VALUE_END_STATE" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "SYNC_STATE_VALUE_END_STATE" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -109,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyncStateValueStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestContainer.java
index c28c84b..640303c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestContainer.java
@@ -38,6 +38,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new VirtualListViewRequestContainer instance
+ *
+ * @param codec The LDAP Service to use
+ */
public VirtualListViewRequestContainer( LdapApiService codec )
{
super();
@@ -47,6 +52,12 @@
}
+ /**
+ * Creates a new VirtualListViewRequestContainer instance
+ *
+ * @param control The VLV control
+ * @param codec The LDAP Service to use
+ */
public VirtualListViewRequestContainer( VirtualListViewRequestDecorator control, LdapApiService codec )
{
this( codec );
@@ -54,12 +65,20 @@
}
+ /**
+ * @return The VLV control
+ */
public VirtualListViewRequestDecorator getDecorator()
{
return control;
}
+ /**
+ * Decorate he VLV control
+ *
+ * @param control The control to decorate
+ */
public void decorate( VirtualListViewRequest control )
{
if ( control instanceof VirtualListViewRequestDecorator )
@@ -73,12 +92,21 @@
}
+ /**
+ * Sets the VLV control
+ *
+ * @param control The VLV control
+ */
public void setVirtualListViewRequestControl( VirtualListViewRequestDecorator control )
{
this.control = control;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestDecorator.java
index aa9b5e4..10809a0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestDecorator.java
@@ -51,12 +51,23 @@
private static final Asn1Decoder DECODER = new Asn1Decoder();
+ /**
+ * Creates a new instance of VirtualListViewRequestDecorator.
+ *
+ * @param codec The LDAP Service to use
+ */
public VirtualListViewRequestDecorator( LdapApiService codec )
{
this( codec, new VirtualListViewRequestImpl() );
}
+ /**
+ * Creates a new instance of VirtualListViewRequestDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param vlvRequest The VLV request to use
+ */
public VirtualListViewRequestDecorator( LdapApiService codec, VirtualListViewRequest vlvRequest )
{
super( codec, vlvRequest );
@@ -66,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int computeLength()
{
vlvSeqLength = 1 + 1 + BerValue.getNbBytes( getBeforeCount() );
@@ -108,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -161,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestFactory.java
index babba5a..2e4801c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestFactory.java
@@ -37,6 +37,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of VirtualListViewRequestFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public VirtualListViewRequestFactory( LdapApiService codec )
{
this.codec = codec;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestGrammar.java
index e4537c0..3d28a1f 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestGrammar.java
@@ -30,7 +30,24 @@
/**
- * TODO VirtualListViewRequestGrammar.
+ * The VLV grammar. It's an implementation of https://www.ietf.org/archive/id/draft-ietf-ldapext-ldapv3-vlv-09.txt
+ *
+ * Here is the grammar :
+ *
+ * <pre>
+ * VirtualListViewRequest ::= SEQUENCE {
+ * beforeCount INTEGER (0..maxInt),
+ * afterCount INTEGER (0..maxInt),
+ * target CHOICE {
+ * byOffset [0] SEQUENCE {
+ * offset INTEGER (1 .. maxInt),
+ * contentCount INTEGER (0 .. maxInt)
+ * },
+ * greaterThanOrEqual [1] AssertionValue
+ * },
+ * contextID OCTET STRING OPTIONAL
+ * }
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -43,6 +60,9 @@
private static Grammar<?> instance = new VirtualListViewRequestGrammar();
+ /**
+ * Creates a new VirtualListViewRequestGrammar object.
+ */
@SuppressWarnings("unchecked")
private VirtualListViewRequestGrammar()
{
@@ -121,6 +141,9 @@
}
+ /**
+ * @return the singleton instance of the VirtualListViewRequestGrammar
+ */
public static Grammar<?> getInstance()
{
return instance;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestStates.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestStates.java
index 4ebc79d..80d0e85 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestStates.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewRequestStates.java
@@ -21,7 +21,6 @@
package org.apache.directory.api.ldap.extras.controls.vlv_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -33,37 +32,56 @@
*/
public enum VirtualListViewRequestStates implements States
{
+ /** Initial state */
START_STATE,
+
+ /** VirtualListViewRequest ::= SEQUENCE transition */
VLV_SEQUENCE_STATE,
+
+ /** beforeCount INTEGER (0..maxInt) transition */
VLV_BEFORE_COUNT_STATE,
+
+ /** afterCount INTEGER (0..maxInt) transition */
VLV_AFTER_COUNT_STATE,
+
+ /** byOffset [0] SEQUENCE transition */
VLV_TARGET_BY_OFFSET_STATE,
+
+ /** offset INTEGER (1 .. maxInt) transition */
VLV_OFFSET_STATE,
+
+ /** contentCount INTEGER (0 .. maxInt) transition */
VLV_CONTENT_COUNT_STATE,
+
+ /** contextID OCTET STRING OPTIONAL transition */
VLV_CONTEXT_ID_STATE,
+
+ /** greaterThanOrEqual [1] AssertionValue transition */
VLV_ASSERTION_VALUE_STATE,
+
+ /** Final state */
END_STATE;
- public String getGrammarName( int grammar )
+ /**
+ * Get the grammar name
+ *
+ * @return The grammar name
+ */
+ public String getGrammarName()
{
return "VLV_REQUEST_GRAMMAR";
}
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof VirtualListViewRequestGrammar )
- {
- return "VLV_REQUEST_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
+ /**
+ * Get the string representing the state
+ *
+ * @param state The state number
+ * @return The String representing the state
+ */
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "VLV_REQUEST_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "VLV_REQUEST_END_STATE" : name();
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java
index 6644c19..6d7f99c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java
@@ -38,6 +38,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new VirtualListViewResponseContainer object.
+ *
+ * @param codec The LDAP Service to use
+ */
public VirtualListViewResponseContainer( LdapApiService codec )
{
super();
@@ -47,6 +52,12 @@
}
+ /**
+ * Creates a new VirtualListViewResponseContainer object.
+ *
+ * @param control The VLV control to decorate
+ * @param codec The LDAP Service to use
+ */
public VirtualListViewResponseContainer( VirtualListViewResponseDecorator control, LdapApiService codec )
{
this( codec );
@@ -54,12 +65,20 @@
}
+ /**
+ * @return The decorated VLV control
+ */
public VirtualListViewResponseDecorator getDecorator()
{
return control;
}
+ /**
+ * Decorate a VLV control
+ *
+ * @param control The VLV control to decorate
+ */
public void decorate( VirtualListViewResponse control )
{
if ( control instanceof VirtualListViewResponseDecorator )
@@ -73,12 +92,21 @@
}
+ /**
+ * Set the VLV control
+ *
+ * @param control The VLV control
+ */
public void setVirtualListViewResponseControl( VirtualListViewResponseDecorator control )
{
this.control = control;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java
index 50e6d79..a4a4bc7 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java
@@ -51,12 +51,23 @@
private static final Asn1Decoder DECODER = new Asn1Decoder();
+ /**
+ * Create a new SyncRequestValueDecorator instance
+ *
+ * @param codec The LDAP API service to use
+ */
public VirtualListViewResponseDecorator( LdapApiService codec )
{
this( codec, new VirtualListViewResponseImpl() );
}
+ /**
+ * Create a new SyncRequestValueDecorator instance
+ *
+ * @param codec The LDAP API service to use
+ * @param vlvRequest The decorated VLV request
+ */
public VirtualListViewResponseDecorator( LdapApiService codec, VirtualListViewResponse vlvRequest )
{
super( codec, vlvRequest );
@@ -66,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int computeLength()
{
vlvSeqLength = 1 + 1 + BerValue.getNbBytes( getTargetPosition() );
@@ -88,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
if ( buffer == null )
@@ -115,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( value == null )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java
index 40b3ee2..1252b9e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java
@@ -37,6 +37,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of VirtualListViewResponseFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public VirtualListViewResponseFactory( LdapApiService codec )
{
this.codec = codec;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java
index f534186..89445d3 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java
@@ -66,6 +66,9 @@
private static Grammar<?> instance = new VirtualListViewResponseGrammar();
+ /**
+ * Creates a new VirtualListViewResponseGrammar object.
+ */
@SuppressWarnings("unchecked")
private VirtualListViewResponseGrammar()
{
@@ -113,6 +116,9 @@
}
+ /**
+ * @return the singleton instance of the VirtualListViewResponseGrammar
+ */
public static Grammar<?> getInstance()
{
return instance;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java
index b9d4666..56536d7 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java
@@ -21,7 +21,6 @@
package org.apache.directory.api.ldap.extras.controls.vlv_impl;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -33,34 +32,47 @@
*/
public enum VirtualListViewResponseStates implements States
{
+ /** Initial state */
START_STATE,
+
+ /** VirtualListViewResponse ::= SEQUENCE transition */
VLV_SEQUENCE_STATE,
+
+ /** targetPosition INTEGER (0 .. maxInt) transition */
VLV_TARGET_POSITION_STATE,
+
+ /** contentCount INTEGER (0 .. maxInt) transition */
VLV_CONTENT_COUNT_STATE,
+
+ /** virtualListViewResult ENUMERATED transition */
VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
+
+ /** contextID OCTET STRING OPTIONAL transition */
VLV_CONTEXT_ID_STATE,
+
+ /** Final state */
END_STATE;
- public String getGrammarName( int grammar )
+ /**
+ * Get the grammar name
+ *
+ * @return The grammar name
+ */
+ public String getGrammarName()
{
return "VLV_RESPONSE_GRAMMAR";
}
- public String getGrammarName( Grammar<?> grammar )
- {
- if ( grammar instanceof VirtualListViewResponseGrammar )
- {
- return "VLV_RESPONSE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
+ /**
+ * Get the string representing the state
+ *
+ * @param state The state number
+ * @return The String representing the state
+ */
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "VLV_RESPONSE_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "VLV_RESPONSE_END_STATE" : name();
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewerTags.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewerTags.java
index 546e756..94a2dfd 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewerTags.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewerTags.java
@@ -28,21 +28,25 @@
*/
public enum VirtualListViewerTags
{
- // byOffset [0]
+ /** byOffset [0] */
BY_OFFSET_TAG(0xA0),
- // greaterThanOrEqual [1]
+
+ /** greaterThanOrEqual [1] */
ASSERTION_VALUE_TAG(0x81);
/** Internal value for each tag */
private int value;
- private VirtualListViewerTags( int value )
+ VirtualListViewerTags( int value )
{
this.value = value;
}
+ /**
+ * @return The interned value
+ */
public int getValue()
{
return value;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelContainer.java
index 60cbba8..814c3da 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelFactory.java
index b16f2f9..bab1763 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelFactory.java
@@ -42,6 +42,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of CancelFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public CancelFactory( LdapApiService codec )
{
this.codec = codec;
@@ -51,6 +56,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return CancelRequest.EXTENSION_OID;
@@ -60,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CancelResponse newResponse( byte[] encodedValue ) throws DecoderException
{
CancelResponseDecorator response = new CancelResponseDecorator( codec, new CancelResponseImpl() );
@@ -72,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CancelRequest newRequest( byte[] value )
{
CancelRequestDecorator req = new CancelRequestDecorator( codec, new CancelRequestImpl() );
@@ -84,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CancelRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof CancelRequestDecorator )
@@ -98,6 +107,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CancelResponseDecorator decorate( ExtendedResponse decoratedMessage )
{
if ( decoratedMessage instanceof CancelResponseDecorator )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelRequestDecorator.java
index e8aa542..7fc3cd4 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelRequestDecorator.java
@@ -53,6 +53,12 @@
private int cancelSequenceLength;
+ /**
+ * Creates a new instance of CancelRequestDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param decoratedMessage The canceled request
+ */
public CancelRequestDecorator( LdapApiService codec, CancelRequest decoratedMessage )
{
super( codec, decoratedMessage );
@@ -63,6 +69,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getCancelId()
{
return cancelRequest.getCancelId();
@@ -72,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCancelId( int cancelId )
{
if ( cancelId == cancelRequest.getCancelId() )
@@ -87,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getRequestValue()
{
if ( requestValue == null )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelStatesEnum.java
index 61d6ee6..9e45af4 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/cancel/CancelStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.cancel;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -56,22 +55,9 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
- {
- return "CANCEL_GRAMMAR";
- }
-
-
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<CancelContainer> grammar )
+ public String getGrammarName()
{
return "CANCEL_GRAMMAR";
}
@@ -85,13 +71,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "CANCEL_END_STATE" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "CANCEL_END_STATE" : this.name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -101,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CancelStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationContainer.java
index 7261f79..26111a2 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationFactory.java
index 6d75617..32b02b0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationFactory.java
@@ -42,6 +42,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of CertGenerationFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public CertGenerationFactory( LdapApiService codec )
{
this.codec = codec;
@@ -51,6 +56,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return CertGenerationRequest.EXTENSION_OID;
@@ -60,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CertGenerationResponse newResponse( byte[] encodedValue ) throws DecoderException
{
CertGenerationResponseDecorator response = new CertGenerationResponseDecorator( codec,
@@ -73,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CertGenerationRequest newRequest( byte[] value )
{
CertGenerationRequestDecorator req = new CertGenerationRequestDecorator( codec, new CertGenerationRequestImpl() );
@@ -84,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CertGenerationRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof CertGenerationRequestDecorator )
@@ -98,6 +107,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CertGenerationResponseDecorator decorate( ExtendedResponse decoratedMessage )
{
if ( decoratedMessage instanceof CertGenerationResponseDecorator )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationGrammar.java
index b4599c8..7cf0c21 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationGrammar.java
@@ -67,6 +67,9 @@
private static Grammar<CertGenerationContainer> instance = new CertGenerationGrammar();
+ /**
+ * Creates a new CertGenerationGrammar object.
+ */
@SuppressWarnings("unchecked")
public CertGenerationGrammar()
{
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationRequestDecorator.java
index e1881a3..f43b41d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationRequestDecorator.java
@@ -53,6 +53,12 @@
private int requestLength = 0;
+ /**
+ * Creates a new instance of CertGenerationRequestDecorator.
+ *
+ * @param codec The LDAP Service to use
+ * @param decoratedMessage The certificate generation request
+ */
public CertGenerationRequestDecorator( LdapApiService codec, CertGenerationRequest decoratedMessage )
{
super( codec, decoratedMessage );
@@ -60,6 +66,9 @@
}
+ /**
+ * @return The certificate generation request
+ */
public CertGenerationRequest getCertGenerationRequest()
{
return certGenerationRequest;
@@ -135,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getTargetDN()
{
return getDecorated().getTargetDN();
@@ -144,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTargetDN( String targetDN )
{
getDecorated().setTargetDN( targetDN );
@@ -153,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getIssuerDN()
{
return getDecorated().getIssuerDN();
@@ -162,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setIssuerDN( String issuerDN )
{
getDecorated().setIssuerDN( issuerDN );
@@ -171,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSubjectDN()
{
return getDecorated().getSubjectDN();
@@ -180,6 +194,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSubjectDN( String subjectDN )
{
getDecorated().setSubjectDN( subjectDN );
@@ -189,6 +204,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getKeyAlgorithm()
{
return getDecorated().getKeyAlgorithm();
@@ -198,6 +214,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setKeyAlgorithm( String keyAlgorithm )
{
getDecorated().setKeyAlgorithm( keyAlgorithm );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationStatesEnum.java
index 9d39788..6d07a7d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -57,25 +56,13 @@
/** terminal state */
LAST_CERT_GENERATION_STATE;
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<CertGenerationContainer> grammar )
- {
- return "CERT_GENERATION_GRAMMER";
- }
-
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "CERT_GENERATION_GRAMMER";
}
@@ -89,13 +76,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "CERT_GENERATION_END_STATE" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "CERT_GENERATION_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -105,6 +93,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CertGenerationStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectContainer.java
index 51e568e..41e5cb2 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectFactory.java
index 17130f0..1a0379e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectFactory.java
@@ -41,6 +41,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of GracefulDisconnectFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public GracefulDisconnectFactory( LdapApiService codec )
{
this.codec = codec;
@@ -50,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequestDecorator<ExtendedRequest> decorate(
ExtendedRequest modelRequest )
{
@@ -61,6 +67,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse decorate( ExtendedResponse decoratedMessage )
{
if ( decoratedMessage instanceof GracefulDisconnectResponseDecorator )
@@ -75,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return GracefulDisconnectResponse.EXTENSION_OID;
@@ -84,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest newRequest( byte[] value )
{
// Nothing to do (there's no request associated to GracefulDisconnectResponse)
@@ -94,6 +103,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GracefulDisconnectResponse newResponse( byte[] encodedValue ) throws DecoderException
{
GracefulDisconnectResponseDecorator req = new GracefulDisconnectResponseDecorator( codec,
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectResponseDecorator.java
index 64c4e36..2383f6c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectResponseDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectResponseDecorator.java
@@ -82,6 +82,7 @@
*
* @return the response specific encoded response values.
*/
+ @Override
public byte[] getResponseValue()
{
if ( responseValue == null )
@@ -106,6 +107,7 @@
*
* @param responseValue the response specific encoded response values.
*/
+ @Override
public void setResponseValue( byte[] responseValue )
{
GracefulDisconnectDecoder decoder = new GracefulDisconnectDecoder();
@@ -133,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getDelay()
{
return gracefulDisconnectResponse.getDelay();
@@ -142,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDelay( int delay )
{
gracefulDisconnectResponse.setDelay( delay );
@@ -151,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeOffline()
{
return gracefulDisconnectResponse.getTimeOffline();
@@ -160,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOffline( int timeOffline )
{
gracefulDisconnectResponse.setTimeOffline( timeOffline );
@@ -169,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Referral getReplicatedContexts()
{
return gracefulDisconnectResponse.getReplicatedContexts();
@@ -178,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addReplicatedContexts( String replicatedContext )
{
gracefulDisconnectResponse.getReplicatedContexts().addLdapUrl( replicatedContext );
@@ -211,11 +219,11 @@
}
if ( ( gracefulDisconnectResponse.getReplicatedContexts() != null )
- && ( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() != 0 ) )
+ && ( !gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().isEmpty() ) )
{
replicatedContextsLength = 0;
- ldapUrlBytes = new ArrayList<byte[]>( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() );
+ ldapUrlBytes = new ArrayList<>( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() );
// We may have more than one reference.
for ( String replicatedContext : gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls() )
@@ -262,7 +270,7 @@
}
if ( ( gracefulDisconnectResponse.getReplicatedContexts() != null )
- && ( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() != 0 ) )
+ && ( !gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().isEmpty() ) )
{
bb.put( UniversalTag.SEQUENCE.getValue() );
bb.put( TLV.getBytes( replicatedContextsLength ) );
@@ -281,15 +289,17 @@
/**
* Return a string representation of the graceful disconnect
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "Graceful Disconnect extended operation" );
sb.append( " TimeOffline : " ).append( gracefulDisconnectResponse.getTimeOffline() ).append( '\n' );
sb.append( " Delay : " ).append( gracefulDisconnectResponse.getDelay() ).append( '\n' );
- if ( ( gracefulDisconnectResponse.getReplicatedContexts() != null ) && ( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() != 0 ) )
+ if ( ( gracefulDisconnectResponse.getReplicatedContexts() != null )
+ && ( !gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().isEmpty() ) )
{
sb.append( " Replicated contexts :" );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectStatesEnum.java
index 6c4fa71..4889c6d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulDisconnect/GracefulDisconnectStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -65,22 +64,9 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
- {
- return "GRACEFUL_DISCONNECT_GRAMMAR";
- }
-
-
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<GracefulDisconnectContainer> grammar )
+ public String getGrammarName()
{
return "GRACEFUL_DISCONNECT_GRAMMAR";
}
@@ -94,13 +80,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "GRACEFUL_DISCONNECT_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "GRACEFUL_DISCONNECT_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -110,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GracefulDisconnectStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownContainer.java
index a2c6b4a..a7cc596 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownFactory.java
index 898eade..1236569 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownFactory.java
@@ -42,6 +42,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of GracefulShutdownFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public GracefulShutdownFactory( LdapApiService codec )
{
this.codec = codec;
@@ -51,6 +56,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return GracefulShutdownRequest.EXTENSION_OID;
@@ -60,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GracefulShutdownResponse newResponse( byte[] encodedValue ) throws DecoderException
{
GracefulShutdownResponseDecorator response = new GracefulShutdownResponseDecorator(
@@ -72,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GracefulShutdownRequest newRequest( byte[] value )
{
GracefulShutdownRequestDecorator req = new GracefulShutdownRequestDecorator( codec,
@@ -84,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof GracefulShutdownRequestDecorator )
@@ -98,6 +107,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse decorate( ExtendedResponse decoratedMessage )
{
if ( decoratedMessage instanceof GracefulShutdownResponseDecorator )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownGrammar.java
index 2546647..653b987 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownGrammar.java
@@ -203,7 +203,7 @@
{
public void action( GracefulShutdownContainer container ) throws DecoderException
{
- GracefulShutdownContainer gracefulShutdownContainer = ( GracefulShutdownContainer ) container;
+ GracefulShutdownContainer gracefulShutdownContainer = container;
BerValue value = gracefulShutdownContainer.getCurrentTLV().getValue();
try
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownRequestDecorator.java
index 5b88edd..3e7f6dc 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownRequestDecorator.java
@@ -68,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRequestValue( byte[] requestValue )
{
GracefulShutdownDecoder decoder = new GracefulShutdownDecoder();
@@ -97,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getRequestValue()
{
if ( requestValue == null )
@@ -119,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getDelay()
{
return getDecorated().getDelay();
@@ -128,6 +131,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDelay( int delay )
{
getDecorated().setDelay( delay );
@@ -137,6 +141,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeOffline()
{
return getDecorated().getTimeOffline();
@@ -146,6 +151,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeOffline( int timeOffline )
{
getDecorated().setTimeOffline( timeOffline );
@@ -214,9 +220,10 @@
/**
* Return a string representation of the graceful shutdown
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "Graceful Shutdown extended operation" );
sb.append( " TimeOffline : " ).append( gracefulShutdownRequest.getTimeOffline() ).append( '\n' );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownStatesEnum.java
index 51863d3..ea9f614 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/gracefulShutdown/GracefulShutdownStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -60,22 +59,9 @@
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
- {
- return "GRACEFUL_SHUTDOWN_GRAMMAR";
- }
-
-
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<GracefulShutdownContainer> grammar )
+ public String getGrammarName()
{
return "GRACEFUL_SHUTDOWN_GRAMMAR";
}
@@ -89,13 +75,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "GRACEFUL_SHUTDOWN_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "GRACEFUL_SHUTDOWN_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -105,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GracefulShutdownStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
index a0b36f8..3969e99 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
@@ -51,6 +51,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of PasswordModifyFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public PasswordModifyFactory( LdapApiService codec )
{
this.codec = codec;
@@ -60,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return PasswordModifyRequest.EXTENSION_OID;
@@ -69,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordModifyResponse newResponse( byte[] encodedValue ) throws DecoderException
{
PasswordModifyResponseDecorator response = new PasswordModifyResponseDecorator( codec,
@@ -81,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordModifyRequest newRequest( byte[] value )
{
PasswordModifyRequestDecorator req = new PasswordModifyRequestDecorator( codec, new PasswordModifyRequestImpl() );
@@ -97,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordModifyRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof PasswordModifyRequestDecorator )
@@ -111,7 +120,8 @@
/**
* {@inheritDoc}
*/
- public PasswordModifyResponseDecorator decorate( ExtendedResponse decoratedResponse )
+ @Override
+public PasswordModifyResponseDecorator decorate( ExtendedResponse decoratedResponse )
{
if ( decoratedResponse instanceof PasswordModifyResponseDecorator )
{
@@ -133,7 +143,7 @@
byte[] value = response.getResponseValue();
PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
- PasswordModifyResponse pwdModifyResponse = null;
+ PasswordModifyResponse pwdModifyResponse;
if ( value != null )
{
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
index b920282..58301f2 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestDecorator.java
index 19bc201..8ca5c03 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestDecorator.java
@@ -130,6 +130,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getUserIdentity()
{
return passwordModifyRequest.getUserIdentity();
@@ -139,6 +140,7 @@
/**
* @param userIdentity the userIdentity to set
*/
+ @Override
public void setUserIdentity( byte[] userIdentity )
{
passwordModifyRequest.setUserIdentity( userIdentity );
@@ -148,6 +150,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getOldPassword()
{
return passwordModifyRequest.getOldPassword();
@@ -157,6 +160,7 @@
/**
* @param oldPassword the oldPassword to set
*/
+ @Override
public void setOldPassword( byte[] oldPassword )
{
passwordModifyRequest.setOldPassword( oldPassword );
@@ -166,6 +170,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getNewPassword()
{
return passwordModifyRequest.getNewPassword();
@@ -175,6 +180,7 @@
/**
* @param newPassword the newPassword to set
*/
+ @Override
public void setNewPassword( byte[] newPassword )
{
passwordModifyRequest.setNewPassword( newPassword );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestGrammar.java
index b9179c2..aa188ff 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestGrammar.java
@@ -62,6 +62,9 @@
private static Grammar<PasswordModifyRequestContainer> instance = new PasswordModifyRequestGrammar();
+ /**
+ * Creates a new PasswordModifyRequestGrammar object.
+ */
@SuppressWarnings("unchecked")
public PasswordModifyRequestGrammar()
{
@@ -129,8 +132,7 @@
userIdentity = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setUserIdentity( userIdentity );
+ container.getPwdModifyRequest().setUserIdentity( userIdentity );
// We may have nothing left
container.setGrammarEndAllowed( true );
@@ -170,8 +172,7 @@
oldPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setOldPassword( oldPassword );
+ container.getPwdModifyRequest().setOldPassword( oldPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
@@ -212,8 +213,7 @@
newPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setNewPassword( newPassword );
+ container.getPwdModifyRequest().setNewPassword( newPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
@@ -253,8 +253,7 @@
oldPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setOldPassword( oldPassword );
+ container.getPwdModifyRequest().setOldPassword( oldPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
@@ -294,8 +293,7 @@
newPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setNewPassword( newPassword );
+ container.getPwdModifyRequest().setNewPassword( newPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
@@ -335,8 +333,7 @@
newPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() )
- .setNewPassword( newPassword );
+ container.getPwdModifyRequest().setNewPassword( newPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestStatesEnum.java
index 0f2c604..2d0037c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -54,25 +53,13 @@
/** Last state */
LAST_PASSWORD_MODIFY_REQUEST_STATE;
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<PasswordModifyRequestContainer> grammar )
- {
- return "PASSWORD_MODIFY_REQUEST_GRAMMER";
- }
-
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "PASSWORD_MODIFY_REQUEST_GRAMMER";
}
@@ -86,13 +73,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "PASSWORD_MODIFY_REQUEST_GRAMMER" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "PASSWORD_MODIFY_REQUEST_GRAMMER" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -102,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordModifyRequestStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
index fe5c4ee..e448a65 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
index e8f6ee0..0c1b076 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
@@ -121,6 +121,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getGenPassword()
{
return getDecorated().getGenPassword();
@@ -140,6 +141,7 @@
* Overload the parent's getResponseName method, as the pwdModify response should not
* contain the responseName.
*/
+ @Override
public String getResponseName()
{
return null;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
index 3348d15..6f81bca 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
@@ -60,6 +60,9 @@
private static Grammar<PasswordModifyResponseContainer> instance = new PasswordModifyResponseGrammar();
+ /**
+ * Creates a new PasswordModifyResponseGrammar object.
+ */
@SuppressWarnings("unchecked")
public PasswordModifyResponseGrammar()
{
@@ -127,8 +130,7 @@
genPassword = Strings.EMPTY_BYTES;
}
- ( ( PasswordModifyResponseDecorator ) container.getPwdModifyResponse() )
- .setGenPassword( genPassword );
+ container.getPwdModifyResponse().setGenPassword( genPassword );
// We may have nothing left
container.setGrammarEndAllowed( true );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseStatesEnum.java
index 5d54884..f268dcb 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -48,25 +47,13 @@
/** Last state */
LAST_PASSWORD_MODIFY_RESPONSE_STATE;
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<PasswordModifyResponseContainer> grammar )
- {
- return "PASSWORD_MODIFY_RESPONSE_GRAMMER";
- }
-
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "PASSWORD_MODIFY_RESPONSE_GRAMMER";
}
@@ -80,13 +67,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "PASSWORD_MODIFY_RESPONSE_GRAMMER" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "PASSWORD_MODIFY_RESPONSE_GRAMMER" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -96,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public PasswordModifyResponseStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
index 552b406..32b2a32 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
@@ -43,6 +43,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of StartTlsFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public StartTlsFactory( LdapApiService codec )
{
this.codec = codec;
@@ -52,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return StartTlsRequest.EXTENSION_OID;
@@ -61,6 +67,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StartTlsResponse newResponse( byte[] encodedValue ) throws DecoderException
{
StartTlsResponseDecorator response = new StartTlsResponseDecorator( codec,
@@ -73,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StartTlsRequest newRequest( byte[] value )
{
StartTlsRequestDecorator req = new StartTlsRequestDecorator( codec, new StartTlsRequestImpl() );
@@ -89,6 +97,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StartTlsRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof StartTlsRequestDecorator )
@@ -103,6 +112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StartTlsResponseDecorator decorate( ExtendedResponse decoratedResponse )
{
if ( decoratedResponse instanceof StartTlsResponseDecorator )
@@ -124,8 +134,6 @@
startTlsResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode() );
startTlsResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage() );
- StartTlsResponseDecorator decorated = new StartTlsResponseDecorator( codec, new StartTlsResponseImpl() );
-
- return decorated;
+ return new StartTlsResponseDecorator( codec, new StartTlsResponseImpl() );
}
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureContainer.java
index c5289ad..e40d02c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureContainer.java
@@ -31,16 +31,12 @@
*/
public class StoredProcedureContainer extends AbstractContainer
{
- // ~ Instance fields
- // ----------------------------------------------------------------------------
-
/** StoredProcedure */
private StoredProcedureRequestDecorator storedProcedure;
-
- // ~ Constructors
- // -------------------------------------------------------------------------------
-
+ /**
+ * Creates a new StoredProcedureContainer instance
+ */
public StoredProcedureContainer()
{
super();
@@ -49,8 +45,6 @@
}
- // ~ Methods
- // ------------------------------------------------------------------------------------
/**
* @return Returns the ldapMessage.
*/
@@ -75,6 +69,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureDecoder.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureDecoder.java
index 1d02d7d..2167a0d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureDecoder.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureDecoder.java
@@ -31,9 +31,10 @@
*/
public class StoredProcedureDecoder extends Asn1Decoder
{
-
+ /**
+ * Creates a new StoredProcedureDecoder instance
+ */
public StoredProcedureDecoder()
{
}
-
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java
index b37e0a4..9f467c6 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return StoredProcedureRequest.EXTENSION_OID;
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StoredProcedureResponse newResponse( byte[] encodedValue ) throws DecoderException
{
StoredProcedureResponseDecorator response = new StoredProcedureResponseDecorator( codec,
@@ -76,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StoredProcedureRequest newRequest( byte[] value )
{
StoredProcedureRequestDecorator req = new StoredProcedureRequestDecorator( codec );
@@ -91,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StoredProcedureRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof StoredProcedureRequestDecorator )
@@ -105,6 +109,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StoredProcedureResponseDecorator decorate( ExtendedResponse decoratedMessage )
{
if ( decoratedMessage instanceof StoredProcedureResponseDecorator )
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java
index 0298a6c..2e86b49 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java
@@ -242,7 +242,7 @@
{
public void action( StoredProcedureContainer container ) throws DecoderException
{
- StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
+ StoredProcedureContainer storedProcedureContainer = container;
TLV tlv = storedProcedureContainer.getCurrentTLV();
StoredProcedureRequestDecorator storedProcedure = storedProcedureContainer.getStoredProcedure();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java
index 45aed8c..f783f88 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java
@@ -61,19 +61,22 @@
/** The list of all parameter lengths */
private List<Integer> parameterLength;
- /** The list of all parameter type lengths */
- private List<Integer> paramTypeLength;
- /** The list of all parameter value lengths */
- private List<Integer> paramValueLength;
-
-
+ /**
+ * Create a new StoredProcedureRequestDecorator instance
+ * @param codec The LDAP API service to use
+ */
public StoredProcedureRequestDecorator( LdapApiService codec )
{
super( codec, new StoredProcedureRequestImpl() );
}
+ /**
+ * Create a new StoredProcedureRequestDecorator instance
+ * @param codec The LDAP API service to use
+ * @param decoratedRequest The decorated request
+ */
public StoredProcedureRequestDecorator( LdapApiService codec, StoredProcedureRequest decoratedRequest )
{
super( codec, decoratedRequest );
@@ -84,12 +87,20 @@
}
+ /**
+ * @return The current parameter
+ */
public StoredProcedureParameter getCurrentParameter()
{
return currentParameter;
}
+ /**
+ * Sets the current parameter
+ *
+ * @param currentParameter The current parameter
+ */
public void setCurrentParameter( StoredProcedureParameter currentParameter )
{
this.currentParameter = currentParameter;
@@ -140,15 +151,13 @@
// Compute parameters length value
if ( getDecorated().getParameters() != null )
{
- parameterLength = new LinkedList<Integer>();
- paramTypeLength = new LinkedList<Integer>();
- paramValueLength = new LinkedList<Integer>();
+ parameterLength = new LinkedList<>();
for ( StoredProcedureParameter spParam : getDecorated().getParameters() )
{
- int localParameterLength = 0;
- int localParamTypeLength = 0;
- int localParamValueLength = 0;
+ int localParameterLength;
+ int localParamTypeLength;
+ int localParamValueLength;
localParamTypeLength = 1 + TLV.getNbBytes( spParam.getType().length ) + spParam.getType().length;
localParamValueLength = 1 + TLV.getNbBytes( spParam.getValue().length ) + spParam.getValue().length;
@@ -158,8 +167,6 @@
parametersLength += 1 + TLV.getNbBytes( localParameterLength ) + localParameterLength;
parameterLength.add( localParameterLength );
- paramTypeLength.add( localParamTypeLength );
- paramValueLength.add( localParamValueLength );
}
}
@@ -198,7 +205,7 @@
bb.put( TLV.getBytes( parametersLength ) );
// The parameters list
- if ( ( getDecorated().getParameters() != null ) && ( getDecorated().getParameters().size() != 0 ) )
+ if ( ( getDecorated().getParameters() != null ) && ( !getDecorated().getParameters().isEmpty() ) )
{
int parameterNumber = 0;
@@ -215,7 +222,7 @@
// The parameter value
BerValue.encode( bb, spParam.getValue() );
- // Go to the next parameter;
+ // Go to the next parameter
parameterNumber++;
}
}
@@ -234,16 +241,16 @@
*
* @return The StoredProcedure string
*/
+ @Override
public String toString()
{
-
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " StoredProcedure\n" );
sb.append( " Language : '" ).append( getDecorated().getLanguage() ).append( "'\n" );
sb.append( " Procedure\n" ).append( getDecorated().getProcedureSpecification() ).append( "'\n" );
- if ( ( getDecorated().getParameters() == null ) || ( getDecorated().getParameters().size() == 0 ) )
+ if ( ( getDecorated().getParameters() == null ) || ( !getDecorated().getParameters().isEmpty() ) )
{
sb.append( " No parameters\n" );
}
@@ -266,6 +273,7 @@
}
+ @Override
public void setProcedure( byte[] procedure )
{
getDecorated().setProcedure( procedure );
@@ -275,6 +283,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRequestValue( byte[] payload )
{
StoredProcedureDecoder decoder = new StoredProcedureDecoder();
@@ -297,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getRequestValue()
{
if ( requestValue == null )
@@ -319,6 +329,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getLanguage()
{
return getDecorated().getLanguage();
@@ -328,6 +339,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setLanguage( String language )
{
getDecorated().setLanguage( language );
@@ -337,6 +349,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getProcedureSpecification()
{
return getDecorated().getProcedureSpecification();
@@ -346,6 +359,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return getDecorated().size();
@@ -355,6 +369,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object getParameterType( int index )
{
return getDecorated().getParameterType( index );
@@ -365,6 +380,7 @@
* {@inheritDoc}
*/
+ @Override
public Class<?> getJavaParameterType( int index )
{
return getDecorated().getJavaParameterType( index );
@@ -375,6 +391,7 @@
* {@inheritDoc}
*/
+ @Override
public Object getParameterValue( int index )
{
return getDecorated().getParameterValue( index );
@@ -384,6 +401,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object getJavaParameterValue( int index )
{
return getDecorated().getJavaParameterValue( index );
@@ -393,6 +411,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addParameter( Object type, Object value )
{
getDecorated().addParameter( type, value );
@@ -402,6 +421,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getProcedure()
{
return getDecorated().getProcedure();
@@ -411,6 +431,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<StoredProcedureParameter> getParameters()
{
return getDecorated().getParameters();
@@ -420,6 +441,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addParameter( StoredProcedureParameter parameter )
{
getDecorated().addParameter( parameter );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java
index ab6f1e5..715fd28 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java
@@ -21,7 +21,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -75,21 +74,10 @@
/**
* Get the grammar name
- * @param grammar The grammar code
+ *
* @return The grammar name
*/
- public String getGrammarName( int grammar )
- {
- return "STORED_PROCEDURE_GRAMMAR";
- }
-
-
- /**
- * Get the grammar name
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<StoredProcedureContainer> grammar )
+ public String getGrammarName()
{
return "STORED_PROCEDURE_GRAMMAR";
}
@@ -103,13 +91,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "STORED_PROCEDURE_END_STATE" : name() );
+ return ( state == END_STATE.ordinal() ) ? "STORED_PROCEDURE_END_STATE" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -119,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StoredProcedureStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
index fdb26f7..52f0d36 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
@@ -49,6 +49,11 @@
private LdapApiService codec;
+ /**
+ * Creates a new instance of WhoAmIFactory.
+ *
+ * @param codec The codec for this factory.
+ */
public WhoAmIFactory( LdapApiService codec )
{
this.codec = codec;
@@ -58,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return WhoAmIRequest.EXTENSION_OID;
@@ -67,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public WhoAmIResponse newResponse( byte[] encodedValue ) throws DecoderException
{
WhoAmIResponseDecorator response = new WhoAmIResponseDecorator( codec,
@@ -79,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public WhoAmIRequest newRequest( byte[] value )
{
WhoAmIRequestDecorator req = new WhoAmIRequestDecorator( codec, new WhoAmIRequestImpl() );
@@ -95,6 +103,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public WhoAmIRequestDecorator decorate( ExtendedRequest modelRequest )
{
if ( modelRequest instanceof WhoAmIRequestDecorator )
@@ -109,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public WhoAmIResponseDecorator decorate( ExtendedResponse decoratedResponse )
{
if ( decoratedResponse instanceof WhoAmIResponseDecorator )
@@ -159,8 +169,6 @@
stackTrace );
}
- WhoAmIResponseDecorator decorated = new WhoAmIResponseDecorator( codec, whoAmIResponse );
-
- return decorated;
+ return new WhoAmIResponseDecorator( codec, whoAmIResponse );
}
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseContainer.java
index 6f9c6cd..7e3f306 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseContainer.java
@@ -70,6 +70,7 @@
/**
* Clean the container for the next decoding.
*/
+ @Override
public void clean()
{
super.clean();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseDecorator.java
index 6ba843a..787b136 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseDecorator.java
@@ -114,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getAuthzId()
{
return getDecorated().getAuthzId();
@@ -123,6 +124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setAuthzId( byte[] authzId )
{
( ( WhoAmIResponseImpl ) getDecorated() ).setAuthzId( authzId );
@@ -150,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDnAuthzId()
{
return whoAmIResponse.isDnAuthzId();
@@ -159,6 +162,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isUserAuthzId()
{
return whoAmIResponse.isUserAuthzId();
@@ -168,6 +172,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getAuthzIdString()
{
return whoAmIResponse.getAuthzIdString();
@@ -177,6 +182,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getUserId()
{
return whoAmIResponse.getUserId();
@@ -186,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getDn()
{
return whoAmIResponse.getDn();
@@ -196,6 +203,7 @@
* Overload the parent's getResponseName method, as the WhoAmI response should not
* contain the responseName.
*/
+ @Override
public String getResponseName()
{
return null;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseGrammar.java
index ed171c1..d12951e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseGrammar.java
@@ -59,6 +59,9 @@
private static Grammar<WhoAmIResponseContainer> instance = new WhoAmIResponseGrammar();
+ /**
+ * Creates a new WhoAmIResponseGrammar object.
+ */
@SuppressWarnings("unchecked")
public WhoAmIResponseGrammar()
{
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseStatesEnum.java
index f3da5cb..783e4fb 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseStatesEnum.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.extras.extended.ads_impl.whoAmI;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
import org.apache.directory.api.asn1.ber.grammar.States;
@@ -45,25 +44,13 @@
/** Last state */
LAST_WHO_AM_I_RESPONSE_STATE;
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<WhoAmIResponseContainer> grammar )
- {
- return "WHO_AM_I_RESPONSE_GRAMMER";
- }
-
/**
* Get the grammar name
*
- * @param grammar The grammar code
* @return The grammar name
*/
- public String getGrammarName( int grammar )
+ public String getGrammarName()
{
return "WHO_AM_I_RESPONSE_GRAMMER";
}
@@ -77,13 +64,14 @@
*/
public String getState( int state )
{
- return ( ( state == END_STATE.ordinal() ) ? "WHO_AM_I_RESPONSE_GRAMMER" : this.name() );
+ return ( state == END_STATE.ordinal() ) ? "WHO_AM_I_RESPONSE_GRAMMER" : name();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEndState()
{
return this == END_STATE;
@@ -93,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public WhoAmIResponseStatesEnum getStartState()
{
return START_STATE;
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
index 4e674fa..0a84420 100644
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
@@ -24,6 +24,7 @@
import static org.junit.Assert.fail;
import java.nio.ByteBuffer;
+import java.util.EnumSet;
import org.apache.directory.api.asn1.DecoderException;
import org.apache.directory.api.asn1.EncoderException;
@@ -50,12 +51,12 @@
@Test
public void testAdDirSyncControl() throws Exception
{
- ByteBuffer bb = ByteBuffer.allocate( 0x0E );
+ ByteBuffer bb = ByteBuffer.allocate( 0x0F );
bb.put( new byte[]
{
- 0x30, 0x0C,
- 0x02, 0x01, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
+ 0x30, 0x0D,
+ 0x02, 0x02, 0x08, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY, LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER)
0x02, 0x01, 0x00, // maxReturnLength (no limit)
0x04, 0x04, 'x', 'k', 'c', 'd' // the cookie
} );
@@ -66,18 +67,19 @@
AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
- assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSync.getFlag() );
+ assertEquals( EnumSet.of(
+ AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY,
+ AdDirSyncFlag.LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER ),
+ adDirSync.getFlags() );
assertEquals( 0, adDirSync.getMaxReturnLength() );
assertEquals( "xkcd", Strings.utf8ToString( adDirSync.getCookie() ) );
// test encoding
- adDirSync.setParentFirst( 1 );
-
try
{
ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
.allocate( ( ( AdDirSyncDecorator ) adDirSync ).computeLength() ) );
- String expected = "0x30 0x0C 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
+ String expected = "0x30 0x0D 0x02 0x02 0x08 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( expected, decoded );
}
@@ -107,13 +109,11 @@
AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
- assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSync.getFlag() );
+ assertEquals( EnumSet.of( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY ), adDirSync.getFlags() );
assertEquals( 0, adDirSync.getMaxReturnLength() );
assertEquals( "", Strings.utf8ToString( adDirSync.getCookie() ) );
// test encoding
- adDirSync.setParentFirst( 1 );
-
try
{
ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
diff --git a/ldap/extras/pom.xml b/ldap/extras/pom.xml
index 23bb185..c624dfb 100644
--- a/ldap/extras/pom.xml
+++ b/ldap/extras/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-parent</artifactId>
diff --git a/ldap/extras/sp/pom.xml b/ldap/extras/sp/pom.xml
index 6b1de5d..2fc0a9a 100644
--- a/ldap/extras/sp/pom.xml
+++ b/ldap/extras/sp/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-sp</artifactId>
diff --git a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
index 33e6597..ba6c515 100644
--- a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
+++ b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
@@ -148,12 +148,22 @@
}
+ /**
+ * Invoke a Stored Procedure
+ *
+ * @param ctx The execution context
+ * @param procedureName The procedure to execute
+ * @param arguments The procedure's arguments
+ * @return The execution resut
+ * @throws NamingException If we have had an error whil executing the stored procedure
+ */
public static Object callStoredProcedure( LdapContext ctx, String procedureName, Object[] arguments )
throws NamingException
{
String language = "Java";
Object responseObject;
+
try
{
/**
@@ -197,5 +207,4 @@
return responseObject;
}
-
}
diff --git a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/LdapContextParameter.java b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/LdapContextParameter.java
index a252b15..4295155 100644
--- a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/LdapContextParameter.java
+++ b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/LdapContextParameter.java
@@ -33,15 +33,24 @@
{
private static final long serialVersionUID = -8703671542595407603L;
+ /** The parameter name */
private String name;
+ /**
+ * Creates a new LdapContextParameter instance
+ *
+ * @param name The parameter name
+ */
public LdapContextParameter( String name )
{
this.name = name;
}
+ /**
+ * @return The parameter's name
+ */
public String getValue()
{
return name;
diff --git a/ldap/extras/trigger/pom.xml b/ldap/extras/trigger/pom.xml
index 300764e..7ee6602 100644
--- a/ldap/extras/trigger/pom.xml
+++ b/ldap/extras/trigger/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-trigger</artifactId>
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/LdapOperation.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/LdapOperation.java
index 0d2d4c1..ec23c65 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/LdapOperation.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/LdapOperation.java
@@ -28,18 +28,25 @@
*/
public enum LdapOperation
{
+ /** The Modify operation */
MODIFY("Modify"),
+ /** The Add operation */
ADD("Add"),
+ /** The Delete operation */
DELETE("Delete"),
+ /** The ModDN operation */
MODIFYDN("ModifyDN"),
+ /** The Rename operation */
MODIFYDN_RENAME("ModifyDN.Rename"),
+ /** The Export operation */
MODIFYDN_EXPORT("ModifyDN.Export"),
+ /** The Import operation */
MODIFYDN_IMPORT("ModifyDN.Import");
private final String name;
@@ -66,6 +73,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public String toString()
{
return name;
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationLexer.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationLexer.java
index 5c8035c..f3209ce 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationLexer.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationLexer.java
@@ -53,7 +53,7 @@
* @param in
* the input to the lexer
*/
- public ReusableAntlrTriggerSpecificationLexer( Reader in )
+ ReusableAntlrTriggerSpecificationLexer( Reader in )
{
super( in );
savedCaseSensitive = getCaseSensitive();
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationParser.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationParser.java
index a9ba80b..72113ae 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationParser.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/ReusableAntlrTriggerSpecificationParser.java
@@ -42,7 +42,7 @@
/**
* Creates a ReusableAntlrTriggerSpecificationParser instance.
*/
- public ReusableAntlrTriggerSpecificationParser( TokenStream lexer )
+ ReusableAntlrTriggerSpecificationParser( TokenStream lexer )
{
super( lexer );
}
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/StoredProcedureParameter.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/StoredProcedureParameter.java
index 80804b3..6d2b6b7 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/StoredProcedureParameter.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/StoredProcedureParameter.java
@@ -31,6 +31,9 @@
*/
public abstract class StoredProcedureParameter
{
+ /**
+ * The generic LdapContext factory
+ */
public static final class Generic_LDAP_CONTEXT extends StoredProcedureParameter
{
private Dn ctxName;
@@ -43,24 +46,41 @@
}
+ /**
+ * Creates a new instance of StoredProcedureParameter
+ *
+ * @param ctxName The context name
+ * @return A new instance of StoredProcedureParameter
+ */
public static StoredProcedureParameter instance( Dn ctxName )
{
return new Generic_LDAP_CONTEXT( ctxName );
}
+ /**
+ * @return The context name
+ */
public Dn getCtxName()
{
return ctxName;
}
+ /**
+ * @see Object#toString()
+ */
+ @Override
public String toString()
{
return name + " \"" + ctxName.getName() + "\"";
}
}
+
+ /**
+ * The generic Operation Principal factory
+ */
public static final class Generic_OPERATION_PRINCIPAL extends StoredProcedureParameter
{
private static Generic_OPERATION_PRINCIPAL instance = new Generic_OPERATION_PRINCIPAL( "$operationPrincipal" );
@@ -72,6 +92,9 @@
}
+ /**
+ * @return The generic Operation Principal instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
@@ -96,6 +119,7 @@
}
+ @Override
public String toString()
{
return name;
@@ -106,6 +130,7 @@
* @see java.lang.Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -119,21 +144,26 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
+
if ( obj == null )
{
return false;
}
+
if ( getClass() != obj.getClass() )
{
return false;
}
- final StoredProcedureParameter other = ( StoredProcedureParameter ) obj;
+
+ StoredProcedureParameter other = ( StoredProcedureParameter ) obj;
+
if ( name == null )
{
if ( other.name != null )
@@ -145,9 +175,14 @@
{
return false;
}
+
return true;
}
+
+ /**
+ * The Modify Object factory
+ */
public static final class Modify_OBJECT extends StoredProcedureParameter
{
private static Modify_OBJECT instance = new Modify_OBJECT( "$object" );
@@ -159,12 +194,19 @@
}
+ /**
+ * @return The Modify Object instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify Modification factory
+ */
public static final class Modify_MODIFICATION extends StoredProcedureParameter
{
private static Modify_MODIFICATION instance = new Modify_MODIFICATION( "$modification" );
@@ -176,12 +218,19 @@
}
+ /**
+ * @return The Modify Modification instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify Old Entry factory
+ */
public static final class Modify_OLD_ENTRY extends StoredProcedureParameter
{
private static Modify_OLD_ENTRY instance = new Modify_OLD_ENTRY( "$oldEntry" );
@@ -193,12 +242,19 @@
}
+ /**
+ * @return The Modify Old Entry instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify New Entry factory
+ */
public static final class Modify_NEW_ENTRY extends StoredProcedureParameter
{
private static Modify_NEW_ENTRY instance = new Modify_NEW_ENTRY( "$newEntry" );
@@ -210,12 +266,19 @@
}
+ /**
+ * @return The Modify New Entry instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Add Entry factory
+ */
public static final class Add_ENTRY extends StoredProcedureParameter
{
private static Add_ENTRY instance = new Add_ENTRY( "$entry" );
@@ -227,12 +290,19 @@
}
+ /**
+ * @return The Add Entry instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Add Attributes factory
+ */
public static final class Add_ATTRIBUTES extends StoredProcedureParameter
{
private static Add_ATTRIBUTES instance = new Add_ATTRIBUTES( "$attributes" );
@@ -244,12 +314,19 @@
}
+ /**
+ * @return The Add Attributes instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Delete Name factory
+ */
public static final class Delete_NAME extends StoredProcedureParameter
{
private static Delete_NAME instance = new Delete_NAME( "$name" );
@@ -261,12 +338,19 @@
}
+ /**
+ * @return The Delete Name instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Delete Deleted factory
+ */
public static final class Delete_DELETED_ENTRY extends StoredProcedureParameter
{
private static Delete_DELETED_ENTRY instance = new Delete_DELETED_ENTRY( "$deletedEntry" );
@@ -278,12 +362,19 @@
}
+ /**
+ * @return The Delete Deleted instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify DN Entry factory
+ */
public static final class ModifyDN_ENTRY extends StoredProcedureParameter
{
private static ModifyDN_ENTRY instance = new ModifyDN_ENTRY( "$entry" );
@@ -295,12 +386,19 @@
}
+ /**
+ * @return The Modify DN Entry instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify New Rdn factory
+ */
public static final class ModifyDN_NEW_RDN extends StoredProcedureParameter
{
private static ModifyDN_NEW_RDN instance = new ModifyDN_NEW_RDN( "$newrdn" );
@@ -312,12 +410,19 @@
}
+ /**
+ * @return The Modify New Rdn instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify DN Delete Old RDN factory
+ */
public static final class ModifyDN_DELETE_OLD_RDN extends StoredProcedureParameter
{
private static ModifyDN_DELETE_OLD_RDN instance = new ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" );
@@ -329,12 +434,19 @@
}
+ /**
+ * @return The Modify DN Delete Old RDN instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify DN New Superior factory
+ */
public static final class ModifyDN_NEW_SUPERIOR extends StoredProcedureParameter
{
private static ModifyDN_NEW_SUPERIOR instance = new ModifyDN_NEW_SUPERIOR( "$newSuperior" );
@@ -346,12 +458,19 @@
}
+ /**
+ * @return The Modify DN New Superior instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify DN Old RDN factory
+ */
public static final class ModifyDN_OLD_RDN extends StoredProcedureParameter
{
private static ModifyDN_OLD_RDN instance = new ModifyDN_OLD_RDN( "$oldRDN" );
@@ -363,12 +482,19 @@
}
+ /**
+ * @return The Modify DN Old RDN instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
+ /**
+ * The Modify DN Old Superior DN factory
+ */
public static final class ModifyDN_OLD_SUPERIOR_DN extends StoredProcedureParameter
{
private static ModifyDN_OLD_SUPERIOR_DN instance = new ModifyDN_OLD_SUPERIOR_DN( "$oldRDN" );
@@ -380,16 +506,18 @@
}
+ /**
+ * @return The Modify DN Old Superior DN instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
}
}
+
/**
- *
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * The Modify DN New DN factory
*/
public static final class ModifyDN_NEW_DN extends StoredProcedureParameter
{
@@ -402,6 +530,9 @@
}
+ /**
+ * @return The Modify DN New DN instance
+ */
public static StoredProcedureParameter instance()
{
return instance;
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerSpecification.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerSpecification.java
index 240cde8..b335c2c 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerSpecification.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerSpecification.java
@@ -52,16 +52,17 @@
public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, List<SPSpec> spSpecs )
{
super();
- if ( ldapOperation == null
- || actionTime == null
- || spSpecs == null )
+
+ if ( ( ldapOperation == null ) || ( actionTime == null ) || ( spSpecs == null ) )
{
throw new NullArgumentException( I18n.err( I18n.ERR_04331 ) );
}
- if ( spSpecs.size() == 0 )
+
+ if ( spSpecs.isEmpty() )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_04332 ) );
}
+
this.ldapOperation = ldapOperation;
this.actionTime = actionTime;
this.spSpecs = spSpecs;
diff --git a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerUtils.java b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerUtils.java
index 150d40a..322fde0 100644
--- a/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerUtils.java
+++ b/ldap/extras/trigger/src/main/java/org/apache/directory/api/ldap/trigger/TriggerUtils.java
@@ -41,12 +41,6 @@
*/
public final class TriggerUtils
{
- public static final String TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE = SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA;
- public static final String TRIGGER_EXECUTION_SUBENTRY_OC = "triggerExecutionSubentry";
- public static final String ENTRY_TRIGGER_SPECIFICATION_ATTR = "entryTriggerSpecification";
- public static final String PRESCRIPTIVE_TRIGGER_SPECIFICATION_ATTR = "prescriptiveTriggerSpecification";
-
-
/**
* Private constructor.
*/
@@ -55,21 +49,35 @@
}
+ /**
+ * Defines the Administration point and administrative role for the TriggerExecution specific point
+ * @param apCtx The administrative point context
+ * @throws NamingException If the operation failed
+ */
public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
{
- Attributes ap = apCtx.getAttributes( "", new String[]
- { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
+ Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
- if ( administrativeRole == null
- || !AttributeUtils.containsValueCaseIgnore( administrativeRole, TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE ) )
+
+ if ( ( administrativeRole == null )
+ || !AttributeUtils.containsValueCaseIgnore( administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA ) )
{
Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
- TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE, true );
+ SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true );
apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
}
+ /**
+ * Create the Trigger execution subentry
+ *
+ * @param apCtx The administration point context
+ * @param subentryCN The CN used by the suentry
+ * @param subtreeSpec The subtree specification
+ * @param prescriptiveTriggerSpec The prescriptive trigger specification
+ * @throws NamingException If the operation failed
+ */
public static void createTriggerExecutionSubentry(
LdapContext apCtx,
String subentryCN,
@@ -81,28 +89,43 @@
subentry.put( objectClass );
objectClass.add( SchemaConstants.TOP_OC );
objectClass.add( SchemaConstants.SUBENTRY_OC );
- objectClass.add( TRIGGER_EXECUTION_SUBENTRY_OC );
+ objectClass.add( SchemaConstants.TRIGGER_EXECUTION_SUBENTRY_OC );
subentry.put( SchemaConstants.SUBTREE_SPECIFICATION_AT, subtreeSpec );
- subentry.put( PRESCRIPTIVE_TRIGGER_SPECIFICATION_ATTR, prescriptiveTriggerSpec );
+ subentry.put( SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, prescriptiveTriggerSpec );
apCtx.createSubcontext( "cn=" + subentryCN, subentry );
}
+ /**
+ * Load an prescriptive trigger specification
+ *
+ * @param apCtx The administrative point context
+ * @param subentryCN The subentry CN
+ * @param triggerSpec The trigger specification
+ * @throws NamingException If the operation failed
+ */
public static void loadPrescriptiveTriggerSpecification(
LdapContext apCtx,
String subentryCN,
String triggerSpec ) throws NamingException
{
- Attributes changes = new BasicAttributes( PRESCRIPTIVE_TRIGGER_SPECIFICATION_ATTR, triggerSpec, true );
+ Attributes changes = new BasicAttributes( SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, triggerSpec, true );
apCtx.modifyAttributes( "cn=" + subentryCN, DirContext.ADD_ATTRIBUTE, changes );
}
+ /**
+ * Load the trigger specification entry
+ *
+ * @param ctx The context
+ * @param triggerSpec The trigger specification
+ * @throws NamingException If the operation failed
+ */
public static void loadEntryTriggerSpecification(
LdapContext ctx,
String triggerSpec ) throws NamingException
{
- Attributes changes = new BasicAttributes( ENTRY_TRIGGER_SPECIFICATION_ATTR, triggerSpec, true );
+ Attributes changes = new BasicAttributes( SchemaConstants.ENTRY_TRIGGER_SPECIFICATION_AT, triggerSpec, true );
ctx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
}
diff --git a/ldap/extras/util/pom.xml b/ldap/extras/util/pom.xml
index 5f03854..dd8775b 100644
--- a/ldap/extras/util/pom.xml
+++ b/ldap/extras/util/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-extras-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-extras-util</artifactId>
diff --git a/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/JndiUtils.java b/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/JndiUtils.java
index 4bf71b6..b906e45 100644
--- a/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/JndiUtils.java
+++ b/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/JndiUtils.java
@@ -93,7 +93,15 @@
}
- // @TODO not really needed and can be moved out
+ /**
+ * Convert a LDAP API control to a JNDI control
+ * @param codec The LDAP API service to use
+ * @param control The control to convert
+ * @return A JNDI control
+ * @throws EncoderException If the conversion failed
+ * @deprecated We don't use JNDI anymore
+ */
+ @Deprecated
public static javax.naming.ldap.Control toJndiControl( LdapApiService codec, Control control )
throws EncoderException
{
@@ -101,7 +109,15 @@
}
- // @TODO not really needed and can be moved out
+ /**
+ * Convert some LDAP API controls to JNDI controls
+ * @param codec The LDAP API service to use
+ * @param controls The controls to convert
+ * @return Array of JNDI control
+ * @throws EncoderException If the conversion failed
+ * @deprecated We don't use JNDI anymore
+ */
+ @Deprecated
public static javax.naming.ldap.Control[] toJndiControls( LdapApiService codec, Control... controls )
throws EncoderException
{
@@ -124,7 +140,15 @@
}
- // @TODO not really needed and can be moved out
+ /**
+ * Convert a JNDI control to a LDAP API control
+ * @param codec The LDAP API service to use
+ * @param jndiControl The control to convert
+ * @return A LDAP API control
+ * @throws DecoderException If the conversion failed
+ * @deprecated We don't use JNDI anymore
+ */
+ @Deprecated
public static Control fromJndiControl( LdapApiService codec, javax.naming.ldap.Control jndiControl )
throws DecoderException
{
@@ -132,7 +156,15 @@
}
- // @TODO not really needed and can be moved out
+ /**
+ * Convert some JNDI controls to LDAP API controls
+ * @param codec The LDAP API service to use
+ * @param jndiControls The controls to convert
+ * @return An array of LDAP API control
+ * @throws DecoderException If the conversion failed
+ * @deprecated We don't use JNDI anymore
+ */
+ @Deprecated
public static Control[] fromJndiControls( LdapApiService codec, javax.naming.ldap.Control... jndiControls )
throws DecoderException
{
@@ -155,6 +187,12 @@
}
+ /**
+ * Wraps a LDAP exception into a NaingException
+ *
+ * @param t The original exception
+ * @throws NamingException The wrapping JNDI exception
+ */
public static void wrap( Throwable t ) throws NamingException
{
if ( t instanceof NamingException )
@@ -285,9 +323,7 @@
{
try
{
- Name name = new LdapName( dn.toString() );
-
- return name;
+ return new LdapName( dn.toString() );
}
catch ( InvalidNameException ine )
{
@@ -329,7 +365,7 @@
private LdapReferralException lre;
- public WrappedReferralException( LdapReferralException lre )
+ WrappedReferralException( LdapReferralException lre )
{
this.lre = lre;
}
@@ -399,7 +435,7 @@
private LdapPartialResultException lpre;
- public WrappedPartialResultException( LdapPartialResultException lpre )
+ WrappedPartialResultException( LdapPartialResultException lpre )
{
this.lpre = lpre;
}
diff --git a/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/tree/DnNode.java b/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/tree/DnNode.java
index 5c3cc6a..f9a5c63 100644
--- a/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/tree/DnNode.java
+++ b/ldap/extras/util/src/main/java/org/apache/directory/api/ldap/util/tree/DnNode.java
@@ -47,7 +47,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @param <N> The type of node we store
*/
-public class DnNode<N> implements Cloneable
+public class DnNode<N>
{
/** The logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( DnNode.class );
@@ -72,77 +72,6 @@
//-------------------------------------------------------------------------
- // Helper methods
- //-------------------------------------------------------------------------
- /**
- * Check that the Dn is not null
- */
- private void checkDn( Dn dn ) throws LdapException
- {
- if ( ( dn == null ) || dn.isEmpty() )
- {
- String message = "Cannot process an empty Dn";
- LOG.error( message );
- throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, message );
- }
- }
-
-
- /**
- * Create a new DnNode, recursively creating all the intermediate nodes.
- */
- private DnNode<N> createNode( Dn dn, N element, int nbRdns ) throws LdapException
- {
- checkDn( dn );
-
- DnNode<N> rootNode = null;
-
- // No parent : add from the current position
- for ( Rdn rdn : dn.getRdns() )
- {
- if ( nbRdns == 0 )
- {
- break;
- }
-
- if ( rootNode == null )
- {
- // Create the new top node
- DnNode<N> node = new DnNode<N>( element );
- node.nodeRdn = rdn;
- node.nodeDn = dn;
- node.depth = dn.size() + depth;
-
- rootNode = node;
- }
- else
- {
- DnNode<N> node = new DnNode<N>();
- node.nodeRdn = rdn;
- node.nodeDn = rootNode.nodeDn.getParent();
- node.depth = node.nodeDn.size() + depth;
- rootNode.parent = node;
- node.children.put( rootNode.nodeRdn, rootNode );
- rootNode = node;
- }
-
- nbRdns--;
- }
-
- return rootNode;
- }
-
-
- /**
- * Store the given element into the node
- */
- private synchronized void setElement( N element )
- {
- this.nodeElement = element;
- }
-
-
- //-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
/**
@@ -204,6 +133,77 @@
}
+ //-------------------------------------------------------------------------
+ // Helper methods
+ //-------------------------------------------------------------------------
+ /**
+ * Check that the Dn is not null
+ */
+ private void checkDn( Dn dn ) throws LdapException
+ {
+ if ( ( dn == null ) || dn.isEmpty() )
+ {
+ String message = "Cannot process an empty Dn";
+ LOG.error( message );
+ throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, message );
+ }
+ }
+
+
+ /**
+ * Create a new DnNode, recursively creating all the intermediate nodes.
+ */
+ private DnNode<N> createNode( Dn dn, N element, int nbRdns ) throws LdapException
+ {
+ checkDn( dn );
+
+ DnNode<N> rootNode = null;
+
+ // No parent : add from the current position
+ for ( Rdn rdn : dn.getRdns() )
+ {
+ if ( nbRdns == 0 )
+ {
+ break;
+ }
+
+ if ( rootNode == null )
+ {
+ // Create the new top node
+ DnNode<N> node = new DnNode<>( element );
+ node.nodeRdn = rdn;
+ node.nodeDn = dn;
+ node.depth = dn.size() + depth;
+
+ rootNode = node;
+ }
+ else
+ {
+ DnNode<N> node = new DnNode<>();
+ node.nodeRdn = rdn;
+ node.nodeDn = rootNode.nodeDn.getParent();
+ node.depth = node.nodeDn.size() + depth;
+ rootNode.parent = node;
+ node.children.put( rootNode.nodeRdn, rootNode );
+ rootNode = node;
+ }
+
+ nbRdns--;
+ }
+
+ return rootNode;
+ }
+
+
+ /**
+ * Store the given element into the node
+ */
+ private synchronized void setElement( N element )
+ {
+ this.nodeElement = element;
+ }
+
+
/**
* Tells if the implementation is a leaf node. If it's a branch node
* then false is returned.
@@ -409,7 +409,7 @@
*/
public synchronized List<N> getDescendantElements( Dn dn )
{
- List<N> descendants = new ArrayList<N>();
+ List<N> descendants = new ArrayList<>();
DnNode<N> node = getNode( dn );
@@ -534,7 +534,7 @@
}
}
- return ( parentNode != null );
+ return parentNode != null;
}
@@ -970,28 +970,6 @@
}
- /**
- * {@inheritDoc}
- */
- public synchronized DnNode<N> clone()
- {
- DnNode<N> clonedDnNode = new DnNode<N>();
-
- clonedDnNode.nodeElement = nodeElement;
- clonedDnNode.depth = depth;
- clonedDnNode.parent = parent;
- clonedDnNode.nodeRdn = nodeRdn;
- clonedDnNode.nodeDn = nodeDn;
-
- for ( DnNode<N> node : children.values() )
- {
- clonedDnNode.children.put( node.getRdn(), node.clone() );
- }
-
- return clonedDnNode;
- }
-
-
private String toString( String tabs )
{
if ( nodeRdn == null )
@@ -1049,6 +1027,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return toString( "" );
diff --git a/ldap/model/pom.xml b/ldap/model/pom.xml
index f5fcd5f..52084aa 100644
--- a/ldap/model/pom.xml
+++ b/ldap/model/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-model</artifactId>
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/AuthenticationLevel.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/AuthenticationLevel.java
index 6a3cc75..9405dc1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/AuthenticationLevel.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/AuthenticationLevel.java
@@ -70,7 +70,7 @@
* @param level The level
* @param name The associated name
*/
- private AuthenticationLevel( int level, String name )
+ AuthenticationLevel( int level, String name )
{
this.level = level;
this.name = name;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/LdapSecurityConstants.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/LdapSecurityConstants.java
index 6d58ab9..a95622a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/LdapSecurityConstants.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/LdapSecurityConstants.java
@@ -68,6 +68,9 @@
/** The crypt (SHA-512) encryption method */
HASH_METHOD_CRYPT_SHA512("CRYPT-SHA-512", "SHA-512", "crypt", "$6$"),
+
+ /** The BCrypt encryption method */
+ HASH_METHOD_CRYPT_BCRYPT("CRYPT-BCRYPT", "BCRYPT", "crypt", "$2a$"),
/** The PBKDF2-based encryption method */
HASH_METHOD_PKCS5S2("PKCS5S2", "PBKDF2WithHmacSHA1", "PKCS5S2");
@@ -106,7 +109,7 @@
* @param algorithm the associated algorithm
* @param prefix the associated prefix
*/
- private LdapSecurityConstants( String name, String algorithm, String prefix )
+ LdapSecurityConstants( String name, String algorithm, String prefix )
{
this( name, algorithm, prefix, "" );
}
@@ -119,7 +122,7 @@
* @param prefix the associated prefix
* @param subPrefix the optional sub-prefix
*/
- private LdapSecurityConstants( String name, String algorithm, String prefix, String subPrefix )
+ LdapSecurityConstants( String name, String algorithm, String prefix, String subPrefix )
{
this.name = name;
this.algorithm = algorithm;
@@ -211,6 +214,11 @@
return HASH_METHOD_CRYPT_SHA512;
}
+ if ( matches( algorithm, HASH_METHOD_CRYPT_BCRYPT ) )
+ {
+ return HASH_METHOD_CRYPT_BCRYPT;
+ }
+
if ( matches( algorithm, HASH_METHOD_SHA256 ) )
{
return HASH_METHOD_SHA256;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/Loggers.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/Loggers.java
index f70649c..096d3c1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/Loggers.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/Loggers.java
@@ -73,7 +73,7 @@
* Creates a new instance of LdapSecurityConstants.
* @param name the associated name
*/
- private Loggers( String name )
+ Loggers( String name )
{
this.name = name;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslQoP.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslQoP.java
index b5e8ebe..dd1012d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslQoP.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslQoP.java
@@ -45,7 +45,7 @@
*
* @param value the equivalent string value
*/
- private SaslQoP( String value )
+ SaslQoP( String value )
{
this.value = value;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslSecurityStrength.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslSecurityStrength.java
index a8fe4a5..7ff80b3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslSecurityStrength.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SaslSecurityStrength.java
@@ -46,7 +46,7 @@
* @param value
* the equivalent string value
*/
- private SaslSecurityStrength( String value )
+ SaslSecurityStrength( String value )
{
this.value = value;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SchemaConstants.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SchemaConstants.java
index ba26654..7cab7e9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SchemaConstants.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SchemaConstants.java
@@ -478,6 +478,10 @@
public static final String ACCESS_CONTROL_SUBENTRY_OC = "accessControlSubentry";
public static final String ACCESS_CONTROL_SUBENTRY_OC_OID = "2.5.17.1";
+ // TriggerExecutionSubentry
+ public static final String TRIGGER_EXECUTION_SUBENTRY_OC = "triggerExecutionSubentry";
+ public static final String TRIGGER_EXECUTION_SUBENTRY_OC_OID = "1.3.6.1.4.1.18060.0.4.1.2.28";
+
//-------------------------------------------------------------------------
// AttributeTypes for standard schemas are listed below. We cover the
// following schemas :
@@ -1585,6 +1589,14 @@
public static final String SUBENTRY_ACI_AT = "subentryACI";
public static final String SUBENTRY_ACI_AT_OID = "2.5.24.6";
+ // PrescriptiveTriggerSpecification
+ public static final String PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT = "prescriptiveTriggerSpecification";
+ public static final String PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT_OID = "1.3.6.1.4.1.18060.0.4.1.2.25";
+
+ // EntryTriggerSpecification
+ public static final String ENTRY_TRIGGER_SPECIFICATION_AT = "entryTriggerSpecification";
+ public static final String ENTRY_TRIGGER_SPECIFICATION_AT_OID = "1.3.6.1.4.1.18060.0.4.1.2.26";
+
// Comparators
public static final String COMPARATORS_AT = "comparators";
public static final String COMPARATORS_AT_OID = "1.3.6.1.4.1.18060.0.4.1.2.32";
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/csn/CsnFactory.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/csn/CsnFactory.java
index 50ba02e..7625f8c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/csn/CsnFactory.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/csn/CsnFactory.java
@@ -43,6 +43,10 @@
private Object lock = new Object();
+ /**
+ * Creates a new CsnFactory instance
+ * @param replicaId The replica ID
+ */
public CsnFactory( int replicaId )
{
changeCount = 0;
@@ -111,6 +115,10 @@
}
+ /**
+ * Sets the replica ID
+ * @param replicaId The replica ID
+ */
public void setReplicaId( int replicaId )
{
this.replicaId = replicaId;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/AbstractCursor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/AbstractCursor.java
index d1995a7..36518ec 100755
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/AbstractCursor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/AbstractCursor.java
@@ -40,6 +40,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setClosureMonitor( ClosureMonitor monitor )
{
if ( monitor == null )
@@ -66,6 +67,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isClosed()
{
return monitor.isClosed();
@@ -75,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close( Exception cause ) throws IOException
{
monitor.close( cause );
@@ -84,6 +87,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
monitor.close();
@@ -93,15 +97,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<E> iterator()
{
- return new CursorIterator<E>( this );
+ return new CursorIterator<>( this );
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAfterLast()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -112,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isBeforeFirst()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -122,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isFirst()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -132,6 +140,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isLast()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
@@ -142,6 +151,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString( String tabs )
{
return tabs;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java
index 1cd6b38..4d0d9c5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/CursorIterator.java
@@ -64,6 +64,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasNext()
{
return available;
@@ -73,12 +74,14 @@
/**
* {@inheritDoc}
*/
+ @Override
public E next()
{
try
{
E element = cursor.get();
available = cursor.next();
+
return element;
}
catch ( Exception e )
@@ -91,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void remove()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02003_REMOVAL_NOT_SUPPORTED ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/DefaultClosureMonitor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/DefaultClosureMonitor.java
index 5a8999b..74e608e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/DefaultClosureMonitor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/DefaultClosureMonitor.java
@@ -43,6 +43,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void close()
{
// state check needed to "try" not to overwrite exception (lack of
@@ -61,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void close( final String cause )
{
// state check needed to "try" not to overwrite exception (lack of
@@ -79,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void close( final Exception cause )
{
// state check needed to "try" not to overwrite exception (lack of
@@ -97,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final Exception getCause()
{
return cause;
@@ -106,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isClosed()
{
return closed;
@@ -115,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void checkNotClosed() throws CursorClosedException
{
// lack of synchronization may cause pass but eventually it will work
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/EmptyCursor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/EmptyCursor.java
index f0d9e23..2155ed7 100755
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/EmptyCursor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/EmptyCursor.java
@@ -43,6 +43,9 @@
private static final boolean IS_DEBUG = LOG_CURSOR.isDebugEnabled();
+ /**
+ * Creates a new EmptyCursor instance
+ */
public EmptyCursor()
{
if ( IS_DEBUG )
@@ -55,6 +58,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return false;
@@ -64,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void before( E element ) throws LdapException, CursorException
{
checkNotClosed( "before()" );
@@ -73,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void after( E element ) throws LdapException, CursorException
{
checkNotClosed( "after()" );
@@ -82,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
checkNotClosed( "beforeFirst()" );
@@ -91,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
checkNotClosed( "afterLast()" );
@@ -100,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
checkNotClosed( "first()" );
@@ -110,6 +119,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
checkNotClosed( "last()" );
@@ -120,6 +130,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
checkNotClosed( "previous()" );
@@ -130,6 +141,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
checkNotClosed( "next()" );
@@ -140,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E get() throws CursorException
{
checkNotClosed( "get()" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/ListCursor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/ListCursor.java
index 6d6fbbe..a364d65 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/ListCursor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/ListCursor.java
@@ -94,7 +94,7 @@
// check list is not empty list since the empty list is the only situation
// where we allow for start to equal the end: in other cases it makes no sense
- if ( ( list.size() > 0 ) && ( start >= end ) )
+ if ( !list.isEmpty() && ( start >= end ) )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_02007_START_INDEX_ABOVE_END_INDEX, start, end ) );
}
@@ -238,6 +238,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return index >= 0 && index < end;
@@ -247,6 +248,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void before( E element ) throws LdapException, CursorException
{
checkNotClosed( "before()" );
@@ -257,7 +259,7 @@
}
// handle some special cases
- if ( list.size() == 0 )
+ if ( list.isEmpty() )
{
return;
}
@@ -280,6 +282,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void after( E element ) throws LdapException, CursorException
{
checkNotClosed( "after()" );
@@ -290,7 +293,7 @@
}
// handle some special cases
- if ( list.size() == 0 )
+ if ( list.isEmpty() )
{
return;
}
@@ -313,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
checkNotClosed( "beforeFirst()" );
@@ -323,6 +327,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
checkNotClosed( "afterLast()" );
@@ -333,11 +338,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
checkNotClosed( "first()" );
- if ( list.size() > 0 )
+ if ( !list.isEmpty() )
{
index = start;
@@ -351,11 +357,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
checkNotClosed( "last()" );
- if ( list.size() > 0 )
+ if ( !list.isEmpty() )
{
index = end - 1;
@@ -372,7 +379,7 @@
@Override
public boolean isFirst()
{
- return list.size() > 0 && index == start;
+ return !list.isEmpty() && index == start;
}
@@ -382,7 +389,7 @@
@Override
public boolean isLast()
{
- return list.size() > 0 && index == end - 1;
+ return !list.isEmpty() && index == end - 1;
}
@@ -409,6 +416,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
checkNotClosed( "previous()" );
@@ -435,7 +443,7 @@
return false;
}
- if ( list.size() <= 0 )
+ if ( list.isEmpty() )
{
index = -1;
}
@@ -447,12 +455,13 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
checkNotClosed( "next()" );
// if parked at -1 we advance to the start index and return true
- if ( ( list.size() > 0 ) && ( index == -1 ) )
+ if ( !list.isEmpty() && ( index == -1 ) )
{
index = start;
@@ -460,7 +469,7 @@
}
// if the index plus one is less than the end then increment and return true
- if ( ( list.size() > 0 ) && ( index + 1 < end ) )
+ if ( !list.isEmpty() && ( index + 1 < end ) )
{
index++;
@@ -468,14 +477,14 @@
}
// if the index plus one is equal to the end then increment and return false
- if ( ( list.size() > 0 ) && ( index + 1 == end ) )
+ if ( !list.isEmpty() && ( index + 1 == end ) )
{
index++;
return false;
}
- if ( list.size() <= 0 )
+ if ( list.isEmpty() )
{
index = end;
}
@@ -487,6 +496,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E get() throws CursorException
{
checkNotClosed( "get()" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SetCursor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SetCursor.java
index cd5a2f6..e907893 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SetCursor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SetCursor.java
@@ -128,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return ( index >= 0 ) && ( index < set.length );
@@ -137,6 +138,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void before( E element ) throws LdapException, CursorException
{
checkNotClosed( "before()" );
@@ -170,6 +172,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void after( E element ) throws LdapException, CursorException
{
checkNotClosed( "after()" );
@@ -203,6 +206,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
checkNotClosed( "beforeFirst()" );
@@ -213,6 +217,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
checkNotClosed( "afterLast()" );
@@ -223,6 +228,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
checkNotClosed( "first()" );
@@ -241,6 +247,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
checkNotClosed( "last()" );
@@ -299,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
checkNotClosed( "previous()" );
@@ -337,6 +345,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
checkNotClosed( "next()" );
@@ -377,6 +386,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E get() throws CursorException
{
checkNotClosed( "get()" );
@@ -423,6 +433,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString( String tabs )
{
StringBuilder sb = new StringBuilder();
@@ -456,6 +467,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return toString( "" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SingletonCursor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SingletonCursor.java
index c57bb73..99a8ee7 100755
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SingletonCursor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/SingletonCursor.java
@@ -92,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean available()
{
return onSingleton;
@@ -101,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void before( E element ) throws LdapException, CursorException
{
checkNotClosed( "before()" );
@@ -126,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void after( E element ) throws LdapException, CursorException
{
checkNotClosed( "after()" );
@@ -151,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void beforeFirst() throws LdapException, CursorException
{
checkNotClosed( "beforeFirst" );
@@ -163,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void afterLast() throws LdapException, CursorException
{
checkNotClosed( "afterLast" );
@@ -175,6 +180,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean first() throws LdapException, CursorException
{
checkNotClosed( "first" );
@@ -189,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean last() throws LdapException, CursorException
{
checkNotClosed( "last" );
@@ -243,6 +250,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean previous() throws LdapException, CursorException
{
checkNotClosed( "previous" );
@@ -273,6 +281,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean next() throws LdapException, CursorException
{
checkNotClosed( "next" );
@@ -303,6 +312,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public E get() throws CursorException
{
checkNotClosed( "get" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/Tuple.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/Tuple.java
index 218e7bc..2751c36 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/Tuple.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/cursor/Tuple.java
@@ -228,6 +228,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
index 48bea75..803b41a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
@@ -36,7 +36,9 @@
/**
* A wrapper around byte[] values in entries.
- *
+ *
+ * @param <T> The valye type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractValue<T> implements Value<T>
@@ -61,6 +63,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Value<T> clone()
{
try
@@ -78,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T getReference()
{
return upValue;
@@ -89,6 +93,7 @@
*
* @return the wrapped value as a String
*/
+ @Override
public String getString()
{
throw new UnsupportedOperationException( "Cannot call this method on a binary value" );
@@ -100,6 +105,7 @@
*
* @return the wrapped value as a byte[]
*/
+ @Override
public byte[] getBytes()
{
throw new UnsupportedOperationException( "Cannot call this method on a String value" );
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType getAttributeType()
{
return attributeType;
@@ -123,6 +130,7 @@
* to the schema
*/
@SuppressWarnings("unchecked")
+ @Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
if ( this.attributeType != null )
@@ -154,7 +162,12 @@
{
if ( upValue != null )
{
- boolean isHR = attributeType.getSyntax().isHumanReadable();
+ boolean isHR = true;
+ // Some broken LDAP servers do not have proper syntax definitions
+ if ( attributeType.getSyntax() != null )
+ {
+ isHR = attributeType.getSyntax().isHumanReadable();
+ }
if ( isHR != isHumanReadable() )
@@ -262,6 +275,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInstanceOf( AttributeType attributeType )
{
return ( attributeType != null )
@@ -272,6 +286,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T getNormReference()
{
if ( isNull() )
@@ -291,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isNull()
{
return upValue == null;
@@ -300,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException
{
if ( syntaxChecker == null )
@@ -323,6 +340,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isSchemaAware()
{
return attributeType != null;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java
index cb3f296..6a294c5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Attribute.java
@@ -378,7 +378,7 @@
* @throws IllegalArgumentException If the ID is empty or null or
* resolve to an empty value after being trimmed
*/
- void setUpId( String upId ) throws IllegalArgumentException;
+ void setUpId( String upId );
/**
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java
index 05df152..966939d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java
@@ -120,6 +120,7 @@
*
* @return the normalized version of the user provided value
*/
+ @Override
public byte[] getNormValue()
{
if ( isNull() )
@@ -139,6 +140,7 @@
* @param value The value we want to compare to
* @return -1 if the current is below the provided one, 1 if it's above, 0 if they are equal
*/
+ @Override
public int compareTo( Value<byte[]> value )
{
if ( isNull() )
@@ -200,6 +202,7 @@
* @see Object#hashCode()
* @return the instance's hashcode
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -225,6 +228,7 @@
* This equals implementation overrides the BinaryValue implementation which
* is not schema aware.
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -399,6 +403,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BinaryValue clone()
{
BinaryValue clone = ( BinaryValue ) super.clone();
@@ -423,6 +428,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( upValue == null )
@@ -442,6 +448,7 @@
*
* @return <code>true</code> if the value is HR, <code>false</code> otherwise
*/
+ @Override
public boolean isHumanReadable()
{
return false;
@@ -451,6 +458,7 @@
/**
* @return The length of the interned value
*/
+ @Override
public int length()
{
return upValue != null ? upValue.length : 0;
@@ -463,6 +471,7 @@
*
* @return the user provided value as a byte[]
*/
+ @Override
public byte[] getBytes()
{
return getValue();
@@ -474,6 +483,7 @@
*
* @return the user provided value as a String
*/
+ @Override
public String getString()
{
return Strings.utf8ToString( upValue );
@@ -519,6 +529,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the BINARY flag
@@ -620,6 +631,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the BINARY flag
@@ -677,6 +689,7 @@
*
* @see Object#toString()
*/
+ @Override
public String toString()
{
if ( upValue == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
index 29eaf81..b2d6181 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
@@ -54,7 +54,7 @@
private AttributeType attributeType;
/** The set of contained values */
- private Set<Value<?>> values = new LinkedHashSet<Value<?>>();
+ private Set<Value<?>> values = new LinkedHashSet<>();
/** The User provided ID */
private String upId;
@@ -71,51 +71,6 @@
//-------------------------------------------------------------------------
- // Helper methods
- //-------------------------------------------------------------------------
- private Value<String> createStringValue( AttributeType attributeType, String value )
- {
- Value<String> stringValue = null;
-
- if ( attributeType != null )
- {
- try
- {
- stringValue = new StringValue( attributeType, value );
- }
- catch ( LdapInvalidAttributeValueException iae )
- {
- return null;
- }
- }
- else
- {
- stringValue = new StringValue( value );
- }
-
- return stringValue;
- }
-
-
- private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value )
- throws LdapInvalidAttributeValueException
- {
- Value<byte[]> binaryValue = null;
-
- if ( attributeType != null )
- {
- binaryValue = new BinaryValue( attributeType, value );
- }
- else
- {
- binaryValue = new BinaryValue( value );
- }
-
- return binaryValue;
- }
-
-
- //-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
// maybe have some additional convenience constructors which take
@@ -506,9 +461,55 @@
}
+ //-------------------------------------------------------------------------
+ // Helper methods
+ //-------------------------------------------------------------------------
+ private Value<String> createStringValue( AttributeType attributeType, String value )
+ {
+ Value<String> stringValue;
+
+ if ( attributeType != null )
+ {
+ try
+ {
+ stringValue = new StringValue( attributeType, value );
+ }
+ catch ( LdapInvalidAttributeValueException iae )
+ {
+ return null;
+ }
+ }
+ else
+ {
+ stringValue = new StringValue( value );
+ }
+
+ return stringValue;
+ }
+
+
+ private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value )
+ throws LdapInvalidAttributeValueException
+ {
+ Value<byte[]> binaryValue;
+
+ if ( attributeType != null )
+ {
+ binaryValue = new BinaryValue( attributeType, value );
+ }
+ else
+ {
+ binaryValue = new BinaryValue( value );
+ }
+
+ return binaryValue;
+ }
+
+
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getBytes() throws LdapInvalidAttributeValueException
{
Value<?> value = get();
@@ -527,6 +528,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getString() throws LdapInvalidAttributeValueException
{
Value<?> value = get();
@@ -545,6 +547,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getId()
{
return id;
@@ -554,6 +557,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getUpId()
{
return upId;
@@ -563,6 +567,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setUpId( String upId )
{
setUpId( upId, attributeType );
@@ -570,7 +575,9 @@
/**
- * {@inheritDoc}
+ * Sets the User Provided ID as a byte[]
+ *
+ * @param upId The User Provided ID
*/
public void setUpId( byte[] upId )
{
@@ -609,6 +616,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setUpId( String upId, AttributeType attributeType )
{
String trimmed = Strings.trim( upId );
@@ -625,7 +633,10 @@
/**
- * {@inheritDoc}
+ * Sets the User Provided ID as a byte[]
+ *
+ * @param upId The User Provided ID
+ * @param attributeType The asscoiated AttributeType
*/
public void setUpId( byte[] upId, AttributeType attributeType )
{
@@ -642,9 +653,6 @@
}
- /**
- * {@inheritDoc}
- */
private void setUpIdInternal( String upId, String newId, AttributeType attributeType )
{
if ( attributeType == null )
@@ -710,6 +718,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isHumanReadable()
{
return isHR != null ? isHR : false;
@@ -719,6 +728,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValid( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
LdapSyntax syntax = attributeType.getSyntax();
@@ -736,7 +746,7 @@
}
// Check that we can have no value for this attributeType
- if ( values.size() == 0 )
+ if ( values.isEmpty() )
{
return syntaxChecker.isValidSyntax( null );
}
@@ -770,6 +780,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int add( Value<?>... vals )
{
int nbAdded = 0;
@@ -1039,6 +1050,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int add( String... vals ) throws LdapInvalidAttributeValueException
{
int nbAdded = 0;
@@ -1188,7 +1200,7 @@
{
for ( byte[] val : valArray )
{
- Value<byte[]> value = null;
+ Value<byte[]> value;
if ( attributeType == null )
{
@@ -1223,6 +1235,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
values.clear();
@@ -1232,6 +1245,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( Value<?>... vals )
{
if ( isHR == null )
@@ -1359,6 +1373,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String... vals )
{
if ( isHR == null )
@@ -1518,6 +1533,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> get()
{
if ( values.isEmpty() )
@@ -1532,6 +1548,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return values.size();
@@ -1541,9 +1558,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( Value<?>... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1649,7 +1667,7 @@
*/
public boolean remove( byte[]... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1709,9 +1727,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( String... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1773,6 +1792,7 @@
*
* @return an iterator over the stored values.
*/
+ @Override
public Iterator<Value<?>> iterator()
{
return values.iterator();
@@ -1782,6 +1802,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType getAttributeType()
{
return attributeType;
@@ -1791,6 +1812,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
if ( attributeType == null )
@@ -1815,7 +1837,7 @@
if ( values != null )
{
- Set<Value<?>> newValues = new LinkedHashSet<Value<?>>( values.size() );
+ Set<Value<?>> newValues = new LinkedHashSet<>( values.size() );
for ( Value<?> value : values )
{
@@ -1842,6 +1864,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInstanceOf( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
return ( attributeType != null )
@@ -1883,6 +1906,7 @@
* @see Object#hashCode()
* @return the instance's hashcode
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -1897,6 +1921,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -1970,6 +1995,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute clone()
{
try
@@ -1982,7 +2008,7 @@
attribute.attributeType = attributeType;
}
- attribute.values = new LinkedHashSet<Value<?>>( values.size() );
+ attribute.values = new LinkedHashSet<>( values.size() );
for ( Value<?> value : values )
{
@@ -2005,6 +2031,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the UPId (the id will be deduced from the upID)
@@ -2041,6 +2068,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the ID and the UPId
@@ -2062,7 +2090,7 @@
{
for ( int i = 0; i < nbValues; i++ )
{
- Value<?> value = null;
+ Value<?> value;
if ( isHR )
{
@@ -2084,7 +2112,8 @@
/**
* @see Object#toString()
*/
- public String toString()
+ @Override
+public String toString()
{
return toString( "" );
}
@@ -2093,11 +2122,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString( String tabs )
{
StringBuilder sb = new StringBuilder();
- if ( ( values != null ) && ( values.size() != 0 ) )
+ if ( ( values != null ) && !values.isEmpty() )
{
boolean isFirst = true;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
index 51576ed..f4d88e7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
@@ -67,7 +67,7 @@
private Dn dn;
/** A map containing all the attributes for this entry */
- private Map<String, Attribute> attributes = new HashMap<String, Attribute>();
+ private Map<String, Attribute> attributes = new HashMap<>();
/** A speedup to get the ObjectClass attribute */
private static AttributeType objectClassAttributeType;
@@ -303,7 +303,7 @@
}
// Init the attributes map
- attributes = new HashMap<String, Attribute>( entry.size() );
+ attributes = new HashMap<>( entry.size() );
// and copy all the attributes
for ( Attribute attribute : entry )
@@ -351,7 +351,7 @@
if ( !( element instanceof String ) )
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12085, ( pos + 1 ) ) );
+ I18n.ERR_12085, pos + 1 ) );
}
String attribute = ( String ) element;
@@ -381,7 +381,7 @@
else
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12086, ( pos + 1 ) ) );
+ I18n.ERR_12086, pos + 1 ) );
}
valueExpected = false;
@@ -394,28 +394,13 @@
.err( I18n.ERR_12087 ) );
}
- LdifAttributesReader reader = null;
-
- try
+ try ( LdifAttributesReader reader = new LdifAttributesReader() )
{
- reader = new LdifAttributesReader();
- Entry entry = reader.parseEntry( schemaManager, sb.toString() );
-
- return entry;
+ return reader.parseEntry( schemaManager, sb.toString() );
}
- finally
+ catch ( IOException e )
{
- try
- {
- if ( reader != null )
- {
- reader.close();
- }
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- }
+ throw new LdapLdifException( "Cannot read an entry" );
}
}
@@ -448,7 +433,7 @@
{
String normUpId = Strings.trim( upId );
- if ( ( attributeType == null ) )
+ if ( attributeType == null )
{
if ( Strings.isEmpty( normUpId ) )
{
@@ -678,6 +663,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( AttributeType attributeType, String... values ) throws LdapException
{
if ( attributeType == null )
@@ -710,6 +696,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( AttributeType attributeType, Value<?>... values ) throws LdapException
{
if ( attributeType == null )
@@ -777,6 +764,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, AttributeType attributeType, Value<?>... values ) throws LdapException
{
if ( attributeType == null )
@@ -809,6 +797,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, AttributeType attributeType, String... values ) throws LdapException
{
if ( attributeType == null )
@@ -843,6 +832,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( Attribute... attributes ) throws LdapException
{
// Loop on all the added attributes
@@ -946,6 +936,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, String... values ) throws LdapException
{
if ( Strings.isEmpty( upId ) )
@@ -990,6 +981,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, Value<?>... values ) throws LdapException
{
if ( Strings.isEmpty( upId ) )
@@ -1036,6 +1028,7 @@
* the original object won't affect the cloned object, as a modification
* on the cloned object has no impact on the original object
*/
+ @Override
public Entry clone()
{
// First, clone the structure
@@ -1070,6 +1063,7 @@
* Shallow clone an entry. We don't clone the Attributes
*/
@SuppressWarnings("unchecked")
+ @Override
public Entry shallowClone()
{
try
@@ -1098,6 +1092,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( Attribute... attributes )
{
if ( schemaManager == null )
@@ -1140,6 +1135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean containsAttribute( String... attributes )
{
if ( schemaManager == null )
@@ -1181,6 +1177,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean containsAttribute( AttributeType attributeType )
{
if ( attributeType == null )
@@ -1218,6 +1215,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( AttributeType attributeType, String... values )
{
if ( attributeType == null )
@@ -1241,6 +1239,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( AttributeType attributeType, Value<?>... values )
{
if ( attributeType == null )
@@ -1299,6 +1298,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String upId, String... values )
{
if ( Strings.isEmpty( upId ) )
@@ -1334,6 +1334,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String upId, Value<?>... values )
{
if ( Strings.isEmpty( upId ) )
@@ -1369,6 +1370,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute get( String alias )
{
try
@@ -1406,6 +1408,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute get( AttributeType attributeType )
{
if ( attributeType != null )
@@ -1422,6 +1425,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<Attribute> getAttributes()
{
return Collections.unmodifiableMap( attributes ).values();
@@ -1470,6 +1474,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, String... values )
{
if ( Strings.isEmpty( upId ) )
@@ -1509,6 +1514,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, Value<?>... values )
{
if ( Strings.isEmpty( upId ) )
@@ -1548,10 +1554,11 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Attribute> put( Attribute... attributes ) throws LdapException
{
// First, get the existing attributes
- List<Attribute> previous = new ArrayList<Attribute>();
+ List<Attribute> previous = new ArrayList<>();
if ( schemaManager == null )
{
@@ -1613,6 +1620,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( AttributeType attributeType, String... values ) throws LdapException
{
return put( null, attributeType, values );
@@ -1622,6 +1630,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( AttributeType attributeType, Value<?>... values ) throws LdapException
{
return put( null, attributeType, values );
@@ -1681,6 +1690,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, AttributeType attributeType, String... values ) throws LdapException
{
if ( attributeType == null )
@@ -1724,6 +1734,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, AttributeType attributeType, Value<?>... values ) throws LdapException
{
if ( attributeType == null )
@@ -1767,9 +1778,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Attribute> remove( Attribute... attributes ) throws LdapException
{
- List<Attribute> removedAttributes = new ArrayList<Attribute>();
+ List<Attribute> removedAttributes = new ArrayList<>();
if ( schemaManager == null )
{
@@ -1853,6 +1865,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( AttributeType attributeType, String... values ) throws LdapException
{
if ( attributeType == null )
@@ -1896,6 +1909,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( AttributeType attributeType, Value<?>... values ) throws LdapException
{
if ( attributeType == null )
@@ -1950,6 +1964,7 @@
*
* @param attributes the AttributeTypes to be removed
*/
+ @Override
public void removeAttributes( AttributeType... attributes )
{
if ( ( attributes == null ) || ( attributes.length == 0 ) || ( schemaManager == null ) )
@@ -1972,6 +1987,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void removeAttributes( String... attributes )
{
if ( attributes.length == 0 )
@@ -2121,6 +2137,7 @@
* @return <code>true</code> if at least a value is removed, <code>false</code>
* if not all the values have been removed or if the attribute does not exist.
*/
+ @Override
public boolean remove( String upId, String... values ) throws LdapException
{
if ( Strings.isEmpty( upId ) )
@@ -2200,6 +2217,7 @@
* @return <code>true</code> if at least a value is removed, <code>false</code>
* if not all the values have been removed or if the attribute does not exist.
*/
+ @Override
public boolean remove( String upId, Value<?>... values ) throws LdapException
{
if ( Strings.isEmpty( upId ) )
@@ -2263,6 +2281,7 @@
*
* @return The entry's Dn
*/
+ @Override
public Dn getDn()
{
return dn;
@@ -2272,6 +2291,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDn( Dn dn )
{
this.dn = dn;
@@ -2284,6 +2304,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDn( String dn ) throws LdapInvalidDnException
{
setDn( new Dn( dn ) );
@@ -2293,6 +2314,7 @@
/**
* Remove all the attributes for this entry. The Dn is not reset
*/
+ @Override
public void clear()
{
attributes.clear();
@@ -2306,6 +2328,7 @@
*
* @return an enumeration of all contained attributes
*/
+ @Override
public Iterator<Attribute> iterator()
{
return Collections.unmodifiableMap( attributes ).values().iterator();
@@ -2317,6 +2340,7 @@
*
* @return the number of attributes
*/
+ @Override
public int size()
{
return attributes.size();
@@ -2342,6 +2366,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// First, the Dn
@@ -2374,6 +2399,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the Dn
@@ -2421,6 +2447,7 @@
* @see java.lang.Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -2435,6 +2462,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasObjectClass( String... objectClasses )
{
if ( ( objectClasses == null ) || ( objectClasses.length == 0 ) || ( objectClasses[0] == null ) )
@@ -2467,6 +2495,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasObjectClass( Attribute... objectClasses )
{
if ( ( objectClasses == null ) || ( objectClasses.length == 0 ) || ( objectClasses[0] == null ) )
@@ -2507,6 +2536,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSchemaAware()
{
return schemaManager != null;
@@ -2516,6 +2546,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
// Short circuit
@@ -2569,6 +2600,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return toString( "" );
@@ -2578,6 +2610,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString( String tabs )
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultModification.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultModification.java
index a650513..53ffcce 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultModification.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultModification.java
@@ -227,6 +227,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModificationOperation getOperation()
{
return operation;
@@ -236,6 +237,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setOperation( int operation )
{
this.operation = ModificationOperation.getOperation( operation );
@@ -245,6 +247,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setOperation( ModificationOperation operation )
{
this.operation = operation;
@@ -254,6 +257,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute getAttribute()
{
return attribute;
@@ -263,6 +267,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setAttribute( Attribute attribute )
{
this.attribute = attribute;
@@ -272,6 +277,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
this.attributeType = attributeType;
@@ -284,7 +290,7 @@
/**
- * {@inheritDoc}
+ * @return The associated AttributeType
*/
public AttributeType getAttributeType()
{
@@ -296,6 +302,7 @@
* @see Object#equals(Object)
* @return <code>true</code> if both values are equal
*/
+ @Override
public boolean equals( Object that )
{
// Basic equals checks
@@ -331,6 +338,7 @@
* Compute the modification @see Object#hashCode
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -345,6 +353,7 @@
/**
* @see java.io.Externalizable#readExternal(ObjectInput)
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// The operation
@@ -364,6 +373,7 @@
/**
* @see java.io.Externalizable#writeExternal(ObjectOutput)
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// The operation
@@ -387,6 +397,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultModification clone()
{
try
@@ -406,6 +417,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Entry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Entry.java
index 370d5c7..7dde6c4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Entry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Entry.java
@@ -150,6 +150,7 @@
*
* @return an iterator on top of all contained attributes
*/
+ @Override
Iterator<Attribute> iterator();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ImmutableEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ImmutableEntry.java
index b92a14e..b51c78f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ImmutableEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ImmutableEntry.java
@@ -82,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( AttributeType attributeType, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -92,6 +93,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( AttributeType attributeType, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -112,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, AttributeType attributeType, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -122,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, AttributeType attributeType, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -132,6 +136,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( Attribute... attributes ) throws LdapException
{
new Exception().printStackTrace();
@@ -152,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -162,6 +168,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry add( String upId, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -174,6 +181,7 @@
* the original object won't affect the cloned object, as a modification
* on the cloned object has no impact on the original object
*/
+ @Override
public Entry clone()
{
return entry.clone();
@@ -183,6 +191,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry shallowClone()
{
return entry.shallowClone();
@@ -192,6 +201,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( Attribute... attributes )
{
return entry.contains( attributes );
@@ -201,6 +211,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean containsAttribute( String... attributes )
{
return entry.containsAttribute( attributes );
@@ -210,6 +221,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean containsAttribute( AttributeType attributeType )
{
return entry.containsAttribute( attributeType );
@@ -228,6 +240,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( AttributeType attributeType, String... values )
{
return entry.contains( attributeType, values );
@@ -237,6 +250,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( AttributeType attributeType, Value<?>... values )
{
return entry.contains( attributeType, values );
@@ -255,6 +269,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String upId, String... values )
{
return entry.contains( upId, values );
@@ -264,6 +279,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String upId, Value<?>... values )
{
return entry.contains( upId, values );
@@ -273,6 +289,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute get( String alias )
{
return entry.get( alias );
@@ -282,6 +299,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute get( AttributeType attributeType )
{
return entry.get( attributeType );
@@ -291,6 +309,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<Attribute> getAttributes()
{
return entry.getAttributes();
@@ -310,6 +329,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, String... values )
{
new Exception().printStackTrace();
@@ -320,6 +340,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, Value<?>... values )
{
new Exception().printStackTrace();
@@ -330,6 +351,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Attribute> put( Attribute... attributes ) throws LdapException
{
new Exception().printStackTrace();
@@ -350,6 +372,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( AttributeType attributeType, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -360,6 +383,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( AttributeType attributeType, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -380,6 +404,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, AttributeType attributeType, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -390,6 +415,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Attribute put( String upId, AttributeType attributeType, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -400,6 +426,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Attribute> remove( Attribute... attributes ) throws LdapException
{
new Exception().printStackTrace();
@@ -420,6 +447,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( AttributeType attributeType, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -430,6 +458,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( AttributeType attributeType, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -451,6 +480,7 @@
*
* @param attributes the AttributeTypes to be removed
*/
+ @Override
public void removeAttributes( AttributeType... attributes )
{
new Exception().printStackTrace();
@@ -461,6 +491,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void removeAttributes( String... attributes )
{
new Exception().printStackTrace();
@@ -517,6 +548,7 @@
* @return <code>true</code> if at least a value is removed, <code>false</code>
* if not all the values have been removed or if the attribute does not exist.
*/
+ @Override
public boolean remove( String upId, String... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -545,6 +577,7 @@
* @return <code>true</code> if at least a value is removed, <code>false</code>
* if not all the values have been removed or if the attribute does not exist.
*/
+ @Override
public boolean remove( String upId, Value<?>... values ) throws LdapException
{
new Exception().printStackTrace();
@@ -557,6 +590,7 @@
*
* @return The entry's Dn
*/
+ @Override
public Dn getDn()
{
return entry.getDn();
@@ -566,6 +600,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDn( Dn dn )
{
new Exception().printStackTrace();
@@ -576,6 +611,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDn( String dn ) throws LdapInvalidDnException
{
new Exception().printStackTrace();
@@ -586,6 +622,7 @@
/**
* Remove all the attributes for this entry. The Dn is not reset
*/
+ @Override
public void clear()
{
new Exception().printStackTrace();
@@ -600,6 +637,7 @@
*
* @return an enumeration of all contained attributes
*/
+ @Override
public Iterator<Attribute> iterator()
{
return entry.iterator();
@@ -611,6 +649,7 @@
*
* @return the number of attributes
*/
+ @Override
public int size()
{
return entry.size();
@@ -636,6 +675,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
entry.writeExternal( out );
@@ -645,6 +685,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
new Exception().printStackTrace();
@@ -694,6 +735,7 @@
* @see java.lang.Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
return entry.hashCode();
@@ -703,6 +745,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasObjectClass( String... objectClasses )
{
return entry.hasObjectClass( objectClasses );
@@ -712,6 +755,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasObjectClass( Attribute... objectClasses )
{
return entry.hasObjectClass( objectClasses );
@@ -721,6 +765,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSchemaAware()
{
return entry.isSchemaAware();
@@ -730,6 +775,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
return entry.equals( o );
@@ -739,6 +785,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return entry.toString();
@@ -748,6 +795,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString( String tabs )
{
return entry.toString( tabs );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ModificationOperation.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ModificationOperation.java
index 691c632..0c28d32 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ModificationOperation.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/ModificationOperation.java
@@ -29,8 +29,13 @@
*/
public enum ModificationOperation
{
+ /** Added attribute value */
ADD_ATTRIBUTE(0),
+
+ /** Removed attribute value */
REMOVE_ATTRIBUTE(1),
+
+ /** Replaced attribute value */
REPLACE_ATTRIBUTE(2);
/** Internal value */
@@ -40,7 +45,7 @@
/**
* Creates a new instance of ModificationOperation.
*/
- private ModificationOperation( int value )
+ ModificationOperation( int value )
{
this.value = value;
}
@@ -86,6 +91,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
switch ( this )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/StringValue.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/StringValue.java
index 211be8b..a111006 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/StringValue.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/StringValue.java
@@ -145,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getValue()
{
// The String is immutable, we can safely return the internal
@@ -156,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getNormValue()
{
return normalizedValue;
@@ -172,6 +174,7 @@
* @throws IllegalStateException on failures to extract the comparator, or the
* normalizers needed to perform the required comparisons based on the schema
*/
+ @Override
public int compareTo( Value<String> value )
{
if ( isNull() )
@@ -239,6 +242,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public StringValue clone()
{
return ( StringValue ) super.clone();
@@ -252,6 +256,7 @@
* @see Object#hashCode()
* @return the instance's hashcode
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -288,6 +293,7 @@
*
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -459,6 +465,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isHumanReadable()
{
return true;
@@ -468,6 +475,7 @@
/**
* @return The length of the interned value
*/
+ @Override
public int length()
{
return upValue != null ? upValue.length() : 0;
@@ -478,6 +486,7 @@
* Get the user provided value as a byte[].
* @return the user provided value as a byte[]
*/
+ @Override
public byte[] getBytes()
{
return bytes;
@@ -489,6 +498,7 @@
*
* @return the user provided value as a String
*/
+ @Override
public String getString()
{
return upValue != null ? upValue : "";
@@ -534,6 +544,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the STRING flag
@@ -793,6 +804,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write a boolean for the HR flag
@@ -844,6 +856,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return upValue == null ? "null" : upValue;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
index a9f49fe..2a0d870 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
@@ -31,12 +31,16 @@
* A interface for wrapping attribute values stored into an EntryAttribute. These
* values can be a String or a byte[].
*
+ * @param <T> The valye type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface Value<T> extends Cloneable, Externalizable, Comparable<Value<T>>
{
- /** Two flags used to tell if the value is HR or not in serialization */
+ /** A flag used to tell if the value is HR in serialization */
boolean STRING = true;
+
+ /** A flag used to tell if the value is not HR in serialization */
boolean BINARY = false;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/AbstractLdapReferralException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/AbstractLdapReferralException.java
index 6bb3f23..33b89a0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/AbstractLdapReferralException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/AbstractLdapReferralException.java
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.model.exception;
-import java.util.Hashtable;
+import java.util.Map;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -44,7 +44,7 @@
/** The remaining Dn */
private Dn remainingDn;
- /** TODO */
+ /** The entry the referal refers to */
private Object resolvedObject;
@@ -65,24 +65,41 @@
*
* @return The interned ResultCode
*/
+ @Override
public ResultCodeEnum getResultCode()
{
return ResultCodeEnum.REFERRAL;
}
+ /**
+ * Not yet implemented
+ *
+ * @return The Referral Context
+ * @throws NamingException If the operation failed
+ */
public Context getReferralContext() throws NamingException
{
throw new NotImplementedException();
}
- public Context getReferralContext( Hashtable<?, ?> arg ) throws NamingException
+ /**
+ * Not yet implemented
+ *
+ * @param arg The arguments
+ * @return The referral context
+ * @throws NamingException If the operation failed
+ */
+ public Context getReferralContext( Map<?, ?> arg ) throws NamingException
{
throw new NotImplementedException();
}
+ /**
+ * Retry. Not yet implemented
+ */
public void retryReferral()
{
throw new NotImplementedException();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapConfigurationException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapConfigurationException.java
index ba04617..fde7ef0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapConfigurationException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapConfigurationException.java
@@ -74,6 +74,7 @@
/**
* @return the exception's cause
*/
+ @Override
public Throwable getCause()
{
return cause;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapOperationException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapOperationException.java
index 477651b..ea2bae1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapOperationException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapOperationException.java
@@ -43,24 +43,6 @@
/**
- * @return the resolvedDn
- */
- public Dn getResolvedDn()
- {
- return resolvedDn;
- }
-
-
- /**
- * @param resolvedDn the resolvedDn to set
- */
- public void setResolvedDn( Dn resolvedDn )
- {
- this.resolvedDn = resolvedDn;
- }
-
-
- /**
* Creates a new instance of LdapOperationException.
*
* @param resultCode The operation resultCode
@@ -111,6 +93,24 @@
/**
+ * @return the resolvedDn
+ */
+ public Dn getResolvedDn()
+ {
+ return resolvedDn;
+ }
+
+
+ /**
+ * @param resolvedDn the resolvedDn to set
+ */
+ public void setResolvedDn( Dn resolvedDn )
+ {
+ this.resolvedDn = resolvedDn;
+ }
+
+
+ /**
* Gets the LDAP result code that would be associated with this exception.
*
* @return the LDAP result code corresponding to this exception type.
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapReferralException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapReferralException.java
index 6a0b0c5..c7f3204 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapReferralException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapReferralException.java
@@ -22,8 +22,8 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -53,7 +53,7 @@
/** The remaining Dn */
private Dn remainingDn;
- /** TODO */
+ /** The Entry the referral refers to */
private Object resolvedObject;
@@ -66,7 +66,7 @@
public LdapReferralException( Collection<String> refs )
{
super( null );
- this.refs = new ArrayList<String>( refs );
+ this.refs = new ArrayList<>( refs );
}
@@ -80,7 +80,7 @@
public LdapReferralException( Collection<String> refs, String explanation )
{
super( explanation );
- this.refs = new ArrayList<String>( refs );
+ this.refs = new ArrayList<>( refs );
}
@@ -89,6 +89,7 @@
*
* @return The ResultCode
*/
+ @Override
public ResultCodeEnum getResultCode()
{
return ResultCodeEnum.REFERRAL;
@@ -104,13 +105,15 @@
}
+ @Override
public Context getReferralContext() throws NamingException
{
throw new NotImplementedException();
}
- public Context getReferralContext( Hashtable<?, ?> arg ) throws NamingException
+ @Override
+ public Context getReferralContext( Map<?, ?> arg ) throws NamingException
{
throw new NotImplementedException();
}
@@ -127,6 +130,7 @@
}
+ @Override
public void retryReferral()
{
throw new NotImplementedException();
@@ -136,6 +140,7 @@
/**
* @return the remainingDn
*/
+ @Override
public Dn getRemainingDn()
{
return remainingDn;
@@ -145,6 +150,7 @@
/**
* @param remainingDn the remainingName to set
*/
+ @Override
public void setRemainingDn( Dn remainingDn )
{
this.remainingDn = remainingDn;
@@ -154,6 +160,7 @@
/**
* @return the resolvedObject
*/
+ @Override
public Object getResolvedObject()
{
return resolvedObject;
@@ -163,6 +170,7 @@
/**
* @param resolvedObject the resolvedObject to set
*/
+ @Override
public void setResolvedObject( Object resolvedObject )
{
this.resolvedObject = resolvedObject;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapSchemaViolationException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapSchemaViolationException.java
index a954c14..8ea3467 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapSchemaViolationException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapSchemaViolationException.java
@@ -94,6 +94,7 @@
case OBJECT_CLASS_VIOLATION:
case NOT_ALLOWED_ON_RDN:
case OBJECT_CLASS_MODS_PROHIBITED:
+ case INVALID_ATTRIBUTE_SYNTAX: // may happen during schema processing
return;
default:
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapUriException.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapUriException.java
index 02f8416..5f8f874 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapUriException.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/exception/LdapUriException.java
@@ -29,21 +29,6 @@
{
private static final long serialVersionUID = 1L;
-
- /**
- * The constructor with a reason string argument.
- *
- * @param reason the reason
- * @param cause the root cause
- */
- public LdapUriException( String reason, Throwable cause )
- {
- // for backward compatibility of Throwable
- super( reason, cause );
- this.reason = reason;
- this.reasonCode = UNKNOWN;
- }
-
/**
* No specified reason code.
*/
@@ -61,6 +46,21 @@
/**
+ * The constructor with a reason string argument.
+ *
+ * @param reason the reason
+ * @param cause the root cause
+ */
+ public LdapUriException( String reason, Throwable cause )
+ {
+ // for backward compatibility of Throwable
+ super( reason, cause );
+ this.reason = reason;
+ this.reasonCode = UNKNOWN;
+ }
+
+
+ /**
* Get the reason code.
*
* @return the reason code
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AbstractExprNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AbstractExprNode.java
index f5e65ef..9c9cecf 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AbstractExprNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AbstractExprNode.java
@@ -63,6 +63,7 @@
*
* @return the node's type
*/
+ @Override
public AssertionType getAssertionType()
{
return assertionType;
@@ -73,6 +74,7 @@
* @see Object#equals(Object)
*@return <code>true</code> if both objects are equal
*/
+ @Override
public boolean equals( Object o )
{
// Shortcut for equals object
@@ -153,7 +155,7 @@
return value;
}
- StringBuilder sb = null;
+ StringBuilder sb;
String val;
if ( !value.isHumanReadable() )
@@ -224,6 +226,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -249,6 +252,7 @@
*
* @return the annotation value.
*/
+ @Override
public Object get( Object key )
{
if ( null == annotations )
@@ -263,11 +267,12 @@
/**
* @see ExprNode#set(String, java.lang.Object)
*/
+ @Override
public void set( String key, Object value )
{
if ( null == annotations )
{
- annotations = new HashMap<String, Object>( 2 );
+ annotations = new HashMap<>( 2 );
}
annotations.put( key, value );
@@ -290,6 +295,7 @@
*
* @return true if the Node is SchemaAware
*/
+ @Override
public boolean isSchemaAware()
{
return isSchemaAware;
@@ -303,6 +309,7 @@
* @return The buffer in which the refinement has been appended
* @throws UnsupportedOperationException if this node isn't a part of a refinement.
*/
+ @Override
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04144 ) );
@@ -340,6 +347,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
if ( ( null != annotations ) && annotations.containsKey( "count" ) )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AndNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AndNode.java
index f36a122..92f66f2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AndNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AndNode.java
@@ -112,6 +112,7 @@
* @param buf the buffer to append to.
* @return The buffer in which the refinement has been appended
*/
+ @Override
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
buf.append( "and: {" );
@@ -145,9 +146,10 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append( "(&" );
buf.append( super.toString() );
@@ -167,6 +169,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -179,6 +182,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object other )
{
if ( this == other )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ApproximateNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ApproximateNode.java
index fe8517f..2f5bb0e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ApproximateNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ApproximateNode.java
@@ -27,6 +27,8 @@
/**
* A simple assertion value node.
*
+ * @param <T> The Value type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApproximateNode<T> extends SimpleNode<T>
@@ -59,6 +61,7 @@
* @see Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AssertionNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AssertionNode.java
index e638e76..71d6d22 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AssertionNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/AssertionNode.java
@@ -81,18 +81,6 @@
/**
- * Makes a full clone in new memory space of the current node and children
- *
- * @return the clone
- */
- @Override
- public ExprNode clone()
- {
- return ( ExprNode ) super.clone();
- }
-
-
- /**
* Gets the Assertion used by this assertion node.
*
* @return the assertion used by this node
@@ -113,6 +101,7 @@
* @see ExprNode#isLeaf()
* @return true if the node is a leaf,false otherwise
*/
+ @Override
public boolean isLeaf()
{
return true;
@@ -122,7 +111,8 @@
/**
* @see ExprNode#printRefinementToBuffer(StringBuilder)
*/
- public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
+ @Override
+ public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04145 ) );
}
@@ -197,6 +187,7 @@
* @see ExprNode#accept(
*FilterVisitor)
*/
+ @Override
public Object accept( FilterVisitor visitor )
{
return visitor.visit( this );
@@ -207,6 +198,7 @@
* @see Object#toString
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNode.java
index 30aed12..ed4bd9b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNode.java
@@ -49,7 +49,7 @@
if ( null == childList )
{
- this.children = new ArrayList<ExprNode>( 2 );
+ this.children = new ArrayList<>( 2 );
}
else
{
@@ -72,7 +72,7 @@
if ( null == children )
{
- this.children = new ArrayList<ExprNode>( childList.length );
+ this.children = new ArrayList<>( childList.length );
}
CollectionUtils.addAll( children, childList );
@@ -88,7 +88,7 @@
{
super( assertionType );
- this.children = new ArrayList<ExprNode>( 2 );
+ this.children = new ArrayList<>( 2 );
isSchemaAware = true;
}
@@ -97,6 +97,7 @@
* @see ExprNode#isLeaf()
* @return false all the time.
*/
+ @Override
public final boolean isLeaf()
{
return false;
@@ -111,12 +112,12 @@
@Override
public ExprNode clone()
{
- ExprNode clone = ( ExprNode ) super.clone();
+ ExprNode clone = super.clone();
// Clone the children
if ( children != null )
{
- ( ( BranchNode ) clone ).children = new ArrayList<ExprNode>();
+ ( ( BranchNode ) clone ).children = new ArrayList<>();
for ( ExprNode child : children )
{
@@ -184,7 +185,7 @@
*/
public ExprNode getFirstChild()
{
- if ( children.size() > 0 )
+ if ( !children.isEmpty() )
{
return children.get( 0 );
}
@@ -199,6 +200,7 @@
*
* @return The modified element
*/
+ @Override
public final Object accept( FilterVisitor visitor )
{
if ( visitor.isPrefix() )
@@ -236,6 +238,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -257,6 +260,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object other )
{
if ( this == other )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNormalizedVisitor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNormalizedVisitor.java
index 1b6b5f4..0fe6c01 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNormalizedVisitor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/BranchNormalizedVisitor.java
@@ -47,6 +47,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object visit( ExprNode node )
{
if ( !( node instanceof BranchNode ) )
@@ -58,7 +59,7 @@
Comparator<ExprNode> nodeComparator = new NodeComparator();
- Set<ExprNode> set = new TreeSet<ExprNode>( nodeComparator );
+ Set<ExprNode> set = new TreeSet<>( nodeComparator );
List<ExprNode> children = branch.getChildren();
@@ -90,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean canVisit( ExprNode node )
{
return node instanceof BranchNode;
@@ -99,6 +101,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isPrefix()
{
return false;
@@ -108,6 +111,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<ExprNode> getOrder( BranchNode node, List<ExprNode> children )
{
return children;
@@ -149,13 +153,14 @@
static class NodeComparator implements Comparator<ExprNode>
{
+ @Override
public int compare( ExprNode o1, ExprNode o2 )
{
StringBuilder buf = new StringBuilder();
buf.setLength( 0 );
- String s1 = null;
+ String s1;
buf.append( o1.toString() );
@@ -163,7 +168,7 @@
buf.setLength( 0 );
- String s2 = null;
+ String s2;
buf.append( o2.toString() );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/EqualityNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/EqualityNode.java
index bdf1f88..242026b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/EqualityNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/EqualityNode.java
@@ -27,6 +27,8 @@
/**
* A assertion value node for Equality.
*
+ * @param <T> The Value type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EqualityNode<T> extends SimpleNode<T>
@@ -59,6 +61,7 @@
* @see Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExprNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExprNode.java
index b0911d7..787bd13 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExprNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExprNode.java
@@ -76,20 +76,17 @@
* Recursively appends the refinement string representation of this node and its
* descendants in prefix notation to a buffer.
*
- * TODO - Why is this here? Why not put it in some utility class?
- *
* @param buf the buffer to append to.
* @return The buffer in which the refinement has been appended
* @throws UnsupportedOperationException if this node isn't a part of a refinement.
*/
- StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException;
+ StringBuilder printRefinementToBuffer( StringBuilder buf );
/**
* Element/node accept method for visitor pattern.
*
* @param visitor the filter expression tree structure visitor
- * TODO - what is this modified element ?
* @return the modified element
*/
Object accept( FilterVisitor visitor );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExtensibleNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExtensibleNode.java
index 34d9611..e447f6f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExtensibleNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ExtensibleNode.java
@@ -111,7 +111,7 @@
@Override
public ExprNode clone()
{
- ExprNode clone = ( ExprNode ) super.clone();
+ ExprNode clone = super.clone();
// Copy the value
if ( value != null )
@@ -259,6 +259,7 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterEncoder.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterEncoder.java
index b4022a5..c776852 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterEncoder.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterEncoder.java
@@ -53,7 +53,7 @@
* @return the formatted filter with escaped values
* @throws IllegalArgumentException if the number of values does not match the number of placeholders in the template
*/
- public static String format( String filterTemplate, String... values ) throws IllegalArgumentException
+ public static String format( String filterTemplate, String... values )
{
if ( values == null )
{
@@ -66,7 +66,6 @@
Format[] formats = mf.getFormatsByArgumentIndex();
if ( formats.length != values.length )
{
- // TODO: I18n
String msg = "Filter template {0} has {1} placeholders but {2} arguments provided.";
throw new IllegalArgumentException( I18n.format( msg, filterTemplate, formats.length, values.length ) );
}
@@ -78,8 +77,7 @@
}
// format the filter
- String format = mf.format( values );
- return format;
+ return mf.format( values );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterParser.java
index 238cab0..a4e94ce 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/FilterParser.java
@@ -59,7 +59,7 @@
private static ExprNode parseExtensible( SchemaManager schemaManager, String attribute, byte[] filter,
Position pos, boolean relaxed ) throws LdapException, ParseException
{
- ExtensibleNode node = null;
+ ExtensibleNode node;
if ( schemaManager != null )
{
@@ -443,7 +443,7 @@
if ( Strings.isCharASCII( filter, pos.start, '*' ) )
{
// We have found a '*' : this is a substring
- SubstringNode node = null;
+ SubstringNode node;
if ( schemaManager != null )
{
@@ -580,6 +580,7 @@
// Definitively a substring with no initial or an error
// Push back the '*' on the string
pos.start--;
+
return parseSubstring( schemaManager, attribute, null, filter, pos );
}
}
@@ -641,10 +642,10 @@
/**
* Parse the following grammar :
* item = simple / present / substring / extensible
- * simple = attr filtertype assertionvalue
+ * simple = attr WSP* filtertype assertionvalue
* filtertype = '=' / '~=' / '>=' / '<='
- * present = attr '=' '*'
- * substring = attr '=' [initial] any [final]
+ * present = attr WSP* '=' '*'
+ * substring = attr WSP* '=' [initial] any [final]
* extensible = ( attr [":dn"] [':' oid] ":=" assertionvalue )
* / ( [":dn"] ':' oid ":=" assertionvalue )
* matchingrule = ":" oid
@@ -656,7 +657,7 @@
private static ExprNode parseItem( SchemaManager schemaManager, byte[] filter, Position pos, byte b,
boolean relaxed ) throws ParseException, LdapException
{
- String attribute = null;
+ String attribute;
if ( b == '\0' )
{
@@ -672,15 +673,19 @@
{
// We must have an attribute
attribute = AttributeUtils.parseAttribute( filter, pos, true, relaxed );
+
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
// Now, we may have a present, substring, simple or an extensible
- b = Strings.byteAt( filter, pos.start );
+ byte currentByte = Strings.byteAt( filter, pos.start );
- switch ( b )
+ switch ( currentByte )
{
case '=':
// It can be a presence, an equal or a substring
pos.start++;
+
return parsePresenceEqOrSubstring( schemaManager, attribute, filter, pos );
case '~':
@@ -694,7 +699,7 @@
}
pos.start++;
-
+
// Parse the value and create the node
if ( schemaManager == null )
{
@@ -858,13 +863,13 @@
/**
* filtercomp = and / or / not / item
- * and = '&' filterlist
- * or = '|' filterlist
- * not = '!' filter
+ * and = '&' WSP* filterlist
+ * or = '|' WSP* filterlist
+ * not = '!' WSP* filter
* item = simple / present / substring / extensible
- * simple = attr filtertype assertionvalue
- * present = attr EQUALS ASTERISK
- * substring = attr EQUALS [initial] any [final]
+ * simple = attr WSP* filtertype WSP* assertionvalue
+ * present = attr WSP* EQUALS ASTERISK
+ * substring = attr WSP* EQUALS WSP* [initial] any [final]
* extensible = ( attr [dnattrs]
* [matchingrule] COLON EQUALS assertionvalue )
* / ( [dnattrs]
@@ -873,7 +878,7 @@
private static ExprNode parseFilterComp( SchemaManager schemaManager, byte[] filter, Position pos,
boolean relaxed ) throws ParseException, LdapException
{
- ExprNode node = null;
+ ExprNode node;
if ( pos.start == pos.length )
{
@@ -887,6 +892,10 @@
case '&':
// This is a AND node
pos.start++;
+
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
node = new AndNode();
node = parseBranchNode( schemaManager, node, filter, pos, relaxed );
break;
@@ -894,6 +903,10 @@
case '|':
// This is an OR node
pos.start++;
+
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
node = new OrNode();
node = parseBranchNode( schemaManager, node, filter, pos, relaxed );
break;
@@ -901,6 +914,10 @@
case '!':
// This is a NOT node
pos.start++;
+
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
node = new NotNode();
node = parseBranchNode( schemaManager, node, filter, pos, relaxed );
break;
@@ -914,15 +931,34 @@
return node;
}
+
+
+ /**
+ * Skip teh white spaces (0x20, 0x09, 0x0a and 0x0d)
+ * @param filter
+ * @param pos
+ */
+ private static void skipWhiteSpaces( byte[] filter, Position pos )
+ {
+ while ( Strings.isCharASCII( filter, pos.start, ' ' )
+ || Strings.isCharASCII( filter, pos.start, '\t' )
+ || Strings.isCharASCII( filter, pos.start, '\n' ) )
+ {
+ pos.start++;
+ }
+ }
/**
- * Pasre the grammar rule :
- * filter ::= '(' filterComp ')'
+ * Parse the grammar rule :
+ * filter ::= WSP* '(' WSP* filterComp WSP* ')' WSP*
*/
private static ExprNode parseFilterInternal( SchemaManager schemaManager, byte[] filter, Position pos,
boolean relaxed ) throws ParseException, LdapException
{
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
// Check for the left '('
if ( !Strings.isCharASCII( filter, pos.start, '(' ) )
{
@@ -939,6 +975,9 @@
pos.start++;
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
// parse the filter component
ExprNode node = parseFilterComp( schemaManager, filter, pos, relaxed );
@@ -947,6 +986,9 @@
return UndefinedNode.UNDEFINED_NODE;
}
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
// Check that we have a right ')'
if ( !Strings.isCharASCII( filter, pos.start, ')' ) )
{
@@ -955,6 +997,9 @@
pos.start++;
+ // Skip spaces
+ skipWhiteSpaces( filter, pos );
+
return node;
}
@@ -1029,7 +1074,16 @@
try
{
- return parseFilterInternal( schemaManager, filter, pos, relaxed );
+ ExprNode node = parseFilterInternal( schemaManager, filter, pos, relaxed );
+
+ if ( node == UndefinedNode.UNDEFINED_NODE )
+ {
+ return null;
+ }
+ else
+ {
+ return node;
+ }
}
catch ( LdapException le )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java
index 2fe9b3b..47b0391 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java
@@ -27,6 +27,8 @@
/**
* A assertion value node for GreaterOrEqual.
*
+ * @param <T> The Value type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class GreaterEqNode<T> extends SimpleNode<T>
@@ -59,6 +61,7 @@
* @see Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LeafNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LeafNode.java
index 7e386ec..a5368f7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LeafNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LeafNode.java
@@ -80,6 +80,7 @@
*
* @return true always
*/
+ @Override
public final boolean isLeaf()
{
return true;
@@ -144,6 +145,7 @@
* @param visitor the filter expression tree structure visitor
* @return The modified element
*/
+ @Override
public final Object accept( FilterVisitor visitor )
{
if ( visitor.canVisit( this ) )
@@ -161,6 +163,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -183,6 +186,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object other )
{
if ( this == other )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java
index b150b45..3757ffb 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java
@@ -27,6 +27,8 @@
/**
* A assertion value node for LessOrEqual.
*
+ * @param <T> The Value type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LessEqNode<T> extends SimpleNode<T>
@@ -59,6 +61,7 @@
* @see Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/NotNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/NotNode.java
index 93c67a3..1800678 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/NotNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/NotNode.java
@@ -81,9 +81,10 @@
*
* @param node the child expression to add to this NOT node
*/
+ @Override
public void addNode( ExprNode node )
{
- if ( ( children == null ) || ( children.size() >= 1 ) )
+ if ( ( children == null ) || ( !children.isEmpty() ) )
{
throw new IllegalStateException( I18n.err( I18n.ERR_04159 ) );
}
@@ -97,9 +98,10 @@
*
* @param node the child expression to add to this branch node
*/
+ @Override
public void addNodeToHead( ExprNode node )
{
- if ( children.size() >= 1 )
+ if ( !children.isEmpty() )
{
throw new IllegalStateException( I18n.err( I18n.ERR_04159 ) );
}
@@ -113,6 +115,7 @@
*
* @param childList the list of children to set.
*/
+ @Override
public void setChildren( List<ExprNode> childList )
{
if ( ( childList != null ) && ( childList.size() > 1 ) )
@@ -175,6 +178,7 @@
* @return The buffer in which the refinement has been appended
* @throws UnsupportedOperationException if this node isn't a part of a refinement.
*/
+ @Override
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
buf.append( "not: " );
@@ -193,6 +197,7 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ObjectClassNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ObjectClassNode.java
index 06c6355..5037a13 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ObjectClassNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ObjectClassNode.java
@@ -46,6 +46,7 @@
*
* This implementation always returns true.
*/
+ @Override
public boolean isLeaf()
{
return true;
@@ -57,6 +58,7 @@
*
* This implementation always returns null.
*/
+ @Override
public Object accept( FilterVisitor visitor )
{
return null;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/OrNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/OrNode.java
index 5b6c8b1..1aaf60d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/OrNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/OrNode.java
@@ -113,6 +113,7 @@
* @return The buffer in which the refinement has been appended
* @throws UnsupportedOperationException if this node isn't a part of a refinement.
*/
+ @Override
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
buf.append( "or: {" );
@@ -146,6 +147,7 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
@@ -168,11 +170,13 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
hash = hash * 17 + AssertionType.OR.hashCode();
hash = hash * 17 + ( annotations == null ? 0 : annotations.hashCode() );
+
return hash;
}
@@ -180,6 +184,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object other )
{
if ( this == other )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/PresenceNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/PresenceNode.java
index fb8fbff..3e74047 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/PresenceNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/PresenceNode.java
@@ -57,6 +57,7 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ScopeNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ScopeNode.java
index 2ee20ae..fc12c56 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ScopeNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/ScopeNode.java
@@ -71,6 +71,7 @@
* @see ExprNode#isLeaf()
* @return <code>true</code>
*/
+ @Override
public boolean isLeaf()
{
return true;
@@ -128,6 +129,7 @@
* @param visitor the filter expression tree structure visitor
* @return The modified element
*/
+ @Override
public Object accept( FilterVisitor visitor )
{
if ( visitor.canVisit( this ) )
@@ -215,6 +217,7 @@
* @see Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SimpleNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SimpleNode.java
index 47679ae..e38c019 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SimpleNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SimpleNode.java
@@ -29,6 +29,8 @@
/**
* A simple assertion value node.
*
+ * @param <T> The Value type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class SimpleNode<T> extends LeafNode
@@ -121,8 +123,6 @@
/**
* Pretty prints this expression node along with annotation information.
*
- * TODO - perhaps this belong in some utility class?
- *
* @param buf the buffer to print into
* @return the same buf argument returned for call chaining
*/
@@ -146,6 +146,7 @@
* @return The buffer in which the refinement has been appended
* @throws UnsupportedOperationException if this node isn't a part of a refinement.
*/
+ @Override
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
if ( isSchemaAware )
@@ -175,6 +176,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -189,6 +191,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals( Object other )
{
if ( this == other )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SubstringNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SubstringNode.java
index 4fa5197..fd0a8a2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SubstringNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/SubstringNode.java
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
import org.apache.directory.api.ldap.model.entry.StringValue;
import org.apache.directory.api.ldap.model.exception.LdapException;
@@ -60,7 +59,7 @@
{
super( attributeType, AssertionType.SUBSTRING );
- anyPattern = new ArrayList<String>( 2 );
+ anyPattern = new ArrayList<>( 2 );
this.finalPattern = finalPattern;
this.initialPattern = initialPattern;
}
@@ -78,7 +77,7 @@
{
super( attribute, AssertionType.SUBSTRING );
- anyPattern = new ArrayList<String>( 2 );
+ anyPattern = new ArrayList<>( 2 );
this.finalPattern = finalPattern;
this.initialPattern = initialPattern;
}
@@ -93,7 +92,7 @@
{
super( attribute, AssertionType.SUBSTRING );
- anyPattern = new ArrayList<String>( 2 );
+ anyPattern = new ArrayList<>( 2 );
this.finalPattern = null;
this.initialPattern = null;
}
@@ -108,7 +107,7 @@
{
super( attributeType, AssertionType.SUBSTRING );
- anyPattern = new ArrayList<String>( 2 );
+ anyPattern = new ArrayList<>( 2 );
this.finalPattern = null;
this.initialPattern = null;
}
@@ -169,9 +168,8 @@
* compiled
*/
public static Pattern getRegex( String initialPattern, String[] anyPattern, String finalPattern )
- throws PatternSyntaxException
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
if ( initialPattern != null )
{
@@ -205,11 +203,11 @@
@Override
public ExprNode clone()
{
- ExprNode clone = ( ExprNode ) super.clone();
+ ExprNode clone = super.clone();
if ( anyPattern != null )
{
- ( ( SubstringNode ) clone ).anyPattern = new ArrayList<String>();
+ ( ( SubstringNode ) clone ).anyPattern = new ArrayList<>();
for ( String any : anyPattern )
{
@@ -303,13 +301,13 @@
*/
public final Pattern getRegex( Normalizer normalizer ) throws LdapException
{
- if ( ( anyPattern != null ) && ( anyPattern.size() > 0 ) )
+ if ( ( anyPattern != null ) && ( !anyPattern.isEmpty() ) )
{
String[] any = new String[anyPattern.size()];
for ( int i = 0; i < any.length; i++ )
{
- any[i] = ( String ) normalizer.normalize( anyPattern.get( i ) );
+ any[i] = normalizer.normalize( anyPattern.get( i ) );
if ( any[i].length() == 0 )
{
@@ -321,14 +319,14 @@
if ( initialPattern != null )
{
- initialStr = ( String ) normalizer.normalize( initialPattern );
+ initialStr = normalizer.normalize( initialPattern );
}
String finalStr = null;
if ( finalPattern != null )
{
- finalStr = ( String ) normalizer.normalize( finalPattern );
+ finalStr = normalizer.normalize( finalPattern );
}
return getRegex( initialStr, any, finalStr );
@@ -338,14 +336,14 @@
if ( initialPattern != null )
{
- initialStr = ( String ) normalizer.normalize( initialPattern );
+ initialStr = normalizer.normalize( initialPattern );
}
String finalStr = null;
if ( finalPattern != null )
{
- finalStr = ( String ) normalizer.normalize( finalPattern );
+ finalStr = normalizer.normalize( finalPattern );
}
return getRegex( initialStr, null, finalStr );
@@ -433,6 +431,7 @@
* @see java.lang.Object#toString()
* @return A string representing the AndNode
*/
+ @Override
public String toString()
{
StringBuilder buf = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
index 487f280..d56c28a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
@@ -46,6 +46,7 @@
*
* This implementation always returns false.
*/
+ @Override
public boolean isLeaf()
{
return false;
@@ -57,6 +58,7 @@
*
* This implementation always returns null.
*/
+ @Override
public Object accept( FilterVisitor visitor )
{
return null;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/ChangeType.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/ChangeType.java
index 6846179..5d420e9 100755
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/ChangeType.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/ChangeType.java
@@ -75,7 +75,7 @@
*
* @param changeType The associated value
*/
- private ChangeType( int changeType )
+ ChangeType( int changeType )
{
this.changeType = changeType;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifAttributesReader.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifAttributesReader.java
index 89862c8..92142c4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifAttributesReader.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifAttributesReader.java
@@ -179,7 +179,7 @@
String attributeType = lowerLine.substring( 0, colonIndex );
// We should *not* have a Dn twice
- if ( attributeType.equals( "dn" ) )
+ if ( "dn".equals( attributeType ) )
{
LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -219,7 +219,7 @@
AttributeType attributeType = null;
// We should *not* have a Dn twice
- if ( attributeName.equals( "dn" ) )
+ if ( "dn".equals( attributeName ) )
{
LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -239,7 +239,7 @@
Object attributeValue = parseValue( attributeName, line, colonIndex );
// Update the entry
- Attribute attribute = null;
+ Attribute attribute;
if ( schemaManager == null )
{
@@ -319,7 +319,7 @@
*/
private Entry parseEntry( SchemaManager schemaManager ) throws LdapLdifException
{
- if ( ( lines == null ) || ( lines.size() == 0 ) )
+ if ( ( lines == null ) || lines.isEmpty() )
{
LOG.debug( "The entry is empty : end of ldif file" );
return null;
@@ -369,19 +369,21 @@
/**
* Parse a ldif file. The following rules are processed :
*
+ * <pre>
* <ldif-file> ::= <ldif-attrval-record> <ldif-attrval-records> |
* <ldif-change-record> <ldif-change-records> <ldif-attrval-record> ::=
* <dn-spec> <sep> <attrval-spec> <attrval-specs> <ldif-change-record> ::=
* <dn-spec> <sep> <controls-e> <changerecord> <dn-spec> ::= "dn:" <fill>
* <distinguishedName> | "dn::" <fill> <base64-distinguishedName>
* <changerecord> ::= "changetype:" <fill> <change-op>
+ * </pre>
*
* @return The read entry
* @throws LdapLdifException If the entry can't be read or is invalid
*/
private Attributes parseAttributes() throws LdapLdifException
{
- if ( ( lines == null ) || ( lines.size() == 0 ) )
+ if ( ( lines == null ) || lines.isEmpty() )
{
LOG.debug( "The entry is empty : end of ldif file" );
return null;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifControl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifControl.java
index 55f2023..aab8170 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifControl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifControl.java
@@ -69,6 +69,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "LdifControl : {" + getOid() + ", " + isCritical() + ", " + Strings.dumpBytes( getValue() ) + "}";
@@ -78,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return oid;
@@ -87,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isCritical()
{
return criticality;
@@ -96,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setCritical( boolean criticality )
{
this.criticality = criticality;
@@ -103,7 +107,9 @@
/**
- * {@inheritDoc}
+ * Get back the control value
+ *
+ * @return The control's value
*/
public byte[] getValue()
{
@@ -112,7 +118,9 @@
/**
- * {@inheritDoc}
+ * Store the control value
+ *
+ * @param value The value to store
*/
public void setValue( byte[] value )
{
@@ -121,7 +129,7 @@
/**
- * {@inheritDoc}
+ * @return <t>TRUE</t> if the control has a value
*/
public boolean hasValue()
{
@@ -132,6 +140,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
out.writeUTF( oid );
@@ -159,6 +168,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
oid = in.readUTF();
@@ -180,6 +190,7 @@
/**
* @see Object#hashCode()
*/
+ @Override
public int hashCode()
{
int h = 17;
@@ -201,6 +212,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
if ( o == this )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
index 608d1b4..b963757 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
@@ -117,8 +117,8 @@
{
// Default LDIF content
changeType = ChangeType.None;
- modificationList = new LinkedList<Modification>();
- modifications = new HashMap<String, Modification>();
+ modificationList = new LinkedList<>();
+ modifications = new HashMap<>();
entry = new DefaultEntry( ( Dn ) null );
entryDn = null;
controls = null;
@@ -134,8 +134,8 @@
{
// Default LDIF content
changeType = ChangeType.None;
- modificationList = new LinkedList<Modification>();
- modifications = new HashMap<String, Modification>();
+ modificationList = new LinkedList<>();
+ modifications = new HashMap<>();
entry = new DefaultEntry( schemaManager, ( Dn ) null );
entryDn = null;
controls = null;
@@ -151,8 +151,8 @@
{
// Default LDIF content
changeType = ChangeType.None;
- modificationList = new LinkedList<Modification>();
- modifications = new HashMap<String, Modification>();
+ modificationList = new LinkedList<>();
+ modifications = new HashMap<>();
this.entry = entry;
entryDn = entry.getDn();
controls = null;
@@ -201,7 +201,7 @@
if ( !( ava instanceof String ) )
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12085, ( pos + 1 ) ) );
+ I18n.ERR_12085, pos + 1 ) );
}
String attribute = ( String ) ava;
@@ -231,7 +231,7 @@
else
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12086, ( pos + 1 ) ) );
+ I18n.ERR_12086, pos + 1 ) );
}
valueExpected = false;
@@ -285,7 +285,7 @@
case Modify:
modificationList = ldifEntry.getModifications();
- modifications = new HashMap<String, Modification>();
+ modifications = new HashMap<>();
for ( Modification modification : modificationList )
{
@@ -878,7 +878,7 @@
if ( this.controls == null )
{
- this.controls = new ConcurrentHashMap<String, LdifControl>();
+ this.controls = new ConcurrentHashMap<>();
}
if ( control instanceof LdifControl )
@@ -900,6 +900,7 @@
* @return a clone of the current instance
* @exception CloneNotSupportedException If there is some problem while cloning the instance
*/
+ @Override
public LdifEntry clone() throws CloneNotSupportedException
{
LdifEntry clone = ( LdifEntry ) super.clone();
@@ -916,12 +917,12 @@
if ( modifications != null )
{
- for ( Map.Entry<String, Modification> entry : modifications.entrySet() )
+ for ( Map.Entry<String, Modification> mapEntry : modifications.entrySet() )
{
- Modification modif = entry.getValue();
+ Modification modif = mapEntry.getValue();
Modification modifClone = new DefaultModification( modif.getOperation(),
modif.getAttribute().clone() );
- clone.modifications.put( entry.getKey(), modifClone );
+ clone.modifications.put( mapEntry.getKey(), modifClone );
}
}
@@ -985,6 +986,7 @@
*
* @return an enumeration of all contained attributes
*/
+ @Override
public Iterator<Attribute> iterator()
{
return entry.iterator();
@@ -994,6 +996,7 @@
/**
* @return a String representing the Entry, as a LDIF
*/
+ @Override
public String toString()
{
try
@@ -1012,6 +1015,7 @@
*
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int result = 37;
@@ -1102,6 +1106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean equals( Object o )
{
// Basic equals checks
@@ -1262,16 +1267,16 @@
return false;
}
- for ( Map.Entry<String, LdifControl> entry : controls.entrySet() )
+ for ( Map.Entry<String, LdifControl> mapEntry : controls.entrySet() )
{
- String controlOid = entry.getKey();
+ String controlOid = mapEntry.getKey();
if ( !otherControls.containsKey( controlOid ) )
{
return false;
}
- Control thisControl = entry.getValue();
+ Control thisControl = mapEntry.getValue();
Control otherControl = otherControls.get( controlOid );
if ( thisControl == null )
@@ -1306,6 +1311,7 @@
* @throws IOException If the stream can't be read
* @throws ClassNotFoundException If the LdifEntry can't be created
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the changeType
@@ -1378,7 +1384,7 @@
// We have at least a control
if ( nbControls > 0 )
{
- controls = new ConcurrentHashMap<String, LdifControl>( nbControls );
+ controls = new ConcurrentHashMap<>( nbControls );
for ( int i = 0; i < nbControls; i++ )
{
@@ -1397,6 +1403,7 @@
* @param out The stream in which the ChangeLogEvent will be serialized.
* @throws IOException If the serialization fail
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the changeType
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
index bb7cbe0..ac083af 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
@@ -24,7 +24,6 @@
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -34,6 +33,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -256,7 +257,7 @@
*/
public LdifReader()
{
- lines = new ArrayList<String>();
+ lines = new ArrayList<>();
position = 0;
version = DEFAULT_VERSION;
}
@@ -269,7 +270,7 @@
*/
public LdifReader( SchemaManager schemaManager )
{
- lines = new ArrayList<String>();
+ lines = new ArrayList<>();
position = 0;
version = DEFAULT_VERSION;
this.schemaManager = schemaManager;
@@ -277,35 +278,6 @@
/**
- * Store the reader and intialize the LdifReader
- */
- private void initReader( BufferedReader reader ) throws LdapException
- {
- this.reader = reader;
- init();
- }
-
-
- /**
- * Initialize the LdifReader
- *
- * @throws LdapException If the initialization failed
- */
- public void init() throws LdapException
- {
- lines = new ArrayList<String>();
- position = 0;
- version = DEFAULT_VERSION;
- containsChanges = false;
- containsEntries = false;
-
- // First get the version - if any -
- version = parseVersion();
- prefetched = parseEntry();
- }
-
-
- /**
* A constructor which takes a file name. Default charset is used.
*
* @param ldifFileName A file name containing ldif formated input
@@ -380,8 +352,9 @@
try
{
+ InputStream is = Files.newInputStream( Paths.get( file.getPath() ) );
initReader(
- new BufferedReader( new InputStreamReader( new FileInputStream( file ), Charset.defaultCharset() ) ) );
+ new BufferedReader( new InputStreamReader( is, Charset.defaultCharset() ) ) );
}
catch ( FileNotFoundException fnfe )
{
@@ -393,6 +366,10 @@
{
throw new LdapLdifException( lide.getMessage(), lide );
}
+ catch ( IOException ioe )
+ {
+ throw new LdapLdifException( ioe.getMessage(), ioe );
+ }
catch ( LdapException le )
{
throw new LdapLdifException( le.getMessage(), le );
@@ -401,6 +378,35 @@
/**
+ * Store the reader and intialize the LdifReader
+ */
+ private void initReader( BufferedReader reader ) throws LdapException
+ {
+ this.reader = reader;
+ init();
+ }
+
+
+ /**
+ * Initialize the LdifReader
+ *
+ * @throws LdapException If the initialization failed
+ */
+ public void init() throws LdapException
+ {
+ lines = new ArrayList<>();
+ position = 0;
+ version = DEFAULT_VERSION;
+ containsChanges = false;
+ containsEntries = false;
+
+ // First get the version - if any -
+ version = parseVersion();
+ prefetched = parseEntry();
+ }
+
+
+ /**
* @return The ldif file version
*/
public int getVersion()
@@ -691,11 +697,10 @@
else
{
byte[] data = new byte[( int ) length];
- DataInputStream inf = null;
-
- try
+
+ try ( DataInputStream inf = new DataInputStream(
+ Files.newInputStream( Paths.get( fileName ) ) ) )
{
- inf = new DataInputStream( new FileInputStream( file ) );
inf.readFully( data );
return getValue( attributeName, data );
@@ -714,23 +719,6 @@
LOG.error( I18n.err( I18n.ERR_12022_ERROR_READING_FILE, fileName, lineNumber ) );
throw new LdapLdifException( I18n.err( I18n.ERR_12023_ERROR_READING_BAD_URL ), ioe );
}
- finally
- {
- try
- {
- if ( inf != null )
- {
- inf.close();
- }
- }
- catch ( IOException ioe )
- {
- LOG.error(
- I18n.err( I18n.ERR_12024_CANNOT_CLOSE_FILE, ioe.getMessage(), lineNumber ),
- ioe );
- // Just do nothing ...
- }
- }
}
}
}
@@ -985,7 +973,7 @@
String attributeType = lowerLine.substring( 0, colonIndex );
// We should *not* have a Dn twice
- if ( attributeType.equals( "dn" ) )
+ if ( "dn".equals( attributeType ) )
{
LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS, lineNumber ) );
throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -1239,7 +1227,7 @@
}
// We should *not* have a Dn twice
- if ( attributeType.equalsIgnoreCase( "dn" ) )
+ if ( "dn".equalsIgnoreCase( attributeType ) )
{
LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS, lineNumber ) );
throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
@@ -1400,7 +1388,7 @@
*/
protected LdifEntry parseEntry() throws LdapException
{
- if ( ( lines == null ) || ( lines.size() == 0 ) )
+ if ( ( lines == null ) || lines.isEmpty() )
{
LOG.debug( "The entry is empty : end of ldif file" );
return null;
@@ -1590,7 +1578,7 @@
// First, read a list of lines
readLines();
- if ( lines.size() == 0 )
+ if ( lines.isEmpty() )
{
LOG.warn( "The ldif file is empty" );
return ver;
@@ -1634,7 +1622,7 @@
lines.remove( 0 );
// and read the next lines if the current buffer is empty
- if ( lines.size() == 0 )
+ if ( lines.isEmpty() )
{
// include the version line as part of the first entry
int tmpEntryLen = entryLen;
@@ -1683,7 +1671,7 @@
entryLen = 0;
entryOffset = offset;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
try
{
@@ -1743,7 +1731,7 @@
lines.add( sb.toString() );
}
- sb = new StringBuffer( line );
+ sb = new StringBuilder( line );
insideComment = false;
break;
}
@@ -1804,14 +1792,12 @@
throw new LdapLdifException( I18n.err( I18n.ERR_12067, fileName ) );
}
- BufferedReader bufferReader = null;
-
// Open the file and then get a channel from the stream
- try
+ try (
+ InputStream is = Files.newInputStream( Paths.get( fileName ) );
+ BufferedReader bufferReader = new BufferedReader(
+ new InputStreamReader( is, Charset.forName( encoding ) ) ) )
{
- bufferReader = new BufferedReader(
- new InputStreamReader( new FileInputStream( file ), Charset.forName( encoding ) ) );
-
return parseLdif( bufferReader );
}
catch ( FileNotFoundException fnfe )
@@ -1823,20 +1809,10 @@
{
throw new LdapLdifException( le.getMessage(), le );
}
- finally
+ catch ( IOException ioe )
{
- // close the reader
- try
- {
- if ( bufferReader != null )
- {
- bufferReader.close();
- }
- }
- catch ( IOException ioe )
- {
- // Nothing to do
- }
+ // Nothing to do
+ throw new LdapLdifException( ioe.getMessage(), ioe );
}
}
@@ -1854,7 +1830,7 @@
if ( Strings.isEmpty( ldif ) )
{
- return new ArrayList<LdifEntry>();
+ return new ArrayList<>();
}
BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) );
@@ -2017,16 +1993,19 @@
/**
* @return An iterator on the file
*/
+ @Override
public Iterator<LdifEntry> iterator()
{
return new Iterator<LdifEntry>()
{
+ @Override
public boolean hasNext()
{
return hasNextInternal();
}
+ @Override
public LdifEntry next()
{
try
@@ -2041,6 +2020,7 @@
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException();
@@ -2078,7 +2058,7 @@
public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapException
{
// Create a list that will contain the read entries
- List<LdifEntry> entries = new ArrayList<LdifEntry>();
+ List<LdifEntry> entries = new ArrayList<>();
this.reader = reader;
@@ -2172,6 +2152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
if ( reader != null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
index 0526a58..9e3510b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
@@ -136,7 +136,7 @@
// As the reversed modifications should be pushed in reversed order,
// we create a list to temporarily store the modifications.
- List<Modification> reverseModifications = new ArrayList<Modification>();
+ List<Modification> reverseModifications = new ArrayList<>();
// Loop through all the modifications. For each modification, we will
// have to apply it to the modified entry in order to be able to generate
@@ -236,7 +236,7 @@
}
// Special case if we don't have any reverse modifications
- if ( reverseModifications.size() == 0 )
+ if ( reverseModifications.isEmpty() )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12073, forwardModifications ) );
}
@@ -265,9 +265,9 @@
public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException
{
LdifEntry entry = new LdifEntry();
- Dn currentParent = null;
- Rdn currentRdn = null;
- Dn newDn = null;
+ Dn currentParent;
+ Rdn currentRdn;
+ Dn newDn;
if ( newSuperiorDn == null )
{
@@ -445,7 +445,7 @@
throws LdapInvalidDnException
{
Dn parentDn = entry.getDn();
- Dn newDn = null;
+ Dn newDn;
if ( newRdn == null )
{
@@ -469,8 +469,8 @@
newDn = newDn.getParent();
newDn = newDn.add( newRdn );
- List<LdifEntry> entries = new ArrayList<LdifEntry>( 1 );
- LdifEntry reverted = new LdifEntry();
+ List<LdifEntry> entries = new ArrayList<>( 1 );
+ LdifEntry reverted;
// Start with the cases here
if ( newRdn.size() == 1 )
@@ -530,7 +530,7 @@
boolean overlapping = false;
boolean existInEntry = false;
- Set<Ava> oldAtavs = new HashSet<Ava>();
+ Set<Ava> oldAtavs = new HashSet<>();
// We first build a set with all the oldRDN ATAVs
for ( Ava atav : oldRdn )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
index 134dc51..1da409f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
@@ -160,7 +160,7 @@
}
// The String cannot end with a space
- return ( currentChar != ' ' );
+ return currentChar != ' ';
}
@@ -276,9 +276,7 @@
*/
public static Attributes getJndiAttributesFromLdif( String ldif ) throws LdapLdifException
{
- LdifAttributesReader reader = new LdifAttributesReader();
-
- try
+ try ( LdifAttributesReader reader = new LdifAttributesReader() )
{
Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
@@ -429,7 +427,7 @@
// Fallthrough
case Add:
- if ( ( entry.getEntry() == null ) )
+ if ( entry.getEntry() == null )
{
throw new LdapException( I18n.err( I18n.ERR_12082 ) );
}
@@ -716,7 +714,7 @@
if ( !( ava instanceof String ) )
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12085, ( pos + 1 ) ) );
+ I18n.ERR_12085, pos + 1 ) );
}
String attribute = ( String ) ava;
@@ -746,7 +744,7 @@
else
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
- I18n.ERR_12086, ( pos + 1 ) ) );
+ I18n.ERR_12086, pos + 1 ) );
}
valueExpected = false;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
index a719dd6..d07865e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
@@ -27,7 +27,9 @@
import org.apache.directory.api.ldap.model.schema.SchemaManager;
/**
- * An abstract class implementing the default behavior of an Aninymizer instance
+ * An abstract class implementing the default behavior of an Anonymizer instance
+ *
+ * @param <K> The type of object being anonymized
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -86,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
@@ -97,6 +100,7 @@
*
* @param attributeAnonymizers The list of existing anonymizers
*/
+ @Override
public void setAnonymizers( Map<String, Anonymizer<K>> attributeAnonymizers )
{
this.attributeAnonymizers = attributeAnonymizers;
@@ -106,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<Integer, String> getLatestStringMap()
{
return null;
@@ -113,8 +118,9 @@
/**
- * @param latestStringMap The latest String anonymized value map
+ * {@inheritDoc}
*/
+ @Override
public void setLatestStringMap( Map<Integer, String> latestStringMap )
{
// Do nothing
@@ -124,6 +130,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<Integer, byte[]> getLatestBytesMap()
{
return null;
@@ -131,8 +138,9 @@
/**
- * @param latestBytesMap The latest byte[] anonymized value map
+ * {@inheritDoc}
*/
+ @Override
public void setLatestBytesMap( Map<Integer, byte[]> latestBytesMap )
{
// Do nothing
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
index 16bf45d..6bc92dc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
@@ -31,6 +31,8 @@
/**
* An interface for Anonymizers.
+ *
+ * @param <K> The type of object that will be anonymized
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
index 6ad6477..ae14a29 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
@@ -40,14 +40,14 @@
public class BinaryAnonymizer extends AbstractAnonymizer<byte[]>
{
/** The latest anonymized byte[] value map */
- protected Map<Integer, byte[]> latestBytesMap = new HashMap<Integer, byte[]>();
+ protected Map<Integer, byte[]> latestBytesMap = new HashMap<>();
/**
* Creates a new instance of BinaryAnonymizer.
*/
public BinaryAnonymizer()
{
- latestBytesMap = new HashMap<Integer, byte[]>();
+ latestBytesMap = new HashMap<>();
}
@@ -60,7 +60,7 @@
{
if ( latestBytesMap == null )
{
- this.latestBytesMap = new HashMap<Integer, byte[]>();
+ this.latestBytesMap = new HashMap<>();
}
else
{
@@ -71,6 +71,7 @@
/**
* Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
*/
+ @Override
public Attribute anonymize( Map<Value<byte[]>, Value<byte[]>> valueMap, Set<Value<byte[]>> valueSet, Attribute attribute )
{
Attribute result = new DefaultAttribute( attribute.getAttributeType() );
@@ -89,7 +90,6 @@
}
catch ( LdapInvalidAttributeValueException e )
{
- // TODO Auto-generated catch block
throw new RuntimeException( "Error while anonymizing the value" + value );
}
}
@@ -101,6 +101,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<Integer, byte[]> getLatestBytesMap()
{
return latestBytesMap;
@@ -110,7 +111,8 @@
/**
* {@inheritDoc}
*/
- public void setLatestBytesgMap( Map<Integer, byte[]> latestBytesMap )
+ @Override
+ public void setLatestBytesMap( Map<Integer, byte[]> latestBytesMap )
{
this.latestBytesMap = latestBytesMap;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/CaseSensitiveStringAnonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/CaseSensitiveStringAnonymizer.java
index 05e9623..cb048c4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/CaseSensitiveStringAnonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/CaseSensitiveStringAnonymizer.java
@@ -48,7 +48,7 @@
*/
public CaseSensitiveStringAnonymizer()
{
- latestStringMap = new HashMap<Integer, String>();
+ latestStringMap = new HashMap<>();
caseSensitive = true;
}
@@ -62,7 +62,7 @@
{
if ( latestStringMap == null )
{
- this.latestStringMap = new HashMap<Integer, String>();
+ this.latestStringMap = new HashMap<>();
}
else
{
@@ -76,6 +76,7 @@
/**
* Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
*/
+ @Override
public Attribute anonymize( Map<Value<String>, Value<String>> valueMap, Set<Value<String>> valueSet, Attribute attribute )
{
AttributeType attributeType = attribute.getAttributeType();
@@ -112,7 +113,6 @@
}
catch ( LdapInvalidAttributeValueException e )
{
- // TODO Auto-generated catch block
throw new RuntimeException( "Error while anonymizing the value" + strValue );
}
}
@@ -126,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<Integer, String> getLatestStringMap()
{
return latestStringMap;
@@ -135,6 +136,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setLatestStringMap( Map<Integer, String> latestStringMap )
{
this.latestStringMap = latestStringMap;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
index 146525d..3930412 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
@@ -48,7 +48,7 @@
*/
public IntegerAnonymizer()
{
- latestIntegerMap = new HashMap<Integer, String>();
+ latestIntegerMap = new HashMap<>();
}
@@ -61,7 +61,7 @@
{
if ( latestIntegerMap == null )
{
- this.latestIntegerMap = new HashMap<Integer, String>();
+ this.latestIntegerMap = new HashMap<>();
}
else
{
@@ -72,6 +72,7 @@
/**
* Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
*/
+ @Override
public Attribute anonymize( Map<Value<String>, Value<String>> valueMap, Set<Value<String>> valueSet, Attribute attribute )
{
Attribute result = new DefaultAttribute( attribute.getAttributeType() );
@@ -116,9 +117,9 @@
return result;
}
-
+
/**
- * {@inheritDoc}
+ * @return The Map containing the latest anonymized value for each integer
*/
public Map<Integer, String> getLatestIntegerMap()
{
@@ -127,7 +128,8 @@
/**
- * {@inheritDoc}
+ * Set the Map containing anonymized integers
+ * @param latestIntegerMap The Map containing the latest anonymized value for each integer
*/
public void setLatestIntegerMap( Map<Integer, String> latestIntegerMap )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
index 18a502f..c7fd1f7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
@@ -48,7 +48,7 @@
*/
public StringAnonymizer()
{
- latestStringMap = new HashMap<Integer, String>();
+ latestStringMap = new HashMap<>();
caseSensitive = false;
}
@@ -62,7 +62,7 @@
{
if ( latestStringMap == null )
{
- this.latestStringMap = new HashMap<Integer, String>();
+ this.latestStringMap = new HashMap<>();
}
else
{
@@ -76,6 +76,7 @@
/**
* Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
*/
+ @Override
public Attribute anonymize( Map<Value<String>, Value<String>> valueMap, Set<Value<String>> valueSet, Attribute attribute )
{
AttributeType attributeType = attribute.getAttributeType();
@@ -112,7 +113,6 @@
}
catch ( LdapInvalidAttributeValueException e )
{
- // TODO Auto-generated catch block
throw new RuntimeException( "Error while anonymizing the value" + strValue );
}
}
@@ -126,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<Integer, String> getLatestStringMap()
{
return latestStringMap;
@@ -135,6 +136,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setLatestStringMap( Map<Integer, String> latestStringMap )
{
this.latestStringMap = latestStringMap;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbandonRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbandonRequestImpl.java
index 9af5b09..49fa8b0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbandonRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbandonRequestImpl.java
@@ -60,6 +60,7 @@
*
* @return the id of the request message to abandon
*/
+ @Override
public int getAbandoned()
{
return abandonId;
@@ -69,6 +70,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest setAbandoned( int abandonId )
{
this.abandonId = abandonId;
@@ -90,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -101,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest addControl( Control control )
{
return ( AbandonRequest ) super.addControl( control );
@@ -110,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest addAllControls( Control[] controls )
{
return ( AbandonRequest ) super.addAllControls( controls );
@@ -119,6 +124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonRequest removeControl( Control control )
{
return ( AbandonRequest ) super.removeControl( control );
@@ -133,6 +139,7 @@
* @param obj the object to test for equality to this AbandonRequest
* @return true if the obj equals this request, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -160,6 +167,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -175,6 +183,7 @@
*
* @return A String representing the AbandonRequest
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractAbandonableRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractAbandonableRequest.java
index 4bfce84..8c7e178 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractAbandonableRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractAbandonableRequest.java
@@ -54,6 +54,7 @@
}
+ @Override
public void abandon()
{
if ( abandoned )
@@ -72,6 +73,7 @@
}
+ @Override
public boolean isAbandoned()
{
return abandoned;
@@ -81,6 +83,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AbandonableRequest addAbandonListener( final AbandonListener listener )
{
if ( o == null )
@@ -90,6 +93,7 @@
o.addObserver( new Observer()
{
+ @Override
public void update( Observable o, Object arg )
{
listener.requestAbandoned( AbstractAbandonableRequest.this );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedRequest.java
index 56f3cf9..ec5973a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedRequest.java
@@ -68,6 +68,7 @@
*
* @return the dotted-decimal representation as a String of the OID
*/
+ @Override
public String getRequestName()
{
return oid;
@@ -79,6 +80,7 @@
*
* @param newOid the dotted-decimal representation as a String of the OID
*/
+ @Override
public ExtendedRequest setRequestName( String newOid )
{
this.oid = newOid;
@@ -90,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -101,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addControl( Control control )
{
return ( ExtendedRequest ) super.addControl( control );
@@ -110,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addAllControls( Control[] controls )
{
return ( ExtendedRequest ) super.addAllControls( controls );
@@ -119,6 +124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest removeControl( Control control )
{
return ( ExtendedRequest ) super.removeControl( control );
@@ -135,6 +141,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.EXTENDED_RESPONSE;
@@ -146,6 +153,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public abstract ExtendedResponse getResultResponse();
@@ -190,6 +198,7 @@
* @param obj the object to be checked for equality
* @return true if the obj equals this ExtendedRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -233,9 +242,10 @@
*
* @return an Extended Request String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Extended request\n" );
sb.append( " Request name : '" ).append( oid ).append( "'\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractMessage.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractMessage.java
index 2ef0419..c7cfbc8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractMessage.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractMessage.java
@@ -55,8 +55,8 @@
{
this.id = id;
this.type = type;
- controls = new HashMap<String, Control>();
- parameters = new HashMap<Object, Object>();
+ controls = new HashMap<>();
+ parameters = new HashMap<>();
}
@@ -68,6 +68,7 @@
*
* @return the session unique message id.
*/
+ @Override
public int getMessageId()
{
return id;
@@ -77,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message setMessageId( int id )
{
this.id = id;
@@ -88,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, Control> getControls()
{
return Collections.unmodifiableMap( controls );
@@ -97,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Control getControl( String oid )
{
return controls.get( oid );
@@ -106,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasControl( String oid )
{
return controls.containsKey( oid );
@@ -115,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message addControl( Control control )
{
controls.put( control.getOid(), control );
@@ -128,6 +134,7 @@
*
* @param control the control to remove.
*/
+ @Override
public Message removeControl( Control control )
{
controls.remove( control.getOid() );
@@ -143,6 +150,7 @@
*
* @return the message type code.
*/
+ @Override
public MessageTypeEnum getType()
{
return type;
@@ -162,6 +170,7 @@
* @param key the key used to access a message parameter.
* @return the transient message parameter value.
*/
+ @Override
public Object get( Object key )
{
return parameters.get( key );
@@ -177,6 +186,7 @@
* @param value the parameter value
* @return the old value or null
*/
+ @Override
public Object put( Object key, Object value )
{
return parameters.put( key, value );
@@ -191,6 +201,7 @@
*
* @param obj the object to compare this Message to for equality
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -238,6 +249,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -253,6 +265,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message addAllControls( Control[] controls )
{
for ( Control c : controls )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractRequest.java
index be7543b..0ab49f8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractRequest.java
@@ -54,6 +54,7 @@
*
* @return true if any reply is generated, false if no response is generated
*/
+ @Override
public boolean hasResponse()
{
return hasResponse;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java
index e5a9406..6e5f12c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractResultResponse.java
@@ -56,6 +56,7 @@
*
* @return the LdapResult for this Response.
*/
+ @Override
public LdapResult getLdapResult()
{
return ldapResult;
@@ -110,18 +111,9 @@
}
ResultResponse resp = ( ResultResponse ) obj;
-
- if ( ldapResult != null && resp.getLdapResult() == null )
- {
- return false;
- }
-
- if ( ldapResult == null && resp.getLdapResult() != null )
- {
- return false;
- }
-
- return ( ( ldapResult == null ) || ( resp.getLdapResult() == null ) || ldapResult.equals( resp.getLdapResult() ) );
+
+ return ( ( ldapResult != null ) && ldapResult.equals( resp.getLdapResult() ) )
+ || ( resp.getLdapResult() == null );
}
@@ -130,6 +122,7 @@
*
* @return An Response String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequest.java
index 881a764..4900e51 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequest.java
@@ -69,23 +69,27 @@
/**
* {@inheritDoc}
*/
+ @Override
AddRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
AddRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
AddRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
AddRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequestImpl.java
index 145684f..a4af8d9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddRequestImpl.java
@@ -136,6 +136,7 @@
*
* @return the Dn of the added entry.
*/
+ @Override
public Dn getEntryDn()
{
return entry.getDn();
@@ -145,6 +146,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setEntryDn( Dn dn )
{
entry.setDn( dn );
@@ -156,6 +158,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry getEntry()
{
return entry;
@@ -165,6 +168,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setEntry( Entry entry )
{
this.entry = entry;
@@ -176,6 +180,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -187,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest addControl( Control control )
{
return ( AddRequest ) super.addControl( control );
@@ -196,6 +202,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest addAllControls( Control[] controls )
{
return ( AddRequest ) super.addAllControls( controls );
@@ -205,6 +212,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AddRequest removeControl( Control control )
{
return ( AddRequest ) super.removeControl( control );
@@ -221,6 +229,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.ADD_RESPONSE;
@@ -232,6 +241,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public AddResponse getResultResponse()
{
if ( response == null )
@@ -255,6 +265,7 @@
* @param obj the object to test for equality to this
* @return true if the obj is equal to this AddRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
// Short circuit
@@ -279,11 +290,11 @@
// Check the entry
if ( entry == null )
{
- return ( req.getEntry() == null );
+ return req.getEntry() == null;
}
else
{
- return ( entry.equals( req.getEntry() ) );
+ return entry.equals( req.getEntry() );
}
}
@@ -292,6 +303,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -306,6 +318,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddResponseImpl.java
index e0798fc..716b0ce 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AddResponseImpl.java
@@ -55,6 +55,7 @@
*
* @return An AddResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AliasDerefMode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AliasDerefMode.java
index 1238042..f284d1f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AliasDerefMode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AliasDerefMode.java
@@ -61,7 +61,7 @@
*
* @param value the integer value of the enumeration.
*/
- private AliasDerefMode( int value, String jndiValue )
+ AliasDerefMode( int value, String jndiValue )
{
this.value = value;
this.jndiValue = jndiValue;
@@ -97,19 +97,21 @@
}
else
{
- if ( property.trim().equalsIgnoreCase( "always" ) )
+ String trimmedProperty = property.trim();
+
+ if ( "always".equalsIgnoreCase( trimmedProperty ) )
{
return DEREF_ALWAYS;
}
- else if ( property.trim().equalsIgnoreCase( "never" ) )
+ else if ( "never".equalsIgnoreCase( trimmedProperty ) )
{
return NEVER_DEREF_ALIASES;
}
- else if ( property.trim().equalsIgnoreCase( "finding" ) )
+ else if ( "finding".equalsIgnoreCase( trimmedProperty ) )
{
return DEREF_FINDING_BASE_OBJ;
}
- else if ( property.trim().equalsIgnoreCase( "searching" ) )
+ else if ( "searching".equalsIgnoreCase( trimmedProperty ) )
{
return DEREF_IN_SEARCHING;
}
@@ -229,7 +231,7 @@
/**
- * get the AliasDerefMode corresponding to the string value {@link #jndiValue} passed
+ * get the AliasDerefMode corresponding to the string value jndiValue passed
*
* @param val the AliasDerefMode's string value
* @return the AliasDerefMode whose value is equivalent to the given string value
@@ -263,6 +265,9 @@
}
+ /**
+ * @return The JNDI value
+ */
public String getJndiValue()
{
return jndiValue;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequest.java
index 933030c..f549620 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequest.java
@@ -204,23 +204,27 @@
/**
* {@inheritDoc}
*/
+ @Override
BindRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
BindRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
BindRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
BindRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequestImpl.java
index b819810..b1e8c04 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindRequestImpl.java
@@ -93,6 +93,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSimple()
{
return isSimple;
@@ -102,6 +103,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getSimple()
{
return isSimple;
@@ -111,6 +113,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setSimple( boolean simple )
{
this.isSimple = simple;
@@ -122,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getCredentials()
{
return credentials;
@@ -131,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setCredentials( String credentials )
{
return setCredentials( Strings.getBytesUtf8( credentials ) );
@@ -140,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setCredentials( byte[] credentials )
{
if ( credentials != null )
@@ -174,6 +180,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSaslMechanism()
{
return mechanism;
@@ -183,6 +190,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setSaslMechanism( String saslMechanism )
{
this.isSimple = false;
@@ -195,6 +203,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getName()
{
return name;
@@ -204,6 +213,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setName( String name )
{
this.name = name;
@@ -226,6 +236,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getDn()
{
return dn;
@@ -235,6 +246,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setDn( Dn dn )
{
this.dn = dn;
@@ -247,6 +259,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isVersion3()
{
return isVersion3;
@@ -256,6 +269,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getVersion3()
{
return isVersion3;
@@ -265,6 +279,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setVersion3( boolean version3 )
{
this.isVersion3 = version3;
@@ -276,6 +291,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -287,6 +303,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest addControl( Control control )
{
return ( BindRequest ) super.addControl( control );
@@ -296,6 +313,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest addAllControls( Control[] controls )
{
return ( BindRequest ) super.addAllControls( controls );
@@ -305,6 +323,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public BindRequest removeControl( Control control )
{
return ( BindRequest ) super.removeControl( control );
@@ -320,6 +339,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.BIND_RESPONSE;
@@ -331,6 +351,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public BindResponse getResultResponse()
{
if ( response == null )
@@ -346,6 +367,7 @@
* RFC 2251/4511 [Section 4.11]: Abandon, Bind, Unbind, and StartTLS operations
* cannot be abandoned.
*/
+ @Override
public void abandon()
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04185 ) );
@@ -457,9 +479,10 @@
*
* @return A BindRequest String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " BindRequest\n" );
sb.append( " Version : '" ).append( isVersion3 ? "3" : "2" ).append( "'\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindResponseImpl.java
index aefb119..aa75100 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/BindResponseImpl.java
@@ -72,6 +72,7 @@
*
* @return the sasl mech. specific credentials or null of auth. is simple
*/
+ @Override
public byte[] getServerSaslCreds()
{
if ( serverSaslCreds == null )
@@ -93,6 +94,7 @@
* @param serverSaslCreds
* the sasl auth. mech. specific credentials
*/
+ @Override
public void setServerSaslCreds( byte[] serverSaslCreds )
{
if ( serverSaslCreds != null )
@@ -132,6 +134,7 @@
* the object to test for equality with this BindResponse
* @return true if obj equals this BindResponse false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
// quickly return true if obj is this one
@@ -174,6 +177,7 @@
*
* @return A BindResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequest.java
index 64e2048..98420f3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequest.java
@@ -97,23 +97,27 @@
/**
* {@inheritDoc}
*/
+ @Override
CompareRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
CompareRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
CompareRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
CompareRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequestImpl.java
index 0681cb2..3db1429 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareRequestImpl.java
@@ -72,6 +72,7 @@
*
* @return the Dn of the compared entry.
*/
+ @Override
public Dn getName()
{
return name;
@@ -81,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setName( Dn name )
{
this.name = name;
@@ -94,6 +96,7 @@
*
* @return the attribute value to used in comparison.
*/
+ @Override
public Value<?> getAssertionValue()
{
return attrVal;
@@ -103,6 +106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAssertionValue( String value )
{
this.attrVal = new StringValue( value );
@@ -114,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAssertionValue( byte[] value )
{
if ( value != null )
@@ -134,6 +139,7 @@
*
* @return the attribute id used in comparison.
*/
+ @Override
public String getAttributeId()
{
return attrId;
@@ -143,6 +149,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setAttributeId( String attributeId )
{
this.attrId = attributeId;
@@ -154,6 +161,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -165,6 +173,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest addControl( Control control )
{
return ( CompareRequest ) super.addControl( control );
@@ -174,6 +183,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest addAllControls( Control[] controls )
{
return ( CompareRequest ) super.addAllControls( controls );
@@ -183,6 +193,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CompareRequest removeControl( Control control )
{
return ( CompareRequest ) super.removeControl( control );
@@ -199,6 +210,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.COMPARE_RESPONSE;
@@ -210,6 +222,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public CompareResponse getResultResponse()
{
if ( response == null )
@@ -257,6 +270,7 @@
* @param obj the obj to compare with this CompareRequest
* @return true if the obj is equal to this request, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -271,21 +285,21 @@
CompareRequest req = ( CompareRequest ) obj;
Dn reqName = req.getName();
-
+
if ( ( name != null ) && ( reqName == null ) )
{
return false;
}
if ( ( name == null ) && ( reqName != null ) )
- {
- return false;
- }
+ {
+ return false;
+ }
if ( ( name != null ) && ( reqName != null ) && !name.equals( req.getName() ) )
{
- return false;
- }
+ return false;
+ }
String reqId = req.getAttributeId();
@@ -295,14 +309,14 @@
}
if ( ( attrId == null ) && ( reqId != null ) )
- {
- return false;
- }
+ {
+ return false;
+ }
if ( ( attrId != null ) && ( reqId != null ) && !attrId.equals( reqId ) )
{
- return false;
- }
+ return false;
+ }
Value<?> reqVal = req.getAssertionValue();
@@ -329,6 +343,7 @@
*
* @return A Compare Request String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponse.java
index 01ec0ab..32b6261 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponse.java
@@ -29,7 +29,6 @@
public interface CompareResponse extends ResultResponse
{
/**
- * @return True if the compared response is a success
* @return <tt>true</tt> if the compare response is TRUE, <tt>false</tt> otherwise
*/
boolean isTrue();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponseImpl.java
index 1b325f1..e47efb0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/CompareResponseImpl.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isTrue()
{
return ldapResult.getResultCode() == ResultCodeEnum.COMPARE_TRUE;
@@ -64,6 +65,7 @@
*
* @return An CompareResponse String
*/
+ @Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequest.java
index d60ee1f..391a496 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequest.java
@@ -53,23 +53,27 @@
/**
* {@inheritDoc}
*/
+ @Override
DeleteRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
DeleteRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
DeleteRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
DeleteRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequestImpl.java
index 4783655..e0a574f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteRequestImpl.java
@@ -62,6 +62,7 @@
*
* @return the Dn of the leaf entry to delete.
*/
+ @Override
public Dn getName()
{
return name;
@@ -71,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest setName( Dn name )
{
this.name = name;
@@ -82,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -93,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest addControl( Control control )
{
return ( DeleteRequest ) super.addControl( control );
@@ -102,6 +106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest addAllControls( Control[] controls )
{
return ( DeleteRequest ) super.addAllControls( controls );
@@ -111,6 +116,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DeleteRequest removeControl( Control control )
{
return ( DeleteRequest ) super.removeControl( control );
@@ -127,6 +133,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.DEL_RESPONSE;
@@ -138,6 +145,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public DeleteResponse getResultResponse()
{
if ( response == null )
@@ -178,6 +186,7 @@
* @param obj the object to test for equality to this
* @return true if the obj is equal to this DeleteRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -216,6 +225,7 @@
*
* @return A DelRequest String
*/
+ @Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteResponseImpl.java
index 6b25c51..55f4726 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/DeleteResponseImpl.java
@@ -55,6 +55,7 @@
*
* @return A DelResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequest.java
index dbb100a..d6189d4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequest.java
@@ -75,23 +75,27 @@
/**
* {@inheritDoc}
*/
+ @Override
ExtendedRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
ExtendedRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
ExtendedRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
ExtendedRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
index f84fd85..71a48fa 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
@@ -56,6 +56,7 @@
*
* @return the dotted-decimal representation as a String of the OID
*/
+ @Override
public String getRequestName()
{
return oid;
@@ -67,6 +68,7 @@
*
* @param newOid the dotted-decimal representation as a String of the OID
*/
+ @Override
public ExtendedRequest setRequestName( String newOid )
{
this.oid = newOid;
@@ -78,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -89,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addControl( Control control )
{
return ( ExtendedRequest ) super.addControl( control );
@@ -98,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest addAllControls( Control[] controls )
{
return ( ExtendedRequest ) super.addAllControls( controls );
@@ -107,6 +112,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedRequest removeControl( Control control )
{
return ( ExtendedRequest ) super.removeControl( control );
@@ -123,6 +129,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.EXTENDED_RESPONSE;
@@ -148,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExtendedResponse getResultResponse()
{
return getExtendedResponse();
@@ -177,6 +185,7 @@
* @param obj the object to be checked for equality
* @return true if the obj equals this ExtendedRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -220,9 +229,10 @@
*
* @return an Extended Request String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Extended request\n" );
sb.append( " Request name : '" ).append( oid ).append( "'\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java
index 761fa34..640ceae 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java
@@ -79,9 +79,10 @@
*
* @return the responseName of the extended response
*/
+ @Override
public String getResponseName()
{
- return ( ( responseName == null ) ? "" : responseName );
+ return ( responseName == null ) ? "" : responseName;
}
@@ -91,6 +92,7 @@
*
* @param responseName the OID of the extended response type.
*/
+ @Override
public void setResponseName( String responseName )
{
this.responseName = responseName;
@@ -123,6 +125,7 @@
* the object to be checked for equality
* @return true if the obj equals this ExtendedRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -167,6 +170,7 @@
*
* @return An ExtendedResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/IntermediateResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/IntermediateResponseImpl.java
index 7b93f62..72e4fdc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/IntermediateResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/IntermediateResponseImpl.java
@@ -41,6 +41,10 @@
protected byte[] responseValue;
+ /**
+ * Creates a new IntermediateResponseImpl instance
+ * @param id The request ID
+ */
public IntermediateResponseImpl( int id )
{
super( id, TYPE );
@@ -56,6 +60,7 @@
*
* @return the response value
*/
+ @Override
public byte[] getResponseValue()
{
if ( responseValue == null )
@@ -74,6 +79,7 @@
*
* @param value the response value.
*/
+ @Override
public void setResponseValue( byte[] value )
{
if ( value != null )
@@ -94,9 +100,10 @@
*
* @return the OID of the Intermediate response type.
*/
+ @Override
public String getResponseName()
{
- return ( ( responseName == null ) ? "" : responseName );
+ return ( responseName == null ) ? "" : responseName;
}
@@ -106,6 +113,7 @@
*
* @param oid the OID of the Intermediate response type.
*/
+ @Override
public void setResponseName( String oid )
{
this.responseName = oid;
@@ -139,6 +147,7 @@
* @param obj the object to be checked for equality
* @return true if the obj equals this IntemediateResponse, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -184,8 +193,8 @@
return false;
}
- return ( ( responseValue == null ) || ( resp.getResponseValue() == null )
- || Arrays.equals( responseValue, resp.getResponseValue() ) );
+ return ( responseValue == null ) || ( resp.getResponseValue() == null )
+ || Arrays.equals( responseValue, resp.getResponseValue() );
}
@@ -194,6 +203,7 @@
*
* @return An IntermediateResponse String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/LdapResultImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/LdapResultImpl.java
index 3ce1fab..c5b15f6 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/LdapResultImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/LdapResultImpl.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getDiagnosticMessage()
{
return diagnosticMessage;
@@ -62,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDiagnosticMessage( String diagnosticMessage )
{
this.diagnosticMessage = diagnosticMessage;
@@ -72,6 +74,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getMatchedDn()
{
return matchedDn;
@@ -81,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMatchedDn( Dn matchedDn )
{
this.matchedDn = matchedDn;
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ResultCodeEnum getResultCode()
{
return resultCode;
@@ -100,17 +105,19 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setResultCode( ResultCodeEnum resultCode )
{
this.resultCode = resultCode;
- isDefaultSuccess = isDefaultSuccess & ( resultCode == ResultCodeEnum.SUCCESS );
+ isDefaultSuccess = isDefaultSuccess && ( resultCode == ResultCodeEnum.SUCCESS );
}
/**
* {@inheritDoc}
*/
+ @Override
public Referral getReferral()
{
return referral;
@@ -120,6 +127,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReferral()
{
return referral != null;
@@ -129,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReferral( Referral referral )
{
this.referral = referral;
@@ -139,6 +148,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDefaultSuccess()
{
return isDefaultSuccess;
@@ -149,6 +159,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -178,6 +189,7 @@
* @param obj The object to compare with
* @return <code>true</code> if both objects are equals
*/
+ @Override
public boolean equals( Object obj )
{
// quickly return true if this is the obj
@@ -256,6 +268,7 @@
*
* @return A LdapResult String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/MessageTypeEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/MessageTypeEnum.java
index e54bca2..c04c355 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/MessageTypeEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/MessageTypeEnum.java
@@ -27,25 +27,66 @@
*/
public enum MessageTypeEnum
{
+ /** The AbandonRequest message */
ABANDON_REQUEST,
+
+ /** The AddResquest message */
ADD_REQUEST,
+
+ /** The Response message */
ADD_RESPONSE,
+
+ /** The BindRequest message */
BIND_REQUEST,
+
+ /** The BindResponse message */
BIND_RESPONSE,
+
+ /** The ompareRequest message */
COMPARE_REQUEST,
+
+ /** The CompareResponse message */
COMPARE_RESPONSE,
+
+ /** The DelRequest message */
DEL_REQUEST,
+
+ /** The DelResponse message */
DEL_RESPONSE,
+
+ /** The ExtendedRequest message */
EXTENDED_REQUEST,
+
+ /** The ExtendedResponse message */
EXTENDED_RESPONSE,
+
+ /** The ModifyDNRequest message */
MODIFYDN_REQUEST,
+
+ /** The ModifyDNResponse message */
MODIFYDN_RESPONSE,
+
+ /** The ModifyRequest message */
MODIFY_REQUEST,
+
+ /** The ModifyResponse message */
MODIFY_RESPONSE,
+
+ /** The SearchRequest message */
SEARCH_REQUEST,
+
+ /** The SeaechResultDone response message */
SEARCH_RESULT_DONE,
+
+ /** The SearchResultEntry Response message */
SEARCH_RESULT_ENTRY,
+
+ /** The earchResultReference Response message */
SEARCH_RESULT_REFERENCE,
+
+ /** The UnbindRequest message */
UNBIND_REQUEST,
+
+ /** The IntermediateResponse message */
INTERMEDIATE_RESPONSE;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequest.java
index 5990d51..05d2ee4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequest.java
@@ -165,23 +165,27 @@
/**
* {@inheritDoc}
*/
+ @Override
ModifyDnRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
ModifyDnRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
ModifyDnRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
ModifyDnRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequestImpl.java
index fd7f731..2c9cb0f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnRequestImpl.java
@@ -69,6 +69,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getDeleteOldRdn()
{
return deleteOldRdn;
@@ -78,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setDeleteOldRdn( boolean deleteOldRdn )
{
this.deleteOldRdn = deleteOldRdn;
@@ -89,6 +91,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isMove()
{
return newSuperior != null;
@@ -98,6 +101,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return name;
@@ -107,6 +111,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setName( Dn name )
{
this.name = name;
@@ -118,6 +123,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Rdn getNewRdn()
{
return newRdn;
@@ -127,6 +133,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
this.newRdn = newRdn;
@@ -138,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getNewSuperior()
{
return newSuperior;
@@ -147,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setNewSuperior( Dn newSuperior )
{
this.newSuperior = newSuperior;
@@ -158,6 +167,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -169,6 +179,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest addControl( Control control )
{
return ( ModifyDnRequest ) super.addControl( control );
@@ -178,6 +189,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest addAllControls( Control[] controls )
{
return ( ModifyDnRequest ) super.addAllControls( controls );
@@ -187,6 +199,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyDnRequest removeControl( Control control )
{
return ( ModifyDnRequest ) super.removeControl( control );
@@ -203,6 +216,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.MODIFYDN_RESPONSE;
@@ -214,6 +228,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public ModifyDnResponse getResultResponse()
{
if ( response == null )
@@ -259,6 +274,7 @@
* @param obj the object to compare with this stub
* @return true if the obj is equal to this stub, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -318,8 +334,8 @@
return false;
}
- return ( ( newSuperior == null ) || ( req.getNewSuperior() == null ) || newSuperior.equals( req
- .getNewSuperior() ) );
+ return ( newSuperior == null ) || ( req.getNewSuperior() == null ) || newSuperior.equals( req
+ .getNewSuperior() );
}
@@ -328,10 +344,11 @@
*
* @return A ModifyDNRequest String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " ModifyDN Response\n" );
sb.append( " Entry : '" ).append( name ).append( "'\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnResponseImpl.java
index 3f9e7be..c50e07f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyDnResponseImpl.java
@@ -55,6 +55,7 @@
*
* @return A ModifyDNResponse String
*/
+ @Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequest.java
index ea10c68..ccbdf38 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequest.java
@@ -269,23 +269,27 @@
/**
* {@inheritDoc}
*/
+ @Override
ModifyRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
ModifyRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
ModifyRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
ModifyRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequestImpl.java
index 86372e7..077a3d9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyRequestImpl.java
@@ -48,7 +48,7 @@
private Dn name;
/** Sequence of modifications or PDU's <b>modification</b> sequence field */
- private List<Modification> mods = new ArrayList<Modification>();
+ private List<Modification> mods = new ArrayList<>();
/** The associated response */
private ModifyResponse response;
@@ -73,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<Modification> getModifications()
{
return Collections.unmodifiableCollection( mods );
@@ -82,6 +83,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Dn getName()
{
return name;
@@ -91,6 +93,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest setName( Dn name )
{
this.name = name;
@@ -102,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addModification( Modification mod )
{
mods.add( mod );
@@ -127,6 +131,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addModification( Attribute attr, ModificationOperation modOp )
{
mods.add( new DefaultModification( modOp, attr ) );
@@ -138,6 +143,7 @@
/**
*{@inheritDoc}
*/
+ @Override
public ModifyRequest add( String attributeName, String... attributeValue )
{
addModification( ModificationOperation.ADD_ATTRIBUTE, attributeName, attributeValue );
@@ -160,6 +166,7 @@
/**
*{@inheritDoc}
*/
+ @Override
public ModifyRequest add( Attribute attr )
{
addModification( attr, ModificationOperation.ADD_ATTRIBUTE );
@@ -171,6 +178,7 @@
/**
* @see #replace(String, String...)
*/
+ @Override
public ModifyRequest replace( String attributeName )
{
addModification( ModificationOperation.REPLACE_ATTRIBUTE, attributeName, StringConstants.EMPTY_STRINGS );
@@ -182,6 +190,7 @@
/**
*{@inheritDoc}
*/
+ @Override
public ModifyRequest replace( String attributeName, String... attributeValue )
{
addModification( ModificationOperation.REPLACE_ATTRIBUTE, attributeName, attributeValue );
@@ -204,6 +213,7 @@
/**
*{@inheritDoc}
*/
+ @Override
public ModifyRequest replace( Attribute attr )
{
addModification( attr, ModificationOperation.REPLACE_ATTRIBUTE );
@@ -215,6 +225,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest removeModification( Modification mod )
{
mods.remove( mod );
@@ -226,6 +237,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( String attributeName, String... attributeValue )
{
addModification( ModificationOperation.REMOVE_ATTRIBUTE, attributeName, attributeValue );
@@ -248,6 +260,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( Attribute attr )
{
addModification( attr, ModificationOperation.REMOVE_ATTRIBUTE );
@@ -259,6 +272,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest remove( String attributerName )
{
addModification( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attributerName ) );
@@ -270,6 +284,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -281,6 +296,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addControl( Control control )
{
return ( ModifyRequest ) super.addControl( control );
@@ -290,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest addAllControls( Control[] controls )
{
return ( ModifyRequest ) super.addAllControls( controls );
@@ -299,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ModifyRequest removeControl( Control control )
{
return ( ModifyRequest ) super.removeControl( control );
@@ -315,6 +333,7 @@
*
* @return the message type of the response.
*/
+ @Override
public MessageTypeEnum getResponseType()
{
return MessageTypeEnum.MODIFY_RESPONSE;
@@ -326,6 +345,7 @@
*
* @return the result containing response for this request
*/
+ @Override
public ModifyResponse getResultResponse()
{
if ( response == null )
@@ -367,6 +387,7 @@
* the object to compare this ModifyRequest to
* @return true if obj equals this ModifyRequest, false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -431,10 +452,10 @@
*
* @return A ModifyRequest String
*/
+ @Override
public String toString()
{
-
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Modify Request\n" );
sb.append( " Object : '" ).append( name ).append( "'\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyResponseImpl.java
index 362fe06..7da58be 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ModifyResponseImpl.java
@@ -54,6 +54,7 @@
*
* @return A ModifyResponse String
*/
+ @Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java
index 31d2bbe..f3dfd03 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralImpl.java
@@ -39,10 +39,10 @@
static final long serialVersionUID = 2638820668325359096L;
/** Sequence of LDAPUrls composing this Referral */
- private final List<String> urls = new ArrayList<String>();
+ private final List<String> urls = new ArrayList<>();
/** The encoded LdapURL */
- private final List<byte[]> urlsBytes = new ArrayList<byte[]>();
+ private final List<byte[]> urlsBytes = new ArrayList<>();
/** The length of the referral */
private int referralLength;
@@ -54,6 +54,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getReferralLength()
{
return referralLength;
@@ -63,6 +64,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReferralLength( int referralLength )
{
this.referralLength = referralLength;
@@ -74,6 +76,7 @@
*
* @return the alternative url objects.
*/
+ @Override
public Collection<String> getLdapUrls()
{
return Collections.unmodifiableCollection( urls );
@@ -83,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<byte[]> getLdapUrlsBytes()
{
return urlsBytes;
@@ -94,6 +98,7 @@
*
* @param url the LDAPv3 URL to add
*/
+ @Override
public void addLdapUrl( String url )
{
urls.add( url );
@@ -103,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addLdapUrlBytes( byte[] urlBytes )
{
urlsBytes.add( urlBytes );
@@ -115,6 +121,7 @@
* @param url
* the LDAPv3 URL to remove
*/
+ @Override
public void removeLdapUrl( String url )
{
urls.remove( url );
@@ -125,6 +132,7 @@
* @see Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
int hash = 37;
@@ -150,6 +158,7 @@
* the object to compare this ReferralImpl to
* @return true if both implementations contain exactly the same URLs
*/
+ @Override
public boolean equals( Object obj )
{
// just in case for speed return true if obj is this object
@@ -192,11 +201,12 @@
*
* @return A Referral String
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
- if ( ( urls != null ) && ( urls.size() != 0 ) )
+ if ( !urls.isEmpty() )
{
sb.append( " Referrals :\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java
index 1ff19f9..4092cda 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java
@@ -30,7 +30,12 @@
*/
public enum ReferralsPolicyEnum
{
+ /** Ignore referral */
IGNORE,
+
+ /** Floow referral */
FOLLOW,
+
+ /** Throw an exception */
THROW
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
index 6ddce6a..e24473d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
@@ -99,7 +99,7 @@
* attributeOrValueExists (20),
* invalidAttributeSyntax (21),
* -- 22-31 unused --
- * NO_SUCH_OBJECT (32),
+ * NO_SUCH_OBJECT (32),
* aliasProblem (33),
* invalidDNSyntax (34),
* -- 35 reserved for undefined isLeaf --
@@ -719,39 +719,7 @@
/** Stores the description of each element of the enumeration */
private String message;
-
- /**
- * Private construct so no other instances can be created other than the
- * public static constants in this class.
- *
- * @param value the integer value of the enumeration.
- * @param message the description of the enumeration.
- */
- private ResultCodeEnum( int value, String message )
- {
- this.value = value;
- this.message = message;
- }
-
-
- /**
- * @return The value associated with the current element.
- */
- public int getValue()
- {
- return value;
- }
-
-
- /**
- * @return The description associated with the current element.
- */
- public String getMessage()
- {
- return message;
- }
-
- private static final Set<ResultCodeEnum> EMPTY_RESULT_CODE_SET = new HashSet<ResultCodeEnum>();
+ private static final Set<ResultCodeEnum> EMPTY_RESULT_CODE_SET = new HashSet<>();
// ------------------------------------------------------------------------
// Error Codes Grouped Into Categories & Static Accessors
@@ -775,7 +743,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.SUCCESS );
set.add( ResultCodeEnum.COMPARE_TRUE );
set.add( ResultCodeEnum.COMPARE_FALSE );
@@ -813,7 +781,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -866,7 +834,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -926,7 +894,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -988,7 +956,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -1043,7 +1011,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -1097,7 +1065,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.BUSY );
set.add( ResultCodeEnum.OTHER );
set.add( ResultCodeEnum.SUCCESS );
@@ -1154,7 +1122,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.OPERATIONS_ERROR );
set.add( ResultCodeEnum.PROTOCOL_ERROR );
set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
@@ -1229,7 +1197,7 @@
static
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> set = new HashSet<>();
set.add( ResultCodeEnum.SUCCESS );
set.add( ResultCodeEnum.OPERATIONS_ERROR );
set.add( ResultCodeEnum.PROTOCOL_ERROR );
@@ -1272,6 +1240,204 @@
set.add( ResultCodeEnum.CANCELED );
EXTENDED_CODES = Collections.unmodifiableSet( set );
}
+ // ------------------------------------------------------------------------
+ // Getting Result Code Enumeration Object Using Integer Values
+ // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // JNDI Exception to ResultCodeEnum Mappings
+ // ------------------------------------------------------------------------
+
+ /**
+ * A set of ResultCodes containing those that may correspond to NamingException.
+ * <ul>
+ * <li><a href="#OPERATIONSERROR">operationsError(1)</a></li>
+ * <li><a href="#ALIAS_PROBLEM">aliasProblem(33)</a></li>
+ * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">aliasDereferencingProblem(36)</a></li>
+ * <li><a href="#LOOP_DETECT">loopDetect(54)</a></li>
+ * <li><a href="#AFFECTS_MULTIPLE_DSAS">affectsMultipleDSAs(71)</a></li>
+ * <li><a href="#OTHER">other(80)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> NAMING_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.OPERATIONS_ERROR );
+ set.add( ResultCodeEnum.ALIAS_PROBLEM );
+ set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
+ set.add( ResultCodeEnum.LOOP_DETECT );
+ set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
+ set.add( ResultCodeEnum.OTHER );
+ NAMING_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">authMethodNotSupported(7)</a></li>
+ * <li><a href="#STRONG_AUTH_REQUIRED">strongAuthRequired(8)</a></li>
+ * <li><a href="#CONFIDENTIALITY_REQUIRED">confidentialityRequired(13)</a></li>
+ * <li><a
+ * href="#INAPPROPRIATE_AUTHENTICATION">inappropriateAuthentication(48)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
+ set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
+ set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
+ set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
+ AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#BUSY">busy(51)</a></li>
+ * <li><a href="#UNAVAILABLE">unavailable(52)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> SERVICE_UNAVAILABLE_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.BUSY );
+ set.add( ResultCodeEnum.UNAVAILABLE );
+ SERVICE_UNAVAILABLE_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#CONSTRAINT_VIOLATION">constraintViolation(19)</a></li>
+ * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">invalidAttributeSyntax(21)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> INVALID_ATTRIBUTE_VALUE_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
+ set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+ INVALID_ATTRIBUTE_VALUE_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#PARTIAL_RESULTS">partialResults(9)</a></li>
+ * <li><a href="#REFERRAL">referral(10)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> PARTIAL_RESULTS_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.PARTIAL_RESULTS );
+ set.add( ResultCodeEnum.REFERRAL );
+ PARTIAL_RESULTS_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#REFERRAL">referal(9)</a></li>
+ * <li><a href="#ADMIN_LIMIT_EXCEEDED">adminLimitExceeded(11)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> LIMIT_EXCEEDED_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.REFERRAL );
+ set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
+ LIMIT_EXCEEDED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a
+ * href="#UNAVAILABLECRITICALEXTENTION">unavailableCriticalExtention(12)</a></li>
+ * <li><a href="#UNWILLING_TO_PERFORM">unwillingToPerform(53)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> OPERATION_NOT_SUPPORTED_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+ set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
+ OPERATION_NOT_SUPPORTED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link Exception}.
+ * <ul>
+ * <li><a href="#INVALID_DN_SYNTAX">invalidDNSyntax(34)</a></li>
+ * <li><a href="#NAMING_VIOLATION">namingViolation(64)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> INVALID_NAME_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
+ set.add( ResultCodeEnum.NAMING_VIOLATION );
+ INVALID_NAME_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+ /**
+ * A set of ResultCodes containing those that may correspond to a
+ * {@link javax.naming.directory.SchemaViolationException}.
+ * <ul>
+ * <li><a href="#OBJECT_CLASS_VIOLATION">objectClassViolation(65)</a></li>
+ * <li><a href="#NOT_ALLOWED_ON_RDN">notAllowedOnRDN(67)</a></li>
+ * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">objectClassModsProhibited(69)</a></li>
+ * </ul>
+ */
+ private static final Set<ResultCodeEnum> SCHEMA_VIOLATION_EXCEPTION_CODES;
+
+ static
+ {
+ Set<ResultCodeEnum> set = new HashSet<>();
+ set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
+ set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
+ set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
+ SCHEMA_VIOLATION_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ }
+
+
+ /**
+ * Private construct so no other instances can be created other than the
+ * public static constants in this class.
+ *
+ * @param value the integer value of the enumeration.
+ * @param message the description of the enumeration.
+ */
+ ResultCodeEnum( int value, String message )
+ {
+ this.value = value;
+ this.message = message;
+ }
/**
@@ -1390,188 +1556,23 @@
}
}
- // ------------------------------------------------------------------------
- // Getting Result Code Enumeration Object Using Integer Values
- // ------------------------------------------------------------------------
- // ------------------------------------------------------------------------
- // JNDI Exception to ResultCodeEnum Mappings
- // ------------------------------------------------------------------------
+
/**
- * A set of ResultCodes containing those that may correspond to NamingException.
- * <ul>
- * <li><a href="#OPERATIONSERROR">operationsError(1)</a></li>
- * <li><a href="#ALIAS_PROBLEM">aliasProblem(33)</a></li>
- * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">aliasDereferencingProblem(36)</a></li>
- * <li><a href="#LOOP_DETECT">loopDetect(54)</a></li>
- * <li><a href="#AFFECTS_MULTIPLE_DSAS">affectsMultipleDSAs(71)</a></li>
- * <li><a href="#OTHER">other(80)</a></li>
- * </ul>
+ * @return The value associated with the current element.
*/
- private static final Set<ResultCodeEnum> NAMING_EXCEPTION_CODES;
-
- static
+ public int getValue()
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.OPERATIONS_ERROR );
- set.add( ResultCodeEnum.ALIAS_PROBLEM );
- set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
- set.add( ResultCodeEnum.LOOP_DETECT );
- set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
- set.add( ResultCodeEnum.OTHER );
- NAMING_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ return value;
}
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">authMethodNotSupported(7)</a></li>
- * <li><a href="#STRONG_AUTH_REQUIRED">strongAuthRequired(8)</a></li>
- * <li><a href="#CONFIDENTIALITY_REQUIRED">confidentialityRequired(13)</a></li>
- * <li><a
- * href="#INAPPROPRIATE_AUTHENTICATION">inappropriateAuthentication(48)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
- set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
- set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
- set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
- AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
/**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#BUSY">busy(51)</a></li>
- * <li><a href="#UNAVAILABLE">unavailable(52)</a></li>
- * </ul>
+ * @return The description associated with the current element.
*/
- private static final Set<ResultCodeEnum> SERVICE_UNAVAILABLE_CODES;
-
- static
+ public String getMessage()
{
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.BUSY );
- set.add( ResultCodeEnum.UNAVAILABLE );
- SERVICE_UNAVAILABLE_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#CONSTRAINT_VIOLATION">constraintViolation(19)</a></li>
- * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">invalidAttributeSyntax(21)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> INVALID_ATTRIBUTE_VALUE_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
- set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
- INVALID_ATTRIBUTE_VALUE_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#PARTIAL_RESULTS">partialResults(9)</a></li>
- * <li><a href="#REFERRAL">referral(10)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> PARTIAL_RESULTS_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.PARTIAL_RESULTS );
- set.add( ResultCodeEnum.REFERRAL );
- PARTIAL_RESULTS_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#REFERRAL">referal(9)</a></li>
- * <li><a href="#ADMIN_LIMIT_EXCEEDED">adminLimitExceeded(11)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> LIMIT_EXCEEDED_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.REFERRAL );
- set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
- LIMIT_EXCEEDED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a
- * href="#UNAVAILABLECRITICALEXTENTION">unavailableCriticalExtention(12)</a></li>
- * <li><a href="#UNWILLING_TO_PERFORM">unwillingToPerform(53)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> OPERATION_NOT_SUPPORTED_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
- set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
- OPERATION_NOT_SUPPORTED_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link Exception}.
- * <ul>
- * <li><a href="#INVALID_DN_SYNTAX">invalidDNSyntax(34)</a></li>
- * <li><a href="#NAMING_VIOLATION">namingViolation(64)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> INVALID_NAME_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
- set.add( ResultCodeEnum.NAMING_VIOLATION );
- INVALID_NAME_EXCEPTION_CODES = Collections.unmodifiableSet( set );
- }
-
- /**
- * A set of ResultCodes containing those that may correspond to a
- * {@link javax.naming.directory.SchemaViolationException}.
- * <ul>
- * <li><a href="#OBJECT_CLASS_VIOLATION">objectClassViolation(65)</a></li>
- * <li><a href="#NOT_ALLOWED_ON_RDN">notAllowedOnRDN(67)</a></li>
- * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">objectClassModsProhibited(69)</a></li>
- * </ul>
- */
- private static final Set<ResultCodeEnum> SCHEMA_VIOLATION_EXCEPTION_CODES;
-
- static
- {
- Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
- set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
- set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
- set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
- SCHEMA_VIOLATION_EXCEPTION_CODES = Collections.unmodifiableSet( set );
+ return message;
}
@@ -1603,7 +1604,7 @@
if ( type == null )
{
- Set<ResultCodeEnum> tmp = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> tmp = new HashSet<>();
tmp.addAll( set );
tmp.removeAll( NON_ERRONEOUS_CODES );
@@ -1615,7 +1616,7 @@
return tmp.iterator().next();
}
- Set<ResultCodeEnum> candidates = EMPTY_RESULT_CODE_SET;
+ Set<ResultCodeEnum> candidates;
switch ( type )
{
@@ -1721,10 +1722,10 @@
{
if ( s1.isEmpty() || s2.isEmpty() )
{
- return new HashSet<ResultCodeEnum>();
+ return new HashSet<>();
}
- Set<ResultCodeEnum> intersection = new HashSet<ResultCodeEnum>();
+ Set<ResultCodeEnum> intersection = new HashSet<>();
if ( s1.size() <= s2.size() )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchParams.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchParams.java
index 326b8f4..c6b0590 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchParams.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchParams.java
@@ -1,5 +1,5 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
+< * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@@ -76,9 +76,9 @@
*/
public SearchParams()
{
- returningAttributes = new HashSet<AttributeTypeOptions>();
- returningAttributesStr = new HashSet<String>();
- controls = new HashSet<Control>();
+ returningAttributes = new HashSet<>();
+ returningAttributesStr = new HashSet<>();
+ controls = new HashSet<>();
}
@@ -303,6 +303,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
@@ -312,7 +313,7 @@
sb.append( " Alias dereferencing : " ).append( aliasDerefMode ).append( "\n" );
sb.append( " types only : " ).append( typesOnly ).append( "\n" );
- if ( returningAttributesStr.size() != 0 )
+ if ( !returningAttributesStr.isEmpty() )
{
sb.append( " returning attributes : " ).append( Strings.setToString( returningAttributesStr ) )
.append( "\n" );
@@ -336,7 +337,7 @@
sb.append( " no sizeLimit\n" );
}
- if ( controls.size() != 0 )
+ if ( !controls.isEmpty() )
{
for ( Control control : controls )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
index cd6b78b..23b6cdf 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
@@ -58,6 +58,7 @@
* @return the RESPONSE_TYPES array
* @see #RESPONSE_TYPES
*/
+ @Override
MessageTypeEnum[] getResponseTypes();
@@ -252,24 +253,28 @@
/**
* {@inheritDoc}
*/
+ @Override
SearchRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
SearchRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
SearchRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
SearchRequest removeControl( Control control );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
index 57dbae9..f33d791 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
@@ -66,7 +66,7 @@
private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
/** Attributes to return */
- private List<String> attributes = new ArrayList<String>();
+ private List<String> attributes = new ArrayList<>();
/** The final result containing SearchResponseDone response */
private SearchResultDone response;
@@ -95,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getAttributes()
{
return Collections.unmodifiableList( attributes );
@@ -106,6 +107,7 @@
*
* @return the search base
*/
+ @Override
public Dn getBase()
{
return baseDn;
@@ -115,6 +117,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setBase( Dn base )
{
baseDn = base;
@@ -126,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AliasDerefMode getDerefAliases()
{
return aliasDerefMode;
@@ -135,6 +139,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setDerefAliases( AliasDerefMode aliasDerefAliases )
{
this.aliasDerefMode = aliasDerefAliases;
@@ -146,6 +151,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ExprNode getFilter()
{
return filterNode;
@@ -155,6 +161,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setFilter( ExprNode filter )
{
this.filterNode = filter;
@@ -165,6 +172,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setFilter( String filter ) throws LdapException
{
try
@@ -184,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MessageTypeEnum[] getResponseTypes()
{
return RESPONSE_TYPES.clone();
@@ -193,6 +202,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchScope getScope()
{
return scope;
@@ -202,6 +212,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setScope( SearchScope scope )
{
this.scope = scope;
@@ -213,6 +224,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public long getSizeLimit()
{
return sizeLimit;
@@ -222,6 +234,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setSizeLimit( long entriesMax )
{
sizeLimit = entriesMax;
@@ -233,6 +246,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getTimeLimit()
{
return timeLimit;
@@ -242,6 +256,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setTimeLimit( int secondsMax )
{
timeLimit = secondsMax;
@@ -253,6 +268,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean getTypesOnly()
{
return typesOnly;
@@ -262,6 +278,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setTypesOnly( boolean typesOnly )
{
this.typesOnly = typesOnly;
@@ -273,6 +290,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addAttributes( String... attributesToAdd )
{
this.attributes.addAll( Arrays.asList( attributesToAdd ) );
@@ -284,6 +302,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest removeAttribute( String attribute )
{
attributes.remove( attribute );
@@ -295,6 +314,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchResultDone getResultResponse()
{
if ( response == null )
@@ -309,6 +329,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -320,6 +341,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addControl( Control control )
{
return ( SearchRequest ) super.addControl( control );
@@ -329,6 +351,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest addAllControls( Control[] controls )
{
return ( SearchRequest ) super.addAllControls( controls );
@@ -338,6 +361,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest removeControl( Control control )
{
return ( SearchRequest ) super.removeControl( control );
@@ -398,6 +422,7 @@
* @return true if the obj is a SearchRequest and equals this SearchRequest,
* false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -442,12 +467,12 @@
return false;
}
- if ( req.getAttributes() == null && attributes != null && attributes.size() > 0 )
+ if ( req.getAttributes() == null && attributes != null && !attributes.isEmpty() )
{
return false;
}
- if ( req.getAttributes() != null && attributes == null && req.getAttributes().size() > 0 )
+ if ( req.getAttributes() != null && attributes == null && !req.getAttributes().isEmpty() )
{
return false;
}
@@ -483,6 +508,7 @@
* Return a string the represent a SearchRequest
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
@@ -605,6 +631,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isFollowReferrals()
{
return referralHandling == ReferralsPolicyEnum.FOLLOW;
@@ -614,6 +641,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest followReferrals()
{
referralHandling = ReferralsPolicyEnum.FOLLOW;
@@ -625,6 +653,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isIgnoreReferrals()
{
return referralHandling == ReferralsPolicyEnum.IGNORE;
@@ -634,6 +663,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SearchRequest ignoreReferrals()
{
referralHandling = ReferralsPolicyEnum.IGNORE;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultDoneImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultDoneImpl.java
index ac9076e..0aa69ac 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultDoneImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultDoneImpl.java
@@ -74,6 +74,7 @@
* the object to be tested for equality
* @return true if obj is equivalent to this SearchResponseDone impl
*/
+ @Override
public boolean equals( Object obj )
{
// quickly return if the obj is this object
@@ -98,6 +99,7 @@
*
* @return A SearchResultDone String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultEntryImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultEntryImpl.java
index 657809b..f51fb96 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultEntryImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultEntryImpl.java
@@ -69,6 +69,7 @@
*
* @return the entry
*/
+ @Override
public Entry getEntry()
{
return entry;
@@ -80,6 +81,7 @@
*
* @param entry the entry
*/
+ @Override
public void setEntry( Entry entry )
{
this.entry = entry;
@@ -91,9 +93,10 @@
*
* @return the Dn of the entry returned.
*/
+ @Override
public Dn getObjectName()
{
- return ( entry == null ? null : entry.getDn() );
+ return entry == null ? null : entry.getDn();
}
@@ -102,6 +105,7 @@
*
* @param objectName the Dn of the entry returned.
*/
+ @Override
public void setObjectName( Dn objectName )
{
if ( entry != null )
@@ -136,6 +140,7 @@
* the object to test for equality with this message
* @return true if the obj is equal false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -162,6 +167,7 @@
/**
* Return a string representation of a SearchResultEntry request
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultReferenceImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultReferenceImpl.java
index eafd2f2..4cdefb0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultReferenceImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchResultReferenceImpl.java
@@ -64,6 +64,7 @@
*
* @return the sequence of LdapUrls
*/
+ @Override
public Referral getReferral()
{
return this.referral;
@@ -75,6 +76,7 @@
*
* @param referral the sequence of LdapUrls
*/
+ @Override
public void setReferral( Referral referral )
{
this.referral = referral;
@@ -105,6 +107,7 @@
* the object to compare to this response stub
* @return true if the objects are equivalent false otherwise
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -119,17 +122,17 @@
SearchResultReference resp = ( SearchResultReference ) obj;
- if ( this.referral != null && resp.getReferral() == null )
+ if ( referral != null && resp.getReferral() == null )
{
return false;
}
- if ( this.referral == null && resp.getReferral() != null )
+ if ( referral == null && resp.getReferral() != null )
{
return false;
}
- return ( this.referral == null || resp.getReferral() == null || this.referral.equals( resp.getReferral() ) );
+ return referral == null || resp.getReferral() == null || referral.equals( resp.getReferral() );
}
@@ -138,6 +141,7 @@
*
* @return The Search Result Reference string
*/
+ @Override
public String toString()
{
@@ -145,7 +149,7 @@
sb.append( " Search Result Reference\n" );
- if ( ( referral == null ) || ( referral.getLdapUrls() == null ) || ( referral.getLdapUrls().size() == 0 ) )
+ if ( ( referral == null ) || ( referral.getLdapUrls() == null ) || referral.getLdapUrls().isEmpty() )
{
sb.append( " No Reference\n" );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchScope.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchScope.java
index 1531131..6004383 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchScope.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchScope.java
@@ -30,8 +30,13 @@
*/
public enum SearchScope
{
+ /** Base scope */
OBJECT(0, "base"),
+
+ /** One Level scope */
ONELEVEL(1, "one"),
+
+ /** Subtree scope */
SUBTREE(2, "sub");
/**
@@ -56,7 +61,7 @@
* @param scope the scope constant
* @param ldapUrlValue LDAP URL scope string value: base, one, or sub
*/
- private SearchScope( int scope, String ldapUrlValue )
+ SearchScope( int scope, String ldapUrlValue )
{
this.scope = scope;
this.ldapUrlValue = ldapUrlValue;
@@ -173,6 +178,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return ldapUrlValue;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequest.java
index 402ec8e..4846b8a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequest.java
@@ -30,23 +30,27 @@
/**
* {@inheritDoc}
*/
+ @Override
UnbindRequest setMessageId( int messageId );
/**
* {@inheritDoc}
*/
+ @Override
UnbindRequest addControl( Control control );
/**
* {@inheritDoc}
*/
+ @Override
UnbindRequest addAllControls( Control[] controls );
/**
* {@inheritDoc}
*/
+ @Override
UnbindRequest removeControl( Control control );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequestImpl.java
index 83936bb..8449616 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/UnbindRequestImpl.java
@@ -57,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
@@ -68,6 +69,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest addControl( Control control )
{
return ( UnbindRequest ) super.addControl( control );
@@ -77,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest addAllControls( Control[] controls )
{
return ( UnbindRequest ) super.addAllControls( controls );
@@ -86,6 +89,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public UnbindRequest removeControl( Control control )
{
return ( UnbindRequest ) super.removeControl( control );
@@ -97,6 +101,7 @@
*
* @return A UnBindRequest String
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/AbstractControl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/AbstractControl.java
index 33f5915..07898fa 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/AbstractControl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/AbstractControl.java
@@ -69,6 +69,7 @@
*
* @return A string which represent the control oid
*/
+ @Override
public String getOid()
{
return oid == null ? "" : oid;
@@ -80,6 +81,7 @@
*
* @return <code>true</code> if the criticality flag is true.
*/
+ @Override
public boolean isCritical()
{
return criticality;
@@ -91,6 +93,7 @@
*
* @param criticality The criticality value
*/
+ @Override
public void setCritical( boolean criticality )
{
this.criticality = criticality;
@@ -100,6 +103,7 @@
/**
* @see Object#hashCode()
*/
+ @Override
public int hashCode()
{
int h = 17;
@@ -113,6 +117,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
if ( o == this )
@@ -144,9 +149,10 @@
/**
* Return a String representing a Control
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " " ).append( getClass().getSimpleName() ).append( " " );
sb.append( "Control\n" );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ChangeType.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ChangeType.java
index e7883d3..f383946 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ChangeType.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ChangeType.java
@@ -42,12 +42,16 @@
*/
public enum ChangeType
{
+ /** An ADD */
ADD(1),
+ /** A Delete */
DELETE(2),
+ /** A Modify */
MODIFY(4),
+ /** A MODDN */
MODDN(8);
private int value;
@@ -59,7 +63,7 @@
*
* @param value The value for the ChangeType.
*/
- private ChangeType( int value )
+ ChangeType( int value )
{
this.value = value;
}
@@ -98,14 +102,18 @@
{
switch ( value )
{
- case ( 1 ):
+ case 1 :
return ADD;
- case ( 2 ):
+
+ case 2 :
return DELETE;
- case ( 4 ):
+
+ case 4 :
return MODIFY;
- case ( 8 ):
+
+ case 8 :
return MODDN;
+
default:
throw new IllegalArgumentException( I18n.err( I18n.ERR_04055, value ) );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChange.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChange.java
index 704a7c1..c0f43c8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChange.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChange.java
@@ -73,6 +73,7 @@
*/
public interface EntryChange extends Control
{
+ /** No defined change number */
int UNDEFINED_CHANGE_NUMBER = -1;
/** The EntryChange control */
@@ -93,14 +94,30 @@
void setChangeType( ChangeType changeType );
+ /**
+ * @return The previous DN
+ */
Dn getPreviousDn();
+ /**
+ * Sets the previous DN
+ *
+ * @param previousDn The previous DN
+ */
void setPreviousDn( Dn previousDn );
+ /**
+ * @return The change number
+ */
long getChangeNumber();
+ /**
+ * Sets the ChangeNumber
+ *
+ * @param changeNumber The ChanegNumber
+ */
void setChangeNumber( long changeNumber );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
index 7685819..d5f3f66 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
@@ -50,36 +50,60 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public ChangeType getChangeType()
{
return changeType;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangeType( ChangeType changeType )
{
this.changeType = changeType;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public Dn getPreviousDn()
{
return previousDn;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setPreviousDn( Dn previousDn )
{
this.previousDn = previousDn;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public long getChangeNumber()
{
return changeNumber;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangeNumber( long changeNumber )
{
this.changeNumber = changeNumber;
@@ -89,11 +113,12 @@
/**
* @see Object#hashCode()
*/
+ @Override
public int hashCode()
{
int h = super.hashCode();
- h = h * 37 + Long.valueOf( changeNumber ).intValue();
+ h = h * 37 + ( int ) changeNumber;
h = h * 37 + ( changeType == null ? 0 : changeType.hashCode() );
h = h * 37 + ( previousDn == null ? 0 : previousDn.hashCode() );
@@ -122,9 +147,10 @@
/**
* Return a String representing this EntryChangeControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Entry Change Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
index ce92cd2..cf4e67b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
@@ -20,7 +20,6 @@
package org.apache.directory.api.ldap.model.message.controls;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import java.util.Arrays;
@@ -63,7 +62,7 @@
private int size;
/** The exchanged cookie */
- private byte[] cookie = StringConstants.EMPTY_BYTES;
+ private byte[] cookie = Strings.EMPTY_BYTES;
/**
@@ -75,30 +74,50 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public int getSize()
{
return size;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setSize( int size )
{
this.size = size;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public byte[] getCookie()
{
return cookie;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public int getCookieValue()
{
int value = 0;
@@ -172,9 +191,10 @@
/**
* Return a String representing this PagedSearchControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Paged Search Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearch.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearch.java
index 1824eff..81a2456 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearch.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearch.java
@@ -35,32 +35,75 @@
/** Min and Max values for the possible combined change types */
int CHANGE_TYPES_MIN = ChangeType.ADD.getValue();
+ /** The maximum value for the possible combined changes type */
int CHANGE_TYPES_MAX = ChangeType.ADD.getValue()
| ChangeType.DELETE.getValue()
| ChangeType.MODIFY.getValue()
| ChangeType.MODDN.getValue();
+ /**
+ * Sets the ChangesOnly flag
+ *
+ * @param changesOnly The ChangesOnly flag
+ */
void setChangesOnly( boolean changesOnly );
+ /**
+ * @return <TT>TRUE</TT> if the changesOnly flag is set
+ */
boolean isChangesOnly();
+ /**
+ * Sets the return entry changes flag
+ *
+ * @param returnECs the return entry changes flag
+ */
void setReturnECs( boolean returnECs );
+ /**
+ * @return <TT>TRUE</TT> if the return entry changes flag is set
+ */
boolean isReturnECs();
+ /**
+ * Set the changeType value we want to get back ( a combinaison of Add, Delete,
+ * Modify and ModifyDN)
+ *
+ * @param changeTypes The changeType values (Add, Modify, Delete and ModifyDn)
+ */
void setChangeTypes( int changeTypes );
+ /**
+ * @return The changeTypes value
+ */
int getChangeTypes();
+ /**
+ * For each changeType, tells if the notification is enabled
+ *
+ * @param changeType The ChnageType we are interested in
+ * @return <T>TRUE<T> if the notification is set for this ChangeType
+ */
boolean isNotificationEnabled( ChangeType changeType );
+ /**
+ * Sets the notification for a given changeType
+ * @param changeType The chnageType we want some notification to be set
+ */
void enableNotification( ChangeType changeType );
+
+
+ /**
+ * Unsets the notification for a given changeType
+ * @param changeType The chnageType we want some notification to be unset
+ */
+ void disableNotification( ChangeType changeType );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
index bf3b7e5..14e5d5d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
@@ -64,48 +64,80 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangesOnly( boolean changesOnly )
{
this.changesOnly = changesOnly;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isChangesOnly()
{
return changesOnly;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setReturnECs( boolean returnECs )
{
this.returnECs = returnECs;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isReturnECs()
{
return returnECs;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void setChangeTypes( int changeTypes )
{
this.changeTypes = changeTypes;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public int getChangeTypes()
{
return changeTypes;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean isNotificationEnabled( ChangeType changeType )
{
return ( changeType.getValue() & changeTypes ) > 0;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void enableNotification( ChangeType changeType )
{
changeTypes |= changeType.getValue();
@@ -113,11 +145,22 @@
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public void disableNotification( ChangeType changeType )
+ {
+ changeTypes &= ~changeType.getValue();
+ }
+
+
+ /**
* Return a String representing this PSearchControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Persistant Search Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
index e7e06bb..6e25e72 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
@@ -52,6 +52,7 @@
/**
* @return the authzId
*/
+ @Override
public String getAuthzId()
{
return authzId;
@@ -70,6 +71,7 @@
* </pre>
* @param authzId the authzId to set
*/
+ @Override
public void setAuthzId( String authzId )
{
// We should have a valid authzId
@@ -139,9 +141,10 @@
/**
* Return a String representing this PagedSearchControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Proxied Authz Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java
index 14bacd1..0f9e301 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java
@@ -139,6 +139,7 @@
/**
* @see String#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
index 0170bdc..b75179d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
@@ -37,6 +37,9 @@
private List<SortKey> sortKeys;
+ /**
+ * Creates a new SortRequestControlImpl instance
+ */
public SortRequestControlImpl()
{
super( OID );
@@ -46,6 +49,7 @@
/**
* @return the sortKeys
*/
+ @Override
public List<SortKey> getSortKeys()
{
return sortKeys;
@@ -55,23 +59,31 @@
/**
* @param sortKeys the sortKeys to set
*/
+ @Override
public void setSortKeys( List<SortKey> sortKeys )
{
this.sortKeys = sortKeys;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void addSortKey( SortKey skey )
{
if ( sortKeys == null )
{
- sortKeys = new ArrayList<SortKey>();
+ sortKeys = new ArrayList<>();
}
sortKeys.add( skey );
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
index ea978cf..dc77a00 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
@@ -32,35 +32,53 @@
/** name of the first offending attribute */
private String attributeName;
+ /**
+ * Creates a new SortResponseControlImpl instance
+ */
public SortResponseControlImpl()
{
super( OID );
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setSortResult( SortResultCode result )
{
this.result = result;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public SortResultCode getSortResult()
{
return result;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setAttributeName( String attributeName )
{
this.attributeName = attributeName;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getAttributeName()
{
return attributeName;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int hashCode()
{
@@ -72,6 +90,9 @@
return hash;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals( Object o )
{
@@ -89,7 +110,7 @@
if ( attributeName != null )
{
- return ( attributeName.equalsIgnoreCase( that.getAttributeName() ) );
+ return attributeName.equalsIgnoreCase( that.getAttributeName() );
}
else if ( that.getAttributeName() == null )
{
@@ -99,6 +120,9 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString()
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResultCode.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResultCode.java
index 0cc95b4..e45e427 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResultCode.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResultCode.java
@@ -52,17 +52,21 @@
int val;
String desc;
- private SortResultCode( int val, String desc )
+ SortResultCode( int val, String desc )
{
this.val = val;
this.desc = desc;
}
+ /**
+ * @return The internet value
+ */
public int getVal()
{
return val;
}
+
/**
* returns the enum value representing the given code.
*
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
index 29e82a0..3d3fe9c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
@@ -69,6 +69,7 @@
/**
* returns Tells if the Subentry values are visible or not
*/
+ @Override
public boolean isVisible()
{
return visibility;
@@ -78,6 +79,7 @@
/**
* @param visibility Set the visibility flag
*/
+ @Override
public void setVisibility( boolean visibility )
{
this.visibility = visibility;
@@ -101,6 +103,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
if ( !super.equals( o ) )
@@ -110,16 +113,17 @@
Subentries otherDecorator = ( Subentries ) o;
- return ( visibility == otherDecorator.isVisible() );
+ return visibility == otherDecorator.isVisible();
}
/**
* Return a String representing this EntryChangeControl.
*/
+ @Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( " Subentries Control\n" );
sb.append( " oid : " ).append( getOid() ).append( '\n' );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
index 7d0de8a..2eb1267 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
@@ -99,6 +99,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return EXTENSION_OID;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
index 39fc57a..38e8456 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
@@ -179,6 +179,7 @@
*
* @return the OID of the extended response type.
*/
+ @Override
public String getResponseName()
{
return EXTENSION_OID;
@@ -192,6 +193,7 @@
* @param oid
* the OID of the extended response type.
*/
+ @Override
public void setResponseName( String oid )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
@@ -223,6 +225,6 @@
return true;
}
- return ( obj instanceof NoticeOfDisconnect );
+ return obj instanceof NoticeOfDisconnect;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
index a98b4be..4af621f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
@@ -248,83 +248,6 @@
/**
- * Construct a schema aware Ava. The AttributeType and value will be checked accordingly
- * to the SchemaManager.
- * <p>
- * Note that the upValue should <b>not</b> be null or empty, or resolve
- * to an empty string after having trimmed it.
- *
- * @param schemaManager The SchemaManager instance
- * @param upType The User Provided type
- * @param value The value
- *
- * @throws LdapInvalidDnException If the given type or value are invalid
- */
- private void createAva( SchemaManager schemaManager, String upType, Value<?> value )
- throws LdapInvalidDnException
- {
- normType = attributeType.getOid();
- this.upType = upType;
- this.value = value;
- upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
- hashCode();
- }
-
-
- /**
- * Construct an Ava. The type and value are normalized :
- * <li> the type is trimmed and lowercased </li>
- * <li> the value is trimmed </li>
- * <p>
- * Note that the upValue should <b>not</b> be null or empty, or resolved
- * to an empty string after having trimmed it.
- *
- * @param upType The User Provided type
- * @param upValue The User Provided value
- *
- * @throws LdapInvalidDnException If the given type or value are invalid
- */
- private void createAva( String upType, Value<?> upValue ) throws LdapInvalidDnException
- {
- String upTypeTrimmed = Strings.trim( upType );
- String normTypeTrimmed = Strings.trim( normType );
-
- if ( Strings.isEmpty( upTypeTrimmed ) )
- {
- if ( Strings.isEmpty( normTypeTrimmed ) )
- {
- String message = I18n.err( I18n.ERR_04188 );
- LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
- }
- else
- {
- // In this case, we will use the normType instead
- this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
- this.upType = normType;
- }
- }
- else if ( Strings.isEmpty( normTypeTrimmed ) )
- {
- // In this case, we will use the upType instead
- this.normType = Strings.lowerCaseAscii( upTypeTrimmed );
- this.upType = upType;
- }
- else
- {
- this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
- this.upType = upType;
-
- }
-
- value = upValue;
-
- upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
- hashCode();
- }
-
-
- /**
* Construct an Ava. The type and value are normalized :
* <li> the type is trimmed and lowercased </li>
* <li> the value is trimmed </li>
@@ -444,6 +367,83 @@
/**
+ * Construct a schema aware Ava. The AttributeType and value will be checked accordingly
+ * to the SchemaManager.
+ * <p>
+ * Note that the upValue should <b>not</b> be null or empty, or resolve
+ * to an empty string after having trimmed it.
+ *
+ * @param schemaManager The SchemaManager instance
+ * @param upType The User Provided type
+ * @param value The value
+ *
+ * @throws LdapInvalidDnException If the given type or value are invalid
+ */
+ private void createAva( SchemaManager schemaManager, String upType, Value<?> value )
+ throws LdapInvalidDnException
+ {
+ normType = attributeType.getOid();
+ this.upType = upType;
+ this.value = value;
+ upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
+ hashCode();
+ }
+
+
+ /**
+ * Construct an Ava. The type and value are normalized :
+ * <li> the type is trimmed and lowercased </li>
+ * <li> the value is trimmed </li>
+ * <p>
+ * Note that the upValue should <b>not</b> be null or empty, or resolved
+ * to an empty string after having trimmed it.
+ *
+ * @param upType The User Provided type
+ * @param upValue The User Provided value
+ *
+ * @throws LdapInvalidDnException If the given type or value are invalid
+ */
+ private void createAva( String upType, Value<?> upValue ) throws LdapInvalidDnException
+ {
+ String upTypeTrimmed = Strings.trim( upType );
+ String normTypeTrimmed = Strings.trim( normType );
+
+ if ( Strings.isEmpty( upTypeTrimmed ) )
+ {
+ if ( Strings.isEmpty( normTypeTrimmed ) )
+ {
+ String message = I18n.err( I18n.ERR_04188 );
+ LOG.error( message );
+ throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ }
+ else
+ {
+ // In this case, we will use the normType instead
+ this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
+ this.upType = normType;
+ }
+ }
+ else if ( Strings.isEmpty( normTypeTrimmed ) )
+ {
+ // In this case, we will use the upType instead
+ this.normType = Strings.lowerCaseAscii( upTypeTrimmed );
+ this.upType = upType;
+ }
+ else
+ {
+ this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
+ this.upType = upType;
+
+ }
+
+ value = upValue;
+
+ upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
+ hashCode();
+ }
+
+
+ /**
* Apply a SchemaManager to the Ava. It will normalize the Ava.<br>
* If the Ava already had a SchemaManager, then the new SchemaManager will be
* used instead.
@@ -567,6 +567,7 @@
*
* @return a clone of this object
*/
+ @Override
public Ava clone()
{
try
@@ -625,6 +626,7 @@
* @see java.lang.Object#hashCode()
* @return The instance hash code
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -642,6 +644,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -722,7 +725,6 @@
if ( Strings.isEmpty( upName )
|| Strings.isEmpty( upType )
|| Strings.isEmpty( normType )
- || ( value.isNull() )
|| ( value.isNull() ) )
{
String message = "Cannot serialize an wrong ATAV, ";
@@ -972,6 +974,7 @@
*
* @throws IOException If the Ava can't be written in the stream
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
if ( Strings.isEmpty( upName )
@@ -1055,6 +1058,7 @@
* @throws IOException If the Ava can't b written to the stream
* @throws ClassNotFoundException If we can't deserialize an Ava from the stream
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
boolean hasUpName = in.readBoolean();
@@ -1132,11 +1136,11 @@
private int compareValues( Ava that )
{
- int comp = 0;
+ int comp;
if ( value.getNormValue() instanceof String )
{
- comp = ( ( String ) value.getNormValue() ).compareTo( ( ( String ) that.value.getNormValue() ) );
+ comp = ( ( String ) value.getNormValue() ).compareTo( ( String ) that.value.getNormValue() );
return comp;
}
@@ -1147,8 +1151,8 @@
for ( int pos = 0; pos < bytes1.length; pos++ )
{
- int v1 = ( bytes1[pos] & 0x00FF );
- int v2 = ( bytes2[pos] & 0x00FF );
+ int v1 = bytes1[pos] & 0x00FF;
+ int v2 = bytes2[pos] & 0x00FF;
if ( v1 > v2 )
{
@@ -1169,7 +1173,7 @@
/**
* @see Comparable#compareTo(Object)
*/
- @SuppressWarnings("unchecked")
+ @Override
public int compareTo( Ava that )
{
if ( that == null )
@@ -1177,7 +1181,7 @@
return 1;
}
- int comp = 0;
+ int comp;
if ( schemaManager == null )
{
@@ -1282,6 +1286,7 @@
*
* @return A string representing an Ava
*/
+ @Override
public String toString()
{
return upName;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
index 62943af..4ad8744 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
@@ -102,7 +102,7 @@
* <li>[2] : dc=a</li>
* </ul>
*/
- protected List<Rdn> rdns = new ArrayList<Rdn>( 5 );
+ protected List<Rdn> rdns = new ArrayList<>( 5 );
/** The user provided name */
private String upName;
@@ -140,6 +140,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasNext()
{
return index >= 0;
@@ -149,6 +150,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Rdn next()
{
return index >= 0 ? rdns.get( index-- ) : null;
@@ -158,6 +160,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void remove()
{
// Not implemented
@@ -416,13 +419,13 @@
*/
private String toUpName()
{
- if ( rdns.size() == 0 )
+ if ( rdns.isEmpty() )
{
upName = "";
}
else
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( Rdn rdn : rdns )
@@ -473,7 +476,7 @@
*/
public String getName()
{
- return ( upName == null ? "" : upName );
+ return upName == null ? "" : upName;
}
@@ -653,7 +656,7 @@
*/
public boolean isEmpty()
{
- return ( rdns.size() == 0 );
+ return rdns.isEmpty();
}
@@ -664,7 +667,7 @@
*/
public boolean isRootDse()
{
- return ( rdns.size() == 0 );
+ return rdns.isEmpty();
}
@@ -679,7 +682,7 @@
*/
public Rdn getRdn( int posn )
{
- if ( rdns.size() == 0 )
+ if ( rdns.isEmpty() )
{
return null;
}
@@ -689,9 +692,7 @@
throw new IllegalArgumentException( "Invalid position : " + posn );
}
- Rdn rdn = rdns.get( posn );
-
- return rdn;
+ return rdns.get( posn );
}
@@ -771,7 +772,7 @@
return this;
}
- if ( rdns.size() == 0 )
+ if ( rdns.isEmpty() )
{
return EMPTY_DN;
}
@@ -860,7 +861,7 @@
return this;
}
- if ( rdns.size() == 0 )
+ if ( rdns.isEmpty() )
{
return EMPTY_DN;
}
@@ -901,7 +902,13 @@
/**
- * {@inheritDoc}
+ * Add a suffix to the Dn. For instance, if the current Dn is "ou=people",
+ * and the suffix "dc=example,dc=com", then the resulting Dn will be
+ * "ou=people,dc=example,dc=com"
+ *
+ * @param suffix the suffix to add
+ * @return The resulting Dn with the additional suffix
+ * @throws LdapInvalidDnException If the resulting Dn is not valid
*/
public Dn add( Dn suffix ) throws LdapInvalidDnException
{
@@ -936,7 +943,13 @@
/**
- * {@inheritDoc}
+ * Add a suffix to the Dn. For instance, if the current Dn is "ou=people",
+ * and the suffix "dc=example,dc=com", then the resulting Dn will be
+ * "ou=people,dc=example,dc=com"
+ *
+ * @param comp the suffix to add
+ * @return The resulting Dn with the additional suffix
+ * @throws LdapInvalidDnException If the resulting Dn is not valid
*/
public Dn add( String comp ) throws LdapInvalidDnException
{
@@ -1027,7 +1040,7 @@
private Dn copy()
{
Dn dn = new Dn( schemaManager );
- dn.rdns = new ArrayList<Rdn>();
+ dn.rdns = new ArrayList<>();
for ( Rdn rdn : rdns )
{
@@ -1129,7 +1142,7 @@
throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX,
I18n.err( I18n.ERR_04460_ATTRIBUTE_TYPE_NULL_NOT_ALLOWED, type ) );
}
- Value<?> atavValue = null;
+ Value<?> atavValue;
Value<?> value = atav.getValue();
if ( value instanceof StringValue )
@@ -1152,14 +1165,12 @@
atavValue = new BinaryValue( attributeType, atav.getValue().getBytes() );
}
- Ava newAva = new Ava(
+ return new Ava(
attributeType,
atav.getType(),
oidNormalizer.getAttributeTypeOid(),
atavValue,
atav.getName() );
-
- return newAva;
}
catch ( LdapException le )
{
@@ -1195,9 +1206,6 @@
{
// We have more than one ATAV for this Rdn. We will loop on all
// ATAVs
- //Rdn rdnCopy = rdn.clone();
- //rdn.clear();
-
if ( rdn.size() < 2 )
{
Ava newAtav = atavOidToName( rdn.getAva(), schemaManager );
@@ -1205,8 +1213,8 @@
}
else
{
- Set<String> sortedOids = new TreeSet<String>();
- Map<String, Ava> avas = new HashMap<String, Ava>();
+ Set<String> sortedOids = new TreeSet<>();
+ Map<String, Ava> avas = new HashMap<>();
// Sort the OIDs
for ( Ava val : rdn )
@@ -1285,14 +1293,14 @@
}
else
{
- if ( rdns.size() == 0 )
+ if ( rdns.isEmpty() )
{
bytes = null;
normName = "";
}
else
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( Rdn rdn : rdns )
@@ -1374,6 +1382,7 @@
* </pre>
*
*/
+ @Override
public Iterator<Rdn> iterator()
{
return new RdnIterator();
@@ -1439,6 +1448,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the UPName
@@ -1460,7 +1470,7 @@
// Read the RDNs. Is it's null, the number will be -1.
int nbRdns = in.readInt();
- rdns = new ArrayList<Rdn>( nbRdns );
+ rdns = new ArrayList<>( nbRdns );
for ( int i = 0; i < nbRdns; i++ )
{
@@ -1474,6 +1484,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
if ( upName == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/DnUtils.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/DnUtils.java
index 6d6504d..245cced 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/DnUtils.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/DnUtils.java
@@ -27,6 +27,11 @@
*/
public final class DnUtils
{
+ private DnUtils()
+ {
+ }
+
+
/**
* Gets the attributeType of a RDN (the left part of the RDN). The RDN is supposed
* to contain only one AVA.
@@ -53,9 +58,4 @@
int index = rdn.indexOf( '=' );
return rdn.substring( index + 1, rdn.length() );
}
-
-
- private DnUtils()
- {
- }
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
index 60bab62..6a485d9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
@@ -41,7 +41,6 @@
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Hex;
import org.apache.directory.api.util.Serialize;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.apache.directory.api.util.Unicode;
import org.slf4j.Logger;
@@ -330,6 +329,13 @@
}
+ /**
+ * A constructor that constructs a Schema aware Rdn from some values.
+ *
+ * @param schemaManager The schemaManager to use
+ * @param avas The list of values
+ * @throws LdapInvalidDnException If the Rdn is invalid
+ */
public Rdn( SchemaManager schemaManager, Ava... avas ) throws LdapInvalidDnException
{
StringBuilder buffer = new StringBuilder();
@@ -350,6 +356,12 @@
}
+ /**
+ * A constructor that constructs a Rdn from some values.
+ *
+ * @param avas The list of values
+ * @throws LdapInvalidDnException If the Rdn is invalid
+ */
public Rdn( Ava... avas ) throws LdapInvalidDnException
{
this( null, avas );
@@ -385,7 +397,7 @@
default:
// We must duplicate the treeSet and the hashMap
- avas = new ArrayList<Ava>();
+ avas = new ArrayList<>();
avaTypes = new MultiValueMap();
for ( Ava currentAva : rdn.avas )
@@ -435,7 +447,7 @@
default:
// We have more than one Ava
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
@@ -502,7 +514,7 @@
private void addAVA( SchemaManager schemaManager, String upType, String type, Value<?> value ) throws LdapInvalidDnException
{
// First, let's normalize the type
- AttributeType attributeType = null;
+ AttributeType attributeType;
String normalizedType = Strings.lowerCaseAscii( type );
this.schemaManager = schemaManager;
@@ -535,7 +547,7 @@
// We already have an Ava. We have to put it in the HashMap
// before adding a new one.
// First, create the HashMap,
- avas = new ArrayList<Ava>();
+ avas = new ArrayList<>();
// and store the existing Ava into it.
avas.add( ava );
@@ -580,22 +592,18 @@
String normalizedType = value.getNormType();
- switch ( nbAvas )
+ if ( nbAvas == 1 )
{
- case 1:
- // This is the first Ava. Just stores it.
- ava = value;
- avaType = normalizedType;
-
- break;
-
- default:
- Ava oldAva = avas.get( pos );
- avas.set( pos, value );
- avaTypes.remove( oldAva.getType() );
- avaTypes.put( normalizedType, value );
-
- break;
+ // This is the first Ava. Just stores it.
+ ava = value;
+ avaType = normalizedType;
+ }
+ else
+ {
+ Ava oldAva = avas.get( pos );
+ avas.set( pos, value );
+ avaTypes.remove( oldAva.getType() );
+ avaTypes.put( normalizedType, value );
}
h = 0;
@@ -631,17 +639,14 @@
// We already have an Ava. We have to put it in the HashMap
// before adding a new one.
// Check that the first AVA is not for the same attribute
- if ( avaType.equals( normalizedType ) )
+ if ( avaType.equals( normalizedType ) && ava.getValue().equals( value.getValue() ) )
{
- if ( ava.getValue().equals( value.getValue() ) )
- {
- throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
- + " is already present in the RDN" );
- }
+ throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
+ + " is already present in the RDN" );
}
// First, create the HashMap,
- avas = new ArrayList<Ava>();
+ avas = new ArrayList<>();
// and store the existing Ava into it.
avas.add( ava );
@@ -746,7 +751,7 @@
{
@SuppressWarnings("unchecked")
Collection<Ava> atavList = ( Collection<Ava> ) avaTypes.get( normalizedType );
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( Ava elem : atavList )
@@ -812,7 +817,7 @@
{
@SuppressWarnings("unchecked")
Collection<Ava> atavList = ( Collection<Ava> ) avaTypes.get( normalizedType );
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( Ava elem : atavList )
@@ -884,6 +889,7 @@
*
* @return an iterator of the components of this Rdn, each an Ava
*/
+ @Override
public Iterator<Ava> iterator()
{
if ( ( nbAvas == 1 ) || ( nbAvas == 0 ) )
@@ -893,12 +899,14 @@
private boolean hasMoreElement = nbAvas == 1;
+ @Override
public boolean hasNext()
{
return hasMoreElement;
}
+ @Override
public Ava next()
{
Ava obj = ava;
@@ -907,6 +915,7 @@
}
+ @Override
public void remove()
{
// nothing to do
@@ -925,6 +934,7 @@
*
* @return A clone of the current Rdn
*/
+ @Override
public Rdn clone()
{
try
@@ -947,7 +957,7 @@
default:
// We must duplicate the treeSet and the hashMap
rdn.avaTypes = new MultiValueMap();
- rdn.avas = new ArrayList<Ava>();
+ rdn.avas = new ArrayList<>();
for ( Ava currentAva : this.avas )
{
@@ -1113,6 +1123,7 @@
* @param that Rdn to be compared for equality with this Rdn
* @return true if the specified object is equal to this Rdn
*/
+ @Override
public boolean equals( Object that )
{
if ( this == that )
@@ -1223,7 +1234,7 @@
* array.
* @throws IllegalArgumentException When an Illegal value is provided.
*/
- public static Object unescapeValue( String value ) throws IllegalArgumentException
+ public static Object unescapeValue( String value )
{
if ( Strings.isEmpty( value ) )
{
@@ -1243,7 +1254,7 @@
if ( chars.length == 1 )
{
// The value is only containing a #
- return StringConstants.EMPTY_BYTES;
+ return Strings.EMPTY_BYTES;
}
if ( ( chars.length % 2 ) != 1 )
@@ -1303,7 +1314,7 @@
if ( Chars.isHex( chars, i ) )
{
isHex = true;
- pair = ( ( byte ) ( Hex.getHexValue( chars[i] ) << 4 ) );
+ pair = ( byte ) ( Hex.getHexValue( chars[i] ) << 4 );
}
break;
@@ -1589,6 +1600,7 @@
* @see java.lang.Object#hashCode()
* @return the instance's hash code
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -1742,7 +1754,7 @@
break;
default:
- avas = new ArrayList<Ava>();
+ avas = new ArrayList<>();
avaTypes = new MultiValueMap();
@@ -1808,6 +1820,7 @@
* @param out The stream into which the serialized Rdn will be put
* @throws IOException If the stream can't be written
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
out.writeInt( nbAvas );
@@ -1856,6 +1869,7 @@
* @throws IOException If we can't read from the input stream
* @throws ClassNotFoundException If we can't create a new Rdn
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the Ava number
@@ -1886,7 +1900,7 @@
break;
default:
- avas = new ArrayList<Ava>();
+ avas = new ArrayList<>();
avaTypes = new MultiValueMap();
@@ -1908,9 +1922,9 @@
}
+ @Override
public int compareTo( Rdn arg0 )
{
- // TODO Auto-generated method stub
return 0;
}
@@ -1919,6 +1933,7 @@
* @return a String representation of the Rdn. The caller will get back the user
* provided Rdn
*/
+ @Override
public String toString()
{
return upName == null ? "" : upName;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/BCrypt.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/BCrypt.java
new file mode 100644
index 0000000..14e1ab6
--- /dev/null
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/BCrypt.java
@@ -0,0 +1,944 @@
+//Copyright (c) 2006 Damien Miller <djm@mindrot.org>
+//
+//Permission to use, copy, modify, and distribute this software for any
+//purpose with or without fee is hereby granted, provided that the above
+//copyright notice and this permission notice appear in all copies.
+//
+//THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+//WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+//MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+//ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+//WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+//ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+//OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+package org.apache.directory.api.ldap.model.password;
+
+
+import java.io.UnsupportedEncodingException;
+import java.security.SecureRandom;
+
+
+/**
+* BCrypt implements OpenBSD-style Blowfish password hashing using
+* the scheme described in "A Future-Adaptable Password Scheme" by
+* Niels Provos and David Mazieres.
+* <p>
+* This password hashing system tries to thwart off-line password
+* cracking using a computationally-intensive hashing algorithm,
+* based on Bruce Schneier's Blowfish cipher. The work factor of
+* the algorithm is parameterised, so it can be increased as
+* computers get faster.
+* <p>
+* Usage is really simple. To hash a password for the first time,
+* call the hashpw method with a random salt, like this:
+* <p>
+* <code>
+* String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br />
+* </code>
+* <p>
+* To check whether a plaintext password matches one that has been
+* hashed previously, use the checkpw method:
+* <p>
+* <code>
+* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
+* System.out.println("It matches");<br />
+* else<br />
+* System.out.println("It does not match");<br />
+* </code>
+* <p>
+* The gensalt() method takes an optional parameter (log_rounds)
+* that determines the computational complexity of the hashing:
+* <p>
+* <code>
+* String strong_salt = BCrypt.gensalt(10)<br />
+* String stronger_salt = BCrypt.gensalt(12)<br />
+* </code>
+* <p>
+* The amount of work increases exponentially (2**log_rounds), so
+* each increment is twice as much work. The default log_rounds is
+* 10, and the valid range is 4 to 30.
+*
+* @author Damien Miller
+* @version 0.2
+*/
+public class BCrypt
+{
+ // BCrypt parameters
+ private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
+ private static final int BCRYPT_SALT_LEN = 16;
+
+ // Blowfish parameters
+ private static final int BLOWFISH_NUM_ROUNDS = 16;
+
+ // Initial contents of key schedule
+ private static final int[] P_ORIG =
+ {
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
+ 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
+ 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
+ 0x9216d5d9, 0x8979fb1b
+ };
+
+ private static final int[] S_ORIG =
+ {
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
+ 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
+ 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
+ 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
+ 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
+ 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
+ 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
+ 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
+ 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
+ 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
+ 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
+ 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
+ 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
+ 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
+ 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
+ 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
+ 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
+ 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
+ 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
+ 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
+ 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
+ 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
+ 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
+ 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
+ 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
+ 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
+ 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
+ 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
+ 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
+ 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
+ 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
+ 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
+ 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
+ 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
+ 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
+ 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
+ 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
+ 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
+ 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
+ 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
+ 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
+ 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
+ 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
+ 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
+ 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
+ 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
+ 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
+ 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
+ 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
+ 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
+ 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
+ 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
+ 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
+ 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
+ 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
+ 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
+ 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
+ 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
+ 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
+ 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
+ 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
+ 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
+ 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
+ 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
+ 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
+ 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
+ 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
+ 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
+ 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
+ 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
+ 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
+ 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
+ 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
+ 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
+ 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
+ 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
+ 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
+ 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
+ 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
+ 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
+ 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
+ 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
+ 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
+ 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
+ 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
+ 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
+ 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
+ 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
+ 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
+ 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
+ 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
+ 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
+ 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
+ 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
+ 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
+ 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
+ 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
+ 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
+ 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
+ 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
+ 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
+ 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
+ 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
+ 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
+ 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
+ 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
+ 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
+ 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
+ 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
+ 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
+ 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
+ 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
+ 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
+ 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
+ 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
+ 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
+ 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
+ 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
+ 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
+ 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
+ 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
+ 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
+ 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
+ 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
+ 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
+ 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
+ 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
+ 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
+ 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
+ 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
+ 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
+ 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
+ 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
+ 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
+ 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
+ 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
+ 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
+ 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
+ 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
+ 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
+ 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
+ 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
+ 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
+ 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
+ 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
+ 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
+ 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
+ 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
+ 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
+ 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
+ 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
+ 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
+ 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
+ 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
+ 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
+ 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
+ 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
+ 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
+ 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
+ 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
+ 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
+ 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
+ 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
+ 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
+ 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
+ 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
+ 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
+ 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
+ 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
+ };
+
+ // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls
+ // this "ciphertext", but it is really plaintext or an IV. We keep
+ // the name to make code comparison easier.
+ private static final int[] BF_CRYPT_CIPHERTEXT =
+ {
+ 0x4f727068,
+ 0x65616e42,
+ 0x65686f6c,
+ 0x64657253,
+ 0x63727944,
+ 0x6f756274
+ };
+
+ // Table for Base64 encoding
+ private static final char[] BASE_64_CHAR =
+ {
+ '.', '/', 'A', 'B', 'C', 'D', 'E', 'F',
+ 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
+ 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z', '0', '1',
+ '2', '3', '4', '5', '6', '7', '8', '9'
+ };
+
+ // Table for Base64 decoding
+ private static final byte[] INDEX_64 =
+ {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 0, 1,
+ 54, 55, 56, 57, 58, 59, 60, 61,
+ 62, 63, -1, -1, -1, -1, -1, -1,
+ -1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, -1, -1, -1, -1, -1,
+ -1, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42,
+ 43, 44, 45, 46, 47, 48, 49, 50,
+ 51, 52, 53, -1, -1, -1, -1, -1
+ };
+
+ // Expanded Blowfish key
+ private int[] pKey;
+ private int[] sKey;
+
+
+ /**
+ * Encode a byte array using bcrypt's slightly-modified base64
+ * encoding scheme. Note that this is *not* compatible with
+ * the standard MIME-base64 encoding.
+ *
+ * @param d the byte array to encode
+ * @param len the number of bytes to encode
+ * @return base64-encoded string
+ * @exception IllegalArgumentException if the length is invalid
+ */
+ private static String encodeBase64( byte[] d, int len )
+ {
+ int off = 0;
+ StringBuilder rs = new StringBuilder();
+ int c1;
+ int c2;
+
+ if ( len <= 0 || len > d.length )
+ {
+ throw new IllegalArgumentException( "Invalid len" );
+ }
+
+ while ( off < len )
+ {
+ c1 = d[off++] & 0xff;
+ rs.append( BASE_64_CHAR[( c1 >> 2 ) & 0x3f] );
+ c1 = ( c1 & 0x03 ) << 4;
+
+ if ( off >= len )
+ {
+ rs.append( BASE_64_CHAR[c1 & 0x3f] );
+ break;
+ }
+
+ c2 = d[off++] & 0xff;
+ c1 |= ( c2 >> 4 ) & 0x0f;
+ rs.append( BASE_64_CHAR[c1 & 0x3f] );
+ c1 = ( c2 & 0x0f ) << 2;
+
+ if ( off >= len )
+ {
+ rs.append( BASE_64_CHAR[c1 & 0x3f] );
+ break;
+ }
+
+ c2 = d[off++] & 0xff;
+ c1 |= ( c2 >> 6 ) & 0x03;
+ rs.append( BASE_64_CHAR[c1 & 0x3f] );
+ rs.append( BASE_64_CHAR[c2 & 0x3f] );
+ }
+
+ return rs.toString();
+ }
+
+
+ /**
+ * Look up the 3 bits base64-encoded by the specified character,
+ * range-checking agaisnt conversion table
+ * @param x the base64-encoded value
+ * @return the decoded value of x
+ */
+ private static byte char64( char x )
+ {
+ if ( ( int ) x < 0 || ( int ) x > INDEX_64.length )
+ {
+ return -1;
+ }
+
+ return INDEX_64[( int ) x];
+ }
+
+
+ /**
+ * Decode a string encoded using bcrypt's base64 scheme to a
+ * byte array. Note that this is *not* compatible with
+ * the standard MIME-base64 encoding.
+ * @param s the string to decode
+ * @param maxolen the maximum number of bytes to decode
+ * @return an array containing the decoded bytes
+ * @throws IllegalArgumentException if maxolen is invalid
+ */
+ private static byte[] decodeBase64( String s, int maxolen )
+ {
+ StringBuilder rs = new StringBuilder();
+ int off = 0;
+ int slen = s.length();
+ int olen = 0;
+ byte[] ret;
+ byte c1;
+ byte c2;
+ byte c3;
+ byte c4;
+ byte o;
+
+ if ( maxolen <= 0 )
+ {
+ throw new IllegalArgumentException( "Invalid maxolen" );
+ }
+
+ while ( off < slen - 1 && olen < maxolen )
+ {
+ c1 = char64( s.charAt( off++ ) );
+ c2 = char64( s.charAt( off++ ) );
+
+ if ( c1 == -1 || c2 == -1 )
+ {
+ break;
+ }
+
+ o = ( byte ) ( c1 << 2 );
+ o |= ( c2 & 0x30 ) >> 4;
+ rs.append( ( char ) o );
+
+ if ( ++olen >= maxolen || off >= slen )
+ {
+ break;
+ }
+
+ c3 = char64( s.charAt( off++ ) );
+
+ if ( c3 == -1 )
+ {
+ break;
+ }
+
+ o = ( byte ) ( ( c2 & 0x0f ) << 4 );
+ o |= ( c3 & 0x3c ) >> 2;
+ rs.append( ( char ) o );
+
+ if ( ++olen >= maxolen || off >= slen )
+ {
+ break;
+ }
+
+ c4 = char64( s.charAt( off++ ) );
+ o = ( byte ) ( ( c3 & 0x03 ) << 6 );
+ o |= c4;
+ rs.append( ( char ) o );
+ ++olen;
+ }
+
+ ret = new byte[olen];
+
+ for ( off = 0; off < olen; off++ )
+ {
+ ret[off] = ( byte ) rs.charAt( off );
+ }
+
+ return ret;
+ }
+
+
+ /**
+ * Blowfish encipher a single 64-bit block encoded as
+ * two 32-bit halves
+ * @param lr an array containing the two 32-bit half blocks
+ * @param off the position in the array of the blocks
+ */
+ private void encipher( int[] lr, int off )
+ {
+ int i;
+ int n;
+ int l = lr[off];
+ int r = lr[off + 1];
+
+ l ^= pKey[0];
+
+ for ( i = 0; i <= BLOWFISH_NUM_ROUNDS - 2; )
+ {
+ // Feistel substitution on left word
+ n = sKey[( l >> 24 ) & 0xff];
+ n += sKey[0x100 | ( ( l >> 16 ) & 0xff )];
+ n ^= sKey[0x200 | ( ( l >> 8 ) & 0xff )];
+ n += sKey[0x300 | ( l & 0xff )];
+ r ^= n ^ pKey[++i];
+
+ // Feistel substitution on right word
+ n = sKey[( r >> 24 ) & 0xff];
+ n += sKey[0x100 | ( ( r >> 16 ) & 0xff )];
+ n ^= sKey[0x200 | ( ( r >> 8 ) & 0xff )];
+ n += sKey[0x300 | ( r & 0xff )];
+ l ^= n ^ pKey[++i];
+ }
+
+ lr[off] = r ^ pKey[BLOWFISH_NUM_ROUNDS + 1];
+ lr[off + 1] = l;
+ }
+
+
+ /**
+ * Cycically extract a word of key material
+ * @param data the string to extract the data from
+ * @param offp a "pointer" (as a one-entry array) to the
+ * current offset into data
+ * @return the next word of material from data
+ */
+ private static int streamToWord( byte[] data, int[] offp )
+ {
+ int i;
+ int word = 0;
+ int off = offp[0];
+
+ for ( i = 0; i < 4; i++ )
+ {
+ word = ( word << 8 ) | ( data[off] & 0xff );
+ off = ( off + 1 ) % data.length;
+ }
+
+ offp[0] = off;
+
+ return word;
+ }
+
+
+ /**
+ * Initialise the Blowfish key schedule
+ */
+ private void initKey()
+ {
+ pKey = ( int[] ) P_ORIG.clone();
+ sKey = ( int[] ) S_ORIG.clone();
+ }
+
+
+ /**
+ * Key the Blowfish cipher
+ * @param key an array containing the key
+ */
+ private void key( byte[] key )
+ {
+ int i;
+ int[] koffp = { 0 };
+ int[] lr = { 0, 0 };
+ int plen = pKey.length;
+ int slen = sKey.length;
+
+ for ( i = 0; i < plen; i++ )
+ {
+ pKey[i] = pKey[i] ^ streamToWord( key, koffp );
+ }
+
+ for ( i = 0; i < plen; i += 2 )
+ {
+ encipher( lr, 0 );
+ pKey[i] = lr[0];
+ pKey[i + 1] = lr[1];
+ }
+
+ for ( i = 0; i < slen; i += 2 )
+ {
+ encipher( lr, 0 );
+ sKey[i] = lr[0];
+ sKey[i + 1] = lr[1];
+ }
+ }
+
+
+ /**
+ * Perform the "enhanced key schedule" step described by
+ * Provos and Mazieres in "A Future-Adaptable Password Scheme"
+ * http://www.openbsd.org/papers/bcrypt-paper.ps
+ * @param data salt information
+ * @param key password information
+ */
+ private void eksKey( byte[] data, byte[] key )
+ {
+ int i;
+ int[] koffp = { 0 };
+ int[] doffp = { 0 };
+ int[] lr = { 0, 0 };
+ int plen = pKey.length;
+ int slen = sKey.length;
+
+ for ( i = 0; i < plen; i++ )
+ {
+ pKey[i] = pKey[i] ^ streamToWord( key, koffp );
+ }
+
+ for ( i = 0; i < plen; i += 2 )
+ {
+ lr[0] ^= streamToWord( data, doffp );
+ lr[1] ^= streamToWord( data, doffp );
+ encipher( lr, 0 );
+ pKey[i] = lr[0];
+ pKey[i + 1] = lr[1];
+ }
+
+ for ( i = 0; i < slen; i += 2 )
+ {
+ lr[0] ^= streamToWord( data, doffp );
+ lr[1] ^= streamToWord( data, doffp );
+ encipher( lr, 0 );
+ sKey[i] = lr[0];
+ sKey[i + 1] = lr[1];
+ }
+ }
+
+
+ /**
+ * Perform the central password hashing step in the
+ * bcrypt scheme
+ * @param password the password to hash
+ * @param salt the binary salt to hash with the password
+ * @param log_rounds the binary logarithm of the number
+ * of rounds of hashing to apply
+ * @param cdata the plaintext to encrypt
+ * @return an array containing the binary hashed password
+ */
+ public byte[] cryptRaw( byte[] password, byte[] salt, int logRounds, int[] cdata )
+ {
+ int rounds;
+ int i;
+ int j;
+ int clen = cdata.length;
+ byte[] ret;
+
+ if ( logRounds < 4 || logRounds > 30 )
+ {
+ throw new IllegalArgumentException( "Bad number of rounds" );
+ }
+
+ rounds = 1 << logRounds;
+
+ if ( salt.length != BCRYPT_SALT_LEN )
+ {
+ throw new IllegalArgumentException( "Bad salt length" );
+ }
+
+ initKey();
+ eksKey( salt, password );
+
+ for ( i = 0; i != rounds; i++ )
+ {
+ key( password );
+ key( salt );
+ }
+
+ for ( i = 0; i < 64; i++ )
+ {
+ for ( j = 0; j < ( clen >> 1 ); j++ )
+ {
+ encipher( cdata, j << 1 );
+ }
+ }
+
+ ret = new byte[clen * 4];
+
+ for ( i = 0, j = 0; i < clen; i++ )
+ {
+ ret[j++] = ( byte ) ( ( cdata[i] >> 24 ) & 0xff );
+ ret[j++] = ( byte ) ( ( cdata[i] >> 16 ) & 0xff );
+ ret[j++] = ( byte ) ( ( cdata[i] >> 8 ) & 0xff );
+ ret[j++] = ( byte ) ( cdata[i] & 0xff );
+ }
+
+ return ret;
+ }
+
+
+ /**
+ * Hash a password using the OpenBSD bcrypt scheme
+ * @param password the password to hash
+ * @param salt the salt to hash with (perhaps generated
+ * using BCrypt.gensalt)
+ * @return the hashed password
+ */
+ public static String hashPw( String password, String salt )
+ {
+ BCrypt bcrypt;
+ String realSalt;
+ byte[] passwordb;
+ byte[] saltb;
+ byte[] hashed;
+ char minor = ( char ) 0;
+ int rounds;
+ int off;
+ StringBuilder rs = new StringBuilder();
+
+ if ( salt.charAt( 0 ) != '$' || salt.charAt( 1 ) != '2' )
+ {
+ throw new IllegalArgumentException( "Invalid salt version" );
+ }
+
+ if ( salt.charAt( 2 ) == '$' )
+ {
+ off = 3;
+ }
+
+ else
+ {
+ minor = salt.charAt( 2 );
+
+ if ( minor != 'a' || salt.charAt( 3 ) != '$' )
+ {
+ throw new IllegalArgumentException( "Invalid salt revision" );
+ }
+
+ off = 4;
+ }
+
+ // Extract number of rounds
+ if ( salt.charAt( off + 2 ) > '$' )
+ {
+ throw new IllegalArgumentException( "Missing salt rounds" );
+ }
+
+ rounds = Integer.parseInt( salt.substring( off, off + 2 ) );
+
+ realSalt = salt.substring( off + 3, off + 25 );
+
+ try
+ {
+ passwordb = ( password + ( minor >= 'a' ? "\000" : "" ) ).getBytes( "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new AssertionError( "UTF-8 is not supported" );
+ }
+
+ saltb = decodeBase64( realSalt, BCRYPT_SALT_LEN );
+
+ bcrypt = new BCrypt();
+ hashed = bcrypt.cryptRaw( passwordb, saltb, rounds, ( int[] ) BF_CRYPT_CIPHERTEXT.clone() );
+
+ rs.append( "$2" );
+
+ if ( minor >= 'a' )
+ {
+ rs.append( minor );
+ }
+
+ rs.append( "$" );
+
+ if ( rounds < 10 )
+ {
+ rs.append( "0" );
+ }
+
+ if ( rounds > 30 )
+ {
+ throw new IllegalArgumentException( "rounds exceeds maximum (30)" );
+ }
+
+ rs.append( Integer.toString( rounds ) );
+ rs.append( "$" );
+ rs.append( encodeBase64( saltb, saltb.length ) );
+ rs.append( encodeBase64( hashed, BF_CRYPT_CIPHERTEXT.length * 4 - 1 ) );
+
+ return rs.toString();
+ }
+
+
+ /**
+ * Generate a salt for use with the BCrypt.hashpw() method
+ * @param log_rounds the log2 of the number of rounds of
+ * hashing to apply - the work factor therefore increases as
+ * 2**log_rounds.
+ * @param random an instance of SecureRandom to use
+ * @return an encoded salt value
+ */
+ public static String genSalt( int logRounds, SecureRandom random )
+ {
+ StringBuilder rs = new StringBuilder();
+ byte[] rnd = new byte[BCRYPT_SALT_LEN];
+
+ random.nextBytes( rnd );
+
+ rs.append( "$2a$" );
+
+ if ( logRounds < 10 )
+ {
+ rs.append( "0" );
+ }
+
+ if ( logRounds > 30 )
+ {
+ throw new IllegalArgumentException( "log_rounds exceeds maximum (30)" );
+ }
+ rs.append( Integer.toString( logRounds ) );
+ rs.append( "$" );
+ rs.append( encodeBase64( rnd, rnd.length ) );
+
+ return rs.toString();
+ }
+
+
+ /**
+ * Generate a salt for use with the BCrypt.hashpw() method
+ * @param log_rounds the log2 of the number of rounds of
+ * hashing to apply - the work factor therefore increases as
+ * 2**log_rounds.
+ * @return an encoded salt value
+ */
+ public static String gensalt( int logRounds )
+ {
+ return genSalt( logRounds, new SecureRandom() );
+ }
+
+
+ /**
+ * Generate a salt for use with the BCrypt.hashpw() method,
+ * selecting a reasonable default for the number of hashing
+ * rounds to apply
+ * @return an encoded salt value
+ */
+ public static String genSalt()
+ {
+ return gensalt( GENSALT_DEFAULT_LOG2_ROUNDS );
+ }
+
+
+ /**
+ * Check that a plaintext password matches a previously hashed
+ * one
+ * @param plaintext the plaintext password to verify
+ * @param hashed the previously-hashed password
+ * @return true if the passwords match, false otherwise
+ */
+ public static boolean checkPw( String plaintext, String hashed )
+ {
+ byte[] hashedBytes;
+ byte[] tryBytes;
+
+ try
+ {
+ String tryPw = hashPw( plaintext, hashed );
+ hashedBytes = hashed.getBytes( "UTF-8" );
+ tryBytes = tryPw.getBytes( "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ return false;
+ }
+
+ if ( hashedBytes.length != tryBytes.length )
+ {
+ return false;
+ }
+
+ byte ret = 0;
+
+ for ( int i = 0; i < tryBytes.length; i++ )
+ {
+ ret |= hashedBytes[i] ^ tryBytes[i];
+ }
+
+ return ret == 0;
+ }
+}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordDetails.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordDetails.java
index 3110e9c..ac66e4b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordDetails.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordDetails.java
@@ -28,9 +28,11 @@
* A class to store all informations about an password.
*
* This includes:
- * - the used algorithm
- * - the salt if any
- * - the password itself.
+ * <ul>
+ * <li> the used algorithm</li>
+ * <li> the salt if any</li>
+ * <li> the password itself</li>
+ * </ul>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -41,6 +43,13 @@
private final byte[] password;
+ /**
+ * Creates a new PasswordDetails instance
+ *
+ * @param algorithm The algorithm to use
+ * @param salt The Salt to use
+ * @param password The password
+ */
public PasswordDetails( LdapSecurityConstants algorithm, byte[] salt, byte[] password )
{
this.algorithm = algorithm;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
index 70625ef..76648a0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
@@ -38,7 +38,6 @@
import org.apache.directory.api.util.DateUtils;
import org.apache.directory.api.util.Strings;
-
/**
* A utility class containing methods related to processing passwords.
*
@@ -77,6 +76,12 @@
/** The CRYPT (SHA-512) hash length */
public static final int CRYPT_SHA512_LENGTH = 86;
+ /** The CRYPT (BCrypt) hash length */
+ public static final int CRYPT_BCRYPT_LENGTH = 31;
+
+ private static final byte[] CRYPT_SALT_CHARS = Strings
+ .getBytesUtf8( "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" );
+
private PasswordUtil()
{
@@ -123,11 +128,17 @@
String algorithm = Strings.toLowerCaseAscii( Strings.utf8ToString( credentials, 1, pos - 1 ) );
// support for crypt additional encryption algorithms (e.g. {crypt}$1$salt$ez2vlPGdaLYkJam5pWs/Y1)
- // currently only one-digit IDs are defined thus this quick check
if ( credentials.length > pos + 3 && credentials[pos + 1] == '$'
- && Character.isDigit( credentials[pos + 2] ) && credentials[pos + 3] == '$' )
+ && Character.isDigit( credentials[pos + 2] ) )
{
- algorithm += Strings.utf8ToString( credentials, pos + 1, 3 );
+ if ( credentials[pos + 3] == '$' )
+ {
+ algorithm += Strings.utf8ToString( credentials, pos + 1, 3 );
+ }
+ else if ( credentials.length > pos + 4 && credentials[pos + 4] == '$' )
+ {
+ algorithm += Strings.utf8ToString( credentials, pos + 1, 4 );
+ }
}
return LdapSecurityConstants.getAlgorithm( algorithm );
@@ -204,17 +215,22 @@
case HASH_METHOD_CRYPT_SHA512:
salt = generateCryptSalt( 8 );
break;
-
+
+ case HASH_METHOD_CRYPT_BCRYPT:
+ salt = Strings.getBytesUtf8( BCrypt.genSalt() );
+ break;
+
default:
salt = null;
}
byte[] hashedPassword = encryptPassword( credentials, algorithm, salt );
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( '{' ).append( Strings.upperCase( algorithm.getPrefix() ) ).append( '}' );
- if ( algorithm == LdapSecurityConstants.HASH_METHOD_CRYPT )
+ if ( algorithm == LdapSecurityConstants.HASH_METHOD_CRYPT
+ || algorithm == LdapSecurityConstants.HASH_METHOD_CRYPT_BCRYPT )
{
sb.append( Strings.utf8ToString( salt ) );
sb.append( Strings.utf8ToString( hashedPassword ) );
@@ -311,7 +327,7 @@
// be able to encrypt the submitted user password in the next step
PasswordDetails passwordDetails = PasswordUtil.splitCredentials( storedCredentials );
- // Reuse the saltedPassword informations to construct the encrypted
+ // Reuse the saltedPassword information to construct the encrypted
// password given by the user.
byte[] userPassword = PasswordUtil.encryptPassword( receivedCredentials, passwordDetails.getAlgorithm(),
passwordDetails.getSalt() );
@@ -408,6 +424,10 @@
algorithm.getSubPrefix() + Strings.utf8ToString( salt ) );
String crypted2 = saltWithCrypted2.substring( saltWithCrypted2.lastIndexOf( '$' ) + 1 );
return Strings.getBytesUtf8( crypted2 );
+
+ case HASH_METHOD_CRYPT_BCRYPT:
+ String crypted3 = BCrypt.hashPw( Strings.utf8ToString( credentials ), Strings.utf8ToString( salt ) );
+ return Strings.getBytesUtf8( crypted3.substring( crypted3.length() - 31 ) );
case HASH_METHOD_PKCS5S2:
return generatePbkdf2Hash( credentials, algorithm, salt );
@@ -474,7 +494,7 @@
}
int algoLength = algorithm.getPrefix().length() + 2;
- byte[] password = null;
+ byte[] password;
switch ( algorithm )
{
@@ -511,6 +531,11 @@
split( credentials, algoLength, salt, password );
return new PasswordDetails( algorithm, salt, password );
+ case HASH_METHOD_CRYPT_BCRYPT:
+ salt = Arrays.copyOfRange( credentials, algoLength, credentials.length - 31 );
+ password = Arrays.copyOfRange( credentials, credentials.length - 31, credentials.length );
+
+ return new PasswordDetails( algorithm, salt, password );
case HASH_METHOD_CRYPT_MD5:
case HASH_METHOD_CRYPT_SHA256:
case HASH_METHOD_CRYPT_SHA512:
@@ -598,8 +623,8 @@
*
* Note: this has been implemented to generate hashes compatible with what JIRA generates.
* See the <a href="http://pythonhosted.org/passlib/lib/passlib.hash.atlassian_pbkdf2_sha1.html">JIRA's passlib</a>
+ * @param credentials the credentials
* @param algorithm the algorithm to use
- * @param password the credentials
* @param salt the optional salt
* @return the digested credentials
*/
@@ -643,10 +668,6 @@
}
- private static final byte[] CRYPT_SALT_CHARS = Strings
- .getBytesUtf8( "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" );
-
-
private static byte[] generateCryptSalt( int length )
{
byte[] salt = new byte[length];
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
index 05ccdb5..c888c9c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
@@ -128,8 +128,8 @@
{
this.objectType = objectType;
this.oid = oid;
- extensions = new HashMap<String, List<String>>();
- names = new ArrayList<String>();
+ extensions = new HashMap<>();
+ names = new ArrayList<>();
}
@@ -142,8 +142,8 @@
protected AbstractSchemaObject( SchemaObjectType objectType )
{
this.objectType = objectType;
- extensions = new HashMap<String, List<String>>();
- names = new ArrayList<String>();
+ extensions = new HashMap<>();
+ names = new ArrayList<>();
}
@@ -157,6 +157,7 @@
* @return an OID for this SchemaObject or its MatchingRule if this
* SchemaObject is a MatchingRuleUse object
*/
+ @Override
public String getOid()
{
return oid;
@@ -168,6 +169,7 @@
* change it's OID
* @param oid The new OID
*/
+ @Override
public void setOid( String oid )
{
if ( locked )
@@ -185,6 +187,7 @@
*
* @return the names for this SchemaObject
*/
+ @Override
public List<String> getNames()
{
if ( names != null )
@@ -205,9 +208,10 @@
* @return the first of the names for this SchemaObject or the oid
* if one does not exist
*/
+ @Override
public String getName()
{
- if ( ( names != null ) && ( names.size() != 0 ) )
+ if ( ( names != null ) && !names.isEmpty() )
{
return names.get( 0 );
}
@@ -224,6 +228,7 @@
*
* @param namesToAdd The names to add
*/
+ @Override
public void addName( String... namesToAdd )
{
if ( locked )
@@ -234,7 +239,7 @@
if ( !isReadOnly )
{
// We must avoid duplicated names, as names are case insensitive
- Set<String> lowerNames = new HashSet<String>();
+ Set<String> lowerNames = new HashSet<>();
// Fills a set with all the existing names
for ( String name : this.names )
@@ -265,6 +270,7 @@
*
* @param names The list of names. Can be empty
*/
+ @Override
public void setNames( List<String> names )
{
if ( locked )
@@ -279,7 +285,7 @@
if ( !isReadOnly )
{
- this.names = new ArrayList<String>( names.size() );
+ this.names = new ArrayList<>( names.size() );
for ( String name : names )
{
@@ -330,6 +336,7 @@
*
* @return a short description about this SchemaObject
*/
+ @Override
public String getDescription()
{
return description;
@@ -341,6 +348,7 @@
*
* @param description The SchemaObject's description
*/
+ @Override
public void setDescription( String description )
{
if ( locked )
@@ -360,6 +368,7 @@
*
* @return the SchemaObject specification
*/
+ @Override
public String getSpecification()
{
return specification;
@@ -371,6 +380,7 @@
*
* @param specification The SchemaObject's specification
*/
+ @Override
public void setSpecification( String specification )
{
if ( locked )
@@ -391,6 +401,7 @@
* @return true if the SchemaObject is enabled, or if it depends on
* an enabled schema
*/
+ @Override
public boolean isEnabled()
{
return isEnabled;
@@ -402,6 +413,7 @@
*
* @return true if the SchemaObject is disabled
*/
+ @Override
public boolean isDisabled()
{
return !isEnabled;
@@ -413,6 +425,7 @@
*
* @param enabled The current SchemaObject state
*/
+ @Override
public void setEnabled( boolean enabled )
{
if ( !isReadOnly )
@@ -427,6 +440,7 @@
*
* @return true if the SchemaObject is not modifiable
*/
+ @Override
public boolean isReadOnly()
{
return isReadOnly;
@@ -438,6 +452,7 @@
*
* @param readOnly The current SchemaObject ReadOnly status
*/
+ @Override
public void setReadOnly( boolean readOnly )
{
if ( locked )
@@ -457,6 +472,7 @@
*
* @return true if inactive, false if active
*/
+ @Override
public boolean isObsolete()
{
return isObsolete;
@@ -468,6 +484,7 @@
*
* @param obsolete The Obsolete flag state
*/
+ @Override
public void setObsolete( boolean obsolete )
{
if ( locked )
@@ -485,6 +502,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, List<String>> getExtensions()
{
return extensions;
@@ -494,7 +512,8 @@
/**
* {@inheritDoc}
*/
- public boolean hasExtension( String extension )
+ @Override
+public boolean hasExtension( String extension )
{
return extensions.containsKey( Strings.toUpperCaseAscii( extension ) );
}
@@ -503,6 +522,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getExtension( String extension )
{
String name = Strings.toUpperCaseAscii( extension );
@@ -529,6 +549,7 @@
* @param key The extension key
* @param values The associated values
*/
+ @Override
public void addExtension( String key, String... values )
{
if ( locked )
@@ -538,7 +559,7 @@
if ( !isReadOnly )
{
- List<String> valueList = new ArrayList<String>();
+ List<String> valueList = new ArrayList<>();
for ( String value : values )
{
@@ -555,6 +576,7 @@
* @param key The extension key
* @param values The associated values
*/
+ @Override
public void addExtension( String key, List<String> values )
{
if ( locked )
@@ -574,6 +596,7 @@
*
* @param extensions The extensions map
*/
+ @Override
public void setExtensions( Map<String, List<String>> extensions )
{
if ( locked )
@@ -583,11 +606,11 @@
if ( !isReadOnly && ( extensions != null ) )
{
- this.extensions = new HashMap<String, List<String>>();
+ this.extensions = new HashMap<>();
for ( Map.Entry<String, List<String>> entry : extensions.entrySet() )
{
- List<String> values = new ArrayList<String>();
+ List<String> values = new ArrayList<>();
for ( String value : entry.getValue() )
{
@@ -619,6 +642,7 @@
*
* @return the SchemaObject type
*/
+ @Override
public SchemaObjectType getObjectType()
{
return objectType;
@@ -630,6 +654,7 @@
*
* @return the name of the schema associated with this schemaObject
*/
+ @Override
public String getSchemaName()
{
return schemaName;
@@ -641,6 +666,7 @@
*
* @param schemaName the new schema name
*/
+ @Override
public void setSchemaName( String schemaName )
{
if ( locked )
@@ -826,14 +852,6 @@
/**
- * Copy the current SchemaObject on place
- *
- * @return The copied SchemaObject
- */
- public abstract SchemaObject copy();
-
-
- /**
* Compare two oids, and return true if they are both null or equal.
*
* @param oid1 the first OID
@@ -856,6 +874,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject copy( SchemaObject original )
{
// copy the description
@@ -867,7 +886,7 @@
isReadOnly = original.isReadOnly();
// copy the names
- names = new ArrayList<String>();
+ names = new ArrayList<>();
for ( String name : original.getNames() )
{
@@ -875,13 +894,13 @@
}
// copy the extensions
- extensions = new HashMap<String, List<String>>();
+ extensions = new HashMap<>();
for ( String key : original.getExtensions().keySet() )
{
List<String> extensionValues = original.getExtension( key );
- List<String> cloneExtension = new ArrayList<String>();
+ List<String> cloneExtension = new ArrayList<>();
for ( String value : extensionValues )
{
@@ -905,6 +924,7 @@
* Clear the current SchemaObject : remove all the references to other objects,
* and all the Maps.
*/
+ @Override
public void clear()
{
// Clear the extensions
@@ -922,6 +942,9 @@
}
+ /**
+ * Unlock the Schema Object and make it modifiable again.
+ */
public void unlock()
{
locked = false;
@@ -931,6 +954,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void lock()
{
if ( locked )
@@ -947,7 +971,7 @@
h += h * 17 + objectType.getValue();
// The Names, if any
- if ( ( names != null ) && ( names.size() != 0 ) )
+ if ( ( names != null ) && !names.isEmpty() )
{
for ( String name : names )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java
index 05e477d..3d481d4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeType.java
@@ -549,6 +549,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -558,6 +559,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType copy()
{
MutableAttributeType copy = new MutableAttributeType( oid );
@@ -610,6 +612,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean equals( Object o )
{
if ( !super.equals( o ) )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeTypeOptions.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeTypeOptions.java
index 11c13f5..fd28025 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeTypeOptions.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributeTypeOptions.java
@@ -93,7 +93,7 @@
*/
public boolean hasOption()
{
- return ( options != null ) && ( options.size() != 0 );
+ return ( options != null ) && !options.isEmpty();
}
@@ -123,7 +123,7 @@
{
if ( options == null )
{
- options = new HashSet<String>();
+ options = new HashSet<>();
}
options.add( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
@@ -151,6 +151,7 @@
/**
* @see Object#hashCode()
*/
+ @Override
public int hashCode()
{
return attributeType.hashCode();
@@ -160,6 +161,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
// Short circuit
@@ -181,6 +183,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java
index 1a3a8f9..8430253 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AttributesFactory.java
@@ -421,7 +421,7 @@
Attribute attr = null;
// handle the superior objectClasses
- if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size() != 0 )
+ if ( objectClass.getSuperiorOids() != null && !objectClass.getSuperiorOids().isEmpty() )
{
if ( schemaManager != null )
{
@@ -442,7 +442,7 @@
}
// add the must list
- if ( objectClass.getMustAttributeTypeOids() != null && objectClass.getMustAttributeTypeOids().size() != 0 )
+ if ( objectClass.getMustAttributeTypeOids() != null && !objectClass.getMustAttributeTypeOids().isEmpty() )
{
if ( schemaManager != null )
{
@@ -462,7 +462,7 @@
}
// add the may list
- if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size() != 0 )
+ if ( objectClass.getMayAttributeTypeOids() != null && !objectClass.getMayAttributeTypeOids().isEmpty() )
{
if ( schemaManager != null )
{
@@ -518,7 +518,7 @@
private void injectNames( List<String> names, Entry entry, SchemaManager schemaManager ) throws LdapException
{
- if ( ( names == null ) || ( names.size() == 0 ) )
+ if ( ( names == null ) || names.isEmpty() )
{
return;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DescriptionUtils.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DescriptionUtils.java
index 385858c..1ff4967 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DescriptionUtils.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DescriptionUtils.java
@@ -138,7 +138,7 @@
List<String> values = extension.getValue();
- if ( ( values != null ) && ( values.size() != 0 ) )
+ if ( ( values != null ) && !values.isEmpty() )
{
if ( values.size() == 1 )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitContentRule.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitContentRule.java
index 77d6180..9f53f1c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitContentRule.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitContentRule.java
@@ -149,15 +149,15 @@
{
super( SchemaObjectType.DIT_CONTENT_RULE, oid );
- mayAttributeTypeOids = new ArrayList<String>();
- mustAttributeTypeOids = new ArrayList<String>();
- notAttributeTypeOids = new ArrayList<String>();
- auxObjectClassOids = new ArrayList<String>();
+ mayAttributeTypeOids = new ArrayList<>();
+ mustAttributeTypeOids = new ArrayList<>();
+ notAttributeTypeOids = new ArrayList<>();
+ auxObjectClassOids = new ArrayList<>();
- mayAttributeTypes = new ArrayList<AttributeType>();
- mustAttributeTypes = new ArrayList<AttributeType>();
- notAttributeTypes = new ArrayList<AttributeType>();
- auxObjectClasses = new ArrayList<ObjectClass>();
+ mayAttributeTypes = new ArrayList<>();
+ mustAttributeTypes = new ArrayList<>();
+ notAttributeTypes = new ArrayList<>();
+ auxObjectClasses = new ArrayList<>();
}
@@ -566,6 +566,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -575,6 +576,7 @@
/**
* Copy a DitContentRule
*/
+ @Override
public DitContentRule copy()
{
DitContentRule copy = new DitContentRule( oid );
@@ -583,7 +585,7 @@
copy.copy( this );
// copy the AUX ObjectClasses OIDs
- copy.auxObjectClassOids = new ArrayList<String>();
+ copy.auxObjectClassOids = new ArrayList<>();
for ( String oid : auxObjectClassOids )
{
@@ -591,10 +593,10 @@
}
// copy the AUX ObjectClasses ( will be empty )
- copy.auxObjectClasses = new ArrayList<ObjectClass>();
+ copy.auxObjectClasses = new ArrayList<>();
// Clone the MAY AttributeTypes OIDs
- copy.mayAttributeTypeOids = new ArrayList<String>();
+ copy.mayAttributeTypeOids = new ArrayList<>();
for ( String oid : mayAttributeTypeOids )
{
@@ -602,10 +604,10 @@
}
// Clone the MAY AttributeTypes ( will be empty )
- copy.mayAttributeTypes = new ArrayList<AttributeType>();
+ copy.mayAttributeTypes = new ArrayList<>();
// Clone the MUST AttributeTypes OIDs
- copy.mustAttributeTypeOids = new ArrayList<String>();
+ copy.mustAttributeTypeOids = new ArrayList<>();
for ( String oid : mustAttributeTypeOids )
{
@@ -613,10 +615,10 @@
}
// Clone the MUST AttributeTypes ( will be empty )
- copy.mustAttributeTypes = new ArrayList<AttributeType>();
+ copy.mustAttributeTypes = new ArrayList<>();
// Clone the NOT AttributeTypes OIDs
- copy.notAttributeTypeOids = new ArrayList<String>();
+ copy.notAttributeTypeOids = new ArrayList<>();
for ( String oid : notAttributeTypeOids )
{
@@ -624,7 +626,7 @@
}
// Clone the NOT AttributeTypes ( will be empty )
- copy.notAttributeTypes = new ArrayList<AttributeType>();
+ copy.notAttributeTypes = new ArrayList<>();
return copy;
}
@@ -657,6 +659,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitStructureRule.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitStructureRule.java
index 6cdc1b8..a34c06e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitStructureRule.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/DitStructureRule.java
@@ -103,7 +103,7 @@
super( SchemaObjectType.DIT_STRUCTURE_RULE, null );
this.ruleId = ruleId;
form = null;
- superRules = new ArrayList<Integer>();
+ superRules = new ArrayList<>();
}
@@ -233,6 +233,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule copy()
{
DitStructureRule copy = new DitStructureRule( ruleId );
@@ -241,7 +242,7 @@
copy.copy( this );
// Copy the Superiors rules
- copy.superRules = new ArrayList<Integer>();
+ copy.superRules = new ArrayList<>();
// Copy the form
copy.form = form;
@@ -282,6 +283,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapComparator.java
index 58a389d..49ea94a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapComparator.java
@@ -28,6 +28,8 @@
* An class used for Comparator. It inherits from the general AbstractAdsSchemaObject class. It
* also implements the Comparator interface
*
+ * @param <T> The comparator type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class LdapComparator<T> extends LoadableSchemaObject implements Comparator<T>, Serializable
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
index a0e1929..e44e4eb 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
@@ -138,7 +138,7 @@
{
List<String> values = getExtension( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT );
- if ( ( values == null ) || ( values.size() == 0 ) )
+ if ( ( values == null ) || values.isEmpty() )
{
// Default to String if the flag is not set
return true;
@@ -148,7 +148,7 @@
String value = values.get( 0 );
hasHumanReadableFlag = true;
- if ( value.equalsIgnoreCase( "FALSE" ) )
+ if ( "FALSE".equalsIgnoreCase( value ) )
{
isHumanReadable = true;
return true;
@@ -243,6 +243,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax copy()
{
LdapSyntax copy = new LdapSyntax( oid );
@@ -307,6 +308,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LoadableSchemaObject.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LoadableSchemaObject.java
index c60e5ea..4d1a3a6 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LoadableSchemaObject.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LoadableSchemaObject.java
@@ -131,6 +131,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LoadableSchemaObject copy()
{
return null;
@@ -156,7 +157,6 @@
LoadableSchemaObject that = ( LoadableSchemaObject ) o;
// Check the byteCode
- // TODO
// Check the FQCN
if ( fqcn == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRule.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRule.java
index 2126d63..ea05286 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRule.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRule.java
@@ -149,6 +149,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -158,6 +159,7 @@
/**
* Copy an MatchingRule
*/
+ @Override
public MatchingRule copy()
{
MatchingRule copy = new MutableMatchingRule( oid );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleEnum.java
index e80feff..066d4d4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleEnum.java
@@ -53,7 +53,7 @@
* @param value
* the integer value of the enumeration.
*/
- private MatchingRuleEnum( int value )
+ MatchingRuleEnum( int value )
{
this.value = value;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleUse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleUse.java
index c6a8e28..e552950 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleUse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MatchingRuleUse.java
@@ -102,8 +102,8 @@
{
super( SchemaObjectType.MATCHING_RULE_USE, oid );
- applicableAttributeOids = new ArrayList<String>();
- applicableAttributes = new ArrayList<AttributeType>();
+ applicableAttributeOids = new ArrayList<>();
+ applicableAttributes = new ArrayList<>();
}
@@ -213,6 +213,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -222,6 +223,7 @@
/**
* Copy an MatchingRuleUse
*/
+ @Override
public MatchingRuleUse copy()
{
MatchingRuleUse copy = new MatchingRuleUse( oid );
@@ -230,7 +232,7 @@
copy.copy( this );
// Clone the APPLY AttributeTypes
- copy.applicableAttributeOids = new ArrayList<String>();
+ copy.applicableAttributeOids = new ArrayList<>();
// Copy the APPLIES oid list
for ( String oid : applicableAttributeOids )
@@ -239,7 +241,7 @@
}
// Copy the APPLIES list (will be empty)
- copy.applicableAttributes = new ArrayList<AttributeType>();
+ copy.applicableAttributes = new ArrayList<>();
return copy;
}
@@ -272,6 +274,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java
index 59ceb91..24d23d5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java
@@ -588,6 +588,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableMatchingRule.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableMatchingRule.java
index b85fecb..438cc70 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableMatchingRule.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableMatchingRule.java
@@ -220,6 +220,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableObjectClass.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableObjectClass.java
index 3c5820d..1dd410a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableObjectClass.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableObjectClass.java
@@ -446,6 +446,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NameForm.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NameForm.java
index 8cb5122..f84d1c1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NameForm.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NameForm.java
@@ -123,11 +123,11 @@
{
super( SchemaObjectType.NAME_FORM, oid );
- mustAttributeTypeOids = new ArrayList<String>();
- mayAttributeTypeOids = new ArrayList<String>();
+ mustAttributeTypeOids = new ArrayList<>();
+ mayAttributeTypeOids = new ArrayList<>();
- mustAttributeTypes = new ArrayList<AttributeType>();
- mayAttributeTypes = new ArrayList<AttributeType>();
+ mustAttributeTypes = new ArrayList<>();
+ mayAttributeTypes = new ArrayList<>();
}
@@ -419,6 +419,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -428,6 +429,7 @@
/**
* Copy a NameForm
*/
+ @Override
public NameForm copy()
{
NameForm copy = new NameForm( oid );
@@ -436,7 +438,7 @@
copy.copy( this );
// Copy the MAY AttributeTypes OIDs
- copy.mayAttributeTypeOids = new ArrayList<String>();
+ copy.mayAttributeTypeOids = new ArrayList<>();
for ( String oid : mayAttributeTypeOids )
{
@@ -444,10 +446,10 @@
}
// Copy the MAY AttributeTypes (will be empty)
- copy.mayAttributeTypes = new ArrayList<AttributeType>();
+ copy.mayAttributeTypes = new ArrayList<>();
// Copy the MUST AttributeTypes OIDs
- copy.mustAttributeTypeOids = new ArrayList<String>();
+ copy.mustAttributeTypeOids = new ArrayList<>();
for ( String oid : mustAttributeTypeOids )
{
@@ -455,7 +457,7 @@
}
// Copy the MUST AttributeTypes ( will be empty )
- copy.mustAttributeTypes = new ArrayList<AttributeType>();
+ copy.mustAttributeTypes = new ArrayList<>();
// Copy the Structural ObjectClass OID
copy.structuralObjectClassOid = structuralObjectClassOid;
@@ -494,6 +496,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the common elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NormalizerMappingResolver.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NormalizerMappingResolver.java
index 76aafab..536f568 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NormalizerMappingResolver.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/NormalizerMappingResolver.java
@@ -38,9 +38,17 @@
* these server side objects that generate these mappings. Instead when a
* resolver is used we can create mock or almost right implementations.
*
+ * @param <E> The normalizer type
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface NormalizerMappingResolver<E extends Normalizer>
{
+ /**
+ * Gets the Map containing the normalizers associated to an OID or name
+ *
+ * @return The normalizer Map
+ * @throws Exception If not found
+ */
Map<String, E> getNormalizerMapping() throws Exception;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClass.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClass.java
index 5415dcd..d8c064d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClass.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClass.java
@@ -101,13 +101,13 @@
{
super( SchemaObjectType.OBJECT_CLASS, oid );
- mayAttributeTypeOids = new ArrayList<String>();
- mustAttributeTypeOids = new ArrayList<String>();
- superiorOids = new ArrayList<String>();
+ mayAttributeTypeOids = new ArrayList<>();
+ mustAttributeTypeOids = new ArrayList<>();
+ superiorOids = new ArrayList<>();
- mayAttributeTypes = new ArrayList<AttributeType>();
- mustAttributeTypes = new ArrayList<AttributeType>();
- superiors = new ArrayList<ObjectClass>();
+ mayAttributeTypes = new ArrayList<>();
+ mustAttributeTypes = new ArrayList<>();
+ superiors = new ArrayList<>();
objectClassType = ObjectClassTypeEnum.STRUCTURAL;
}
@@ -217,6 +217,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this );
@@ -226,6 +227,7 @@
/**
* Copy an ObjectClass
*/
+ @Override
public ObjectClass copy()
{
ObjectClass copy = new ObjectClass( oid );
@@ -237,7 +239,7 @@
copy.objectClassType = objectClassType;
// Copy the Superiors ObjectClasses OIDs
- copy.superiorOids = new ArrayList<String>();
+ copy.superiorOids = new ArrayList<>();
for ( String oid : superiorOids )
{
@@ -245,10 +247,10 @@
}
// Copy the Superiors ObjectClasses ( will be empty )
- copy.superiors = new ArrayList<ObjectClass>();
+ copy.superiors = new ArrayList<>();
// Copy the MAY AttributeTypes OIDs
- copy.mayAttributeTypeOids = new ArrayList<String>();
+ copy.mayAttributeTypeOids = new ArrayList<>();
for ( String oid : mayAttributeTypeOids )
{
@@ -256,10 +258,10 @@
}
// Copy the MAY AttributeTypes ( will be empty )
- copy.mayAttributeTypes = new ArrayList<AttributeType>();
+ copy.mayAttributeTypes = new ArrayList<>();
// Copy the MUST AttributeTypes OIDs
- copy.mustAttributeTypeOids = new ArrayList<String>();
+ copy.mustAttributeTypeOids = new ArrayList<>();
for ( String oid : mustAttributeTypeOids )
{
@@ -267,12 +269,11 @@
}
// Copy the MUST AttributeTypes ( will be empty )
- copy.mustAttributeTypes = new ArrayList<AttributeType>();
+ copy.mustAttributeTypes = new ArrayList<>();
return copy;
}
-
/**
* @see Object#equals(Object)
*/
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClassTypeEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClassTypeEnum.java
index d1befed..aa1f07d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClassTypeEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/ObjectClassTypeEnum.java
@@ -68,7 +68,7 @@
* @param value
* the integer value of the enumeration.
*/
- private ObjectClassTypeEnum( int value )
+ ObjectClassTypeEnum( int value )
{
this.value = value;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java
index 7027645..d36f584 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java
@@ -158,15 +158,34 @@
*/
public enum StringType
{
+ /** Not a String */
NOT_STRING,
+
+ /** A numeric String */
NUMERIC_STRING,
+
+ /** Case sensitive String */
CASE_EXACT,
+
+ /** IA5 case sensitive String */
CASE_EXACT_IA5,
+
+ /** IA5 case insensitive String */
CASE_IGNORE_IA5,
+
+ /** Case insensitive String list */
CASE_IGNORE_LIST,
+
+ /** Case insensitive String */
CASE_IGNORE,
+
+ /** Directory String */
DIRECTORY_STRING,
+
+ /** Telephone number String */
TELEPHONE_NUMBER,
+
+ /** A word */
WORD
}
@@ -4739,6 +4758,7 @@
case 0xFE63: // SMALL HYPHEN-MINUS
case 0xFF0D: // FULLWIDTH HYPHEN-MINUS
soh = c;
+ isSpaceOrHyphen = true;
break;
default:
@@ -4747,6 +4767,10 @@
array[pos++] = soh;
isSpaceOrHyphen = false;
}
+ else
+ {
+ isSpaceOrHyphen = false;
+ }
array[pos++] = c;
break;
@@ -4830,7 +4854,7 @@
// TODO : we have to find a way to prevent this waste of space.
char[] target = new char[str.length() * 3 + 2];
- int pos = 0;
+ int pos;
char lowerCase = ( char ) ( caseSensitive ? 0x00 : 0x20 );
// First pass to map the chars. This will copy the array into the target
@@ -4882,7 +4906,7 @@
}
// Now remove the spaces at the end
- int i = 0;
+ int i;
for ( i = limit - 1; i >= start; i-- )
{
@@ -4993,10 +5017,9 @@
{
target[pos++] = '\\';
}
+
// Ends by unescaping the escaped elements
- String result = unescape( target, pos );
-
- return result;
+ return unescape( target, pos );
}
@@ -5022,7 +5045,7 @@
char[] array = str.toCharArray();
- int pos = 0;
+ int pos;
char lowerCase = ( char ) ( caseSensitive ? 0x00 : 0x20 );
// First pass to map the chars
@@ -5067,7 +5090,7 @@
}
// Now remove the spaces at the end
- int i = 0;
+ int i;
for ( i = limit - 1; i >= start; i-- )
{
@@ -5121,11 +5144,7 @@
checkProhibited( c );
- /*if ( isCombiningMark( c ) )
- {
- throw new InvalidCharacterException( c );
- }
- else*/ if ( c == ' ' )
+ if ( c == ' ' )
{
if ( escapeSeen )
{
@@ -5184,9 +5203,7 @@
}
// Ends by unescaping the escaped elements
- String result = unescape( array, pos );
-
- return result;
+ return unescape( array, pos );
}
@@ -5249,7 +5266,8 @@
case '7' :
case '8' :
case '9' :
- bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - '0' ) << 4 ) + toByte( array[i + 1] ) );
+ bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - '0' ) << 4 )
+ + ( toByte( array[i + 1] ) & 0xff ) );
i++;
break;
@@ -5259,7 +5277,8 @@
case 'd' :
case 'e' :
case 'f' :
- bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'a' + 10 ) << 4 ) + toByte( array[i + 1] ) );
+ bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'a' + 10 ) << 4 )
+ + ( toByte( array[i + 1] ) & 0xFF ) );
i++;
break;
@@ -5269,7 +5288,8 @@
case 'D' :
case 'E' :
case 'F' :
- bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'A' + 10 ) << 4 ) + toByte( array[i + 1] ) );
+ bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'A' + 10 ) << 4 )
+ + ( toByte( array[i + 1] ) & 0xff ) );
i++;
break;
@@ -5308,9 +5328,7 @@
bytes[pos++] = '\\';
}
- String result = Strings.utf8ToString( bytes, pos );
-
- return result;
+ return Strings.utf8ToString( bytes, pos );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
index 0a775e9..e38e3b0 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
@@ -306,12 +306,14 @@
/**
* {@inheritDoc}
*/
+ @Override
int hashCode();
/**
* {@inheritDoc}
*/
+ @Override
boolean equals( Object o1 );
@@ -341,7 +343,6 @@
/**
* Transform the SchemaObject to an immutable object
- * TODO locked.
*
*/
void lock();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectRenderer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectRenderer.java
index c1fe267..7da0a3e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectRenderer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectRenderer.java
@@ -65,7 +65,7 @@
final boolean printSchemaName;
- private Style( boolean startWithSchemaType, boolean prettyPrint, boolean printSchemaName )
+ Style( boolean startWithSchemaType, boolean prettyPrint, boolean printSchemaName )
{
this.startWithSchemaType = startWithSchemaType;
this.prettyPrint = prettyPrint;
@@ -452,7 +452,7 @@
List<String> applies = mru.getApplicableAttributeOids();
- if ( ( applies != null ) && ( applies.size() > 0 ) )
+ if ( ( applies != null ) && !applies.isEmpty() )
{
prettyPrintIndent( buf );
buf.append( "APPLIES " );
@@ -592,7 +592,7 @@
{
List<String> names = so.getNames();
- if ( ( names != null ) && ( names.size() > 0 ) )
+ if ( ( names != null ) && !names.isEmpty() )
{
buf.append( " NAME " );
renderQDescrs( buf, names );
@@ -662,7 +662,7 @@
*/
private StringBuilder renderQDescrs( StringBuilder buf, List<String> qdescrs )
{
- if ( ( qdescrs == null ) || ( qdescrs.size() == 0 ) )
+ if ( ( qdescrs == null ) || qdescrs.isEmpty() )
{
return buf;
}
@@ -689,7 +689,7 @@
private void renderOids( StringBuilder buf, String prefix, List<String> oids )
{
- if ( ( oids != null ) && ( oids.size() > 0 ) )
+ if ( ( oids != null ) && !oids.isEmpty() )
{
prettyPrintIndent( buf );
buf.append( prefix ).append( ' ' );
@@ -778,7 +778,7 @@
private StringBuilder renderRuleIds( StringBuilder buf, List<Integer> ruleIds )
{
- if ( ( ruleIds != null ) && ( ruleIds.size() > 0 ) )
+ if ( ( ruleIds != null ) && !ruleIds.isEmpty() )
{
prettyPrintIndent( buf );
buf.append( "SUP " );
@@ -832,14 +832,12 @@
private void renderClose( StringBuilder buf )
{
- if ( style.prettyPrint )
+ if ( ( style.prettyPrint ) && ( buf.charAt( buf.length() - 1 ) == '\n' ) )
{
- if ( buf.charAt( buf.length() - 1 ) == '\n' )
- {
- buf.deleteCharAt( buf.length() - 1 );
- buf.append( " " );
- }
+ buf.deleteCharAt( buf.length() - 1 );
+ buf.append( " " );
}
+
buf.append( ")" );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectSorter.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectSorter.java
index 5fa3efd..bab531b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectSorter.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectSorter.java
@@ -52,7 +52,7 @@
*/
public static Iterable<AttributeType> hierarchicalOrdered( List<AttributeType> attributeTypes )
{
- return new SchemaObjectIterable<AttributeType>( attributeTypes, new ReferenceCallback<AttributeType>()
+ return new SchemaObjectIterable<>( attributeTypes, new ReferenceCallback<AttributeType>()
{
@Override
public Collection<String> getSuperiorOids( AttributeType at )
@@ -71,7 +71,7 @@
*/
public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses )
{
- return new SchemaObjectIterable<ObjectClass>( objectClasses, new ReferenceCallback<ObjectClass>()
+ return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>()
{
@Override
public Collection<String> getSuperiorOids( ObjectClass oc )
@@ -105,7 +105,7 @@
@Override
public Iterator<T> iterator()
{
- return new SchemaObjectIterator<T>( schemaObjects, callback );
+ return new SchemaObjectIterator<>( schemaObjects, callback );
}
}
@@ -127,8 +127,8 @@
this.schemaObjects = schemaObjects;
this.callback = callback;
- this.oid2numericOid = new HashMap<String, String>();
- this.numericOid2schemaObject = new TreeMap<String, T>();
+ this.oid2numericOid = new HashMap<>();
+ this.numericOid2schemaObject = new TreeMap<>();
this.loopCount = 0;
for ( T schemaObject : schemaObjects )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectType.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectType.java
index aa1b09a..ca2eefd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectType.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectType.java
@@ -30,16 +30,37 @@
*/
public enum SchemaObjectType
{
+ /** An AttributeType */
ATTRIBUTE_TYPE(0),
+
+ /** A Comparator */
COMPARATOR(1),
+
+ /** */
DIT_CONTENT_RULE(2),
+
+ /** */
DIT_STRUCTURE_RULE(3),
+
+ /** A Syntax */
LDAP_SYNTAX(4),
+
+ /** A MatchingRule */
MATCHING_RULE(5),
+
+ /** A MatchingRuleUse */
MATCHING_RULE_USE(6),
+
+ /** A NameForm */
NAME_FORM(7),
+
+ /** A Normalizer */
NORMALIZER(8),
+
+ /** An ObjectClass */
OBJECT_CLASS(9),
+
+ /** A SyntaxChecker */
SYNTAX_CHECKER(10);
/** The inner value*/
@@ -49,7 +70,7 @@
/**
* A private constructor to associated a number to the type
*/
- private SchemaObjectType( int value )
+ SchemaObjectType( int value )
{
this.value = value;
}
@@ -71,7 +92,7 @@
*/
public String getRdn()
{
- String schemaObjectPath = null;
+ String schemaObjectPath;
switch ( this )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectWrapper.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectWrapper.java
index 6b0443f..e40cec8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectWrapper.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObjectWrapper.java
@@ -49,6 +49,7 @@
* Compute the hash code for this wrapper. We only use the object type
* and its oid.
*/
+ @Override
public int hashCode()
{
int h = 37;
@@ -66,6 +67,7 @@
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object o )
{
if ( o == this )
@@ -90,7 +92,7 @@
// If both OID are null, instances are equals
if ( that.getOid() == null )
{
- return ( current.getOid() == null );
+ return current.getOid() == null;
}
// The that'oid will never be null, we don't really care if current.oid is null here.
@@ -110,6 +112,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "<" + schemaObject.getObjectType() + "," + schemaObject.getOid() + ">";
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
index d26ba96..2856861 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
@@ -140,9 +140,9 @@
* the quoted description strings to render
* @return the same string buffer that was given for call chaining
*/
- public static StringBuffer render( StringBuffer buf, List<String> qdescrs )
+ public static StringBuilder render( StringBuilder buf, List<String> qdescrs )
{
- if ( ( qdescrs == null ) || ( qdescrs.size() == 0 ) )
+ if ( ( qdescrs == null ) || qdescrs.isEmpty() )
{
return buf;
}
@@ -176,9 +176,9 @@
* @param qdescrs the quoted description strings to render
* @return the string buffer the qdescrs are rendered into
*/
- /* No qualifier */static StringBuffer renderQDescrs( StringBuffer buf, List<String> qdescrs )
+ /* No qualifier */static StringBuilder renderQDescrs( StringBuilder buf, List<String> qdescrs )
{
- if ( ( qdescrs == null ) || ( qdescrs.size() == 0 ) )
+ if ( ( qdescrs == null ) || qdescrs.isEmpty() )
{
return buf;
}
@@ -209,7 +209,7 @@
* @param qdescrs the quoted description strings to render
* @return the string buffer the qdescrs are rendered into
*/
- private static StringBuffer renderQDString( StringBuffer buf, String qdString )
+ private static StringBuilder renderQDString( StringBuilder buf, String qdString )
{
buf.append( '\'' );
@@ -249,9 +249,9 @@
* the objectClasses to list
* @return a buffer which contains the rendered list
*/
- public static StringBuffer render( ObjectClass[] ocs )
+ public static StringBuilder render( ObjectClass[] ocs )
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
return render( buf, ocs );
}
@@ -267,7 +267,7 @@
* the objectClasses to list
* @return a buffer which contains the rendered list
*/
- public static StringBuffer render( StringBuffer buf, ObjectClass[] ocs )
+ public static StringBuilder render( StringBuilder buf, ObjectClass[] ocs )
{
if ( ocs == null || ocs.length == 0 )
{
@@ -312,9 +312,10 @@
* the attributeTypes to list
* @return a buffer which contains the rendered list
*/
- public static StringBuffer render( AttributeType[] ats )
+ public static StringBuilder render( AttributeType[] ats )
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
+
return render( buf, ats );
}
@@ -329,7 +330,7 @@
* the attributeTypes to list
* @return a buffer which contains the rendered list
*/
- public static StringBuffer render( StringBuffer buf, AttributeType[] ats )
+ public static StringBuilder render( StringBuilder buf, AttributeType[] ats )
{
if ( ats == null || ats.length == 0 )
{
@@ -365,14 +366,14 @@
// ------------------------------------------------------------------------
/**
- * Renders the schema extensions into a new StringBuffer.
+ * Renders the schema extensions into a new StringBuilder.
*
* @param extensions the schema extensions map with key and values
- * @return a StringBuffer with the extensions component of a syntax description
+ * @return a StringBuilder with the extensions component of a syntax description
*/
- public static StringBuffer render( Map<String, List<String>> extensions )
+ public static StringBuilder render( Map<String, List<String>> extensions )
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
if ( extensions.isEmpty() )
{
@@ -427,7 +428,7 @@
*/
public static String render( LoadableSchemaObject description )
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append( "( " ).append( description.getOid() );
if ( description.getDescription() != null )
@@ -455,7 +456,7 @@
{
List<String> values = desc.getExtension( MetaSchemaConstants.X_SCHEMA_AT );
- if ( values == null || values.size() == 0 )
+ if ( values == null || values.isEmpty() )
{
return MetaSchemaConstants.SCHEMA_OTHER;
}
@@ -510,7 +511,7 @@
if ( optionsPos != -1 )
{
- Set<String> options = new HashSet<String>();
+ Set<String> options = new HashSet<>();
String[] res = attributeId.substring( optionsPos + 1 ).split( ";" );
@@ -595,7 +596,7 @@
}
// Check the first char which must be ALPHA or DIGIT
- boolean descr = false;
+ boolean descr;
boolean zero = false;
boolean dot = false;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SyntaxChecker.java
index 76023ea..5e6a241 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SyntaxChecker.java
@@ -19,6 +19,9 @@
*/
package org.apache.directory.api.ldap.model.schema;
+import org.apache.directory.api.i18n.I18n;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used to validate values of a particular syntax. This interface does not
@@ -31,6 +34,42 @@
{
/** The mandatory serialVersionUID */
public static final long serialVersionUID = 1L;
+
+ /** A logger for this class */
+ protected static final Logger LOG = LoggerFactory.getLogger( SyntaxChecker.class );
+
+ /**
+ * A static Builder for this class
+ */
+ public abstract static class SCBuilder<SC>
+ {
+ /** The SyntaxChecker OID */
+ protected String oid;
+
+ /**
+ * The Builder constructor
+ */
+ protected SCBuilder( String oid )
+ {
+ this.oid = oid;
+ }
+
+
+ /**
+ * Set the SyntaxChecker's OID
+ *
+ * @param oid The OID
+ * @return The Builder's Instance
+ */
+ public SCBuilder<SC> setOid( String oid )
+ {
+ this.oid = oid;
+
+ return this;
+ }
+
+ public abstract SC build();
+ }
/**
@@ -59,7 +98,15 @@
* @param value the value of some attribute with the syntax
* @return true if the value is in the valid syntax, false otherwise
*/
- public abstract boolean isValidSyntax( Object value );
+ public boolean isValidSyntax( Object value )
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
+ return true;
+ }
/**
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/UsageEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/UsageEnum.java
index d3b2f18..6401db4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/UsageEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/UsageEnum.java
@@ -56,7 +56,7 @@
*
* @param value the integer value of the enumeration.
*/
- private UsageEnum( int value )
+ UsageEnum( int value )
{
this.value = value;
}
@@ -82,9 +82,7 @@
{
try
{
- UsageEnum result = valueOf( usage );
-
- return result;
+ return valueOf( usage );
}
catch ( IllegalArgumentException iae )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BitStringComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BitStringComparator.java
index 1fcdb30..0755d88 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BitStringComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BitStringComparator.java
@@ -71,7 +71,7 @@
// have been caught by the previous test
if ( ( bs1 == null ) || ( bs2 == null ) )
{
- return ( bs1 == null ? -1 : 1 );
+ return bs1 == null ? -1 : 1;
}
// We have to get rid of 0 from left of each BitString
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BooleanComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BooleanComparator.java
index c243c32..7d1b61d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BooleanComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/BooleanComparator.java
@@ -71,7 +71,7 @@
// have been catched by the previous test
if ( ( b1 == null ) || ( b2 == null ) )
{
- return ( b1 == null ? -1 : 1 );
+ return b1 == null ? -1 : 1;
}
// The boolean should have been stored as 'TRUE' or 'FALSE'
@@ -79,14 +79,14 @@
// with normalized booleans, so no need to upper case them.
// We don't need to check the assertion value, because we
// are dealing with booleans.
- boolean boolean1 = Boolean.valueOf( b1 );
- boolean boolean2 = Boolean.valueOf( b2 );
+ boolean boolean1 = Boolean.parseBoolean( b1 );
+ boolean boolean2 = Boolean.parseBoolean( b2 );
if ( boolean1 == boolean2 )
{
return 0;
}
- return ( boolean1 ? 1 : -1 );
+ return boolean1 ? 1 : -1;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnComparator.java
index 1202456..a5d153b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnComparator.java
@@ -61,6 +61,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( Object csnObj1, Object csnObj2 )
{
LOG.debug( "comparing CSN objects '{}' with '{}'", csnObj1, csnObj2 );
@@ -75,7 +76,7 @@
// -------------------------------------------------------------------
if ( csnObj1 == null )
{
- return ( csnObj2 == null ) ? 0 : -1;
+ return -1;
}
if ( csnObj2 == null )
@@ -83,8 +84,8 @@
return 1;
}
- String csnStr1 = null;
- String csnStr2 = null;
+ String csnStr1;
+ String csnStr2;
if ( csnObj1 instanceof StringValue )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnSidComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnSidComparator.java
index f5da888..d1d960c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnSidComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/CsnSidComparator.java
@@ -74,7 +74,7 @@
}
int sid1 = 0;
- int sid2 = 0;
+ int sid2;
try
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java
index bd0c4d8..f7b2d31 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimCachingNormalizingComparator.java
@@ -25,7 +25,8 @@
/**
- * TODO DeepTrimCachingNormalizingComparator.
+ * A comparator that compare two Strings after having trimmed them on left and right,
+ * and replaced any contiguous spaces in the middle by 1 single space. We also keep a cache.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java
index dc91bcf..d3e74c9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DeepTrimToLowerCachingNormalizingComparator.java
@@ -25,7 +25,9 @@
/**
- * TODO DeepTrimCachingNormalizingComparator.
+ * A comparator that compare two Strings after having trimmed them on left and right,
+ * and replaced any contiguous spaces in the middle by 1 single space. The Strings are compared
+ * case insensitive. We also keep a cache
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
index 5ca7609..29c30b4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( Object obj0, Object obj1 )
{
Dn dn0 = null;
@@ -95,13 +96,13 @@
private Dn getDn( Object obj ) throws LdapInvalidDnException
{
- Dn dn = null;
+ Dn dn;
if ( obj instanceof Dn )
{
dn = ( Dn ) obj;
- dn = ( dn.isSchemaAware() ? dn : dn.apply( schemaManager ) );
+ dn = dn.isSchemaAware() ? dn : dn.apply( schemaManager );
}
else if ( obj instanceof String )
{
@@ -109,7 +110,7 @@
}
else
{
- throw new IllegalStateException( I18n.err( I18n.ERR_04218, ( obj == null ? null : obj.getClass() ) ) );
+ throw new IllegalStateException( I18n.err( I18n.ERR_04218, obj == null ? null : obj.getClass() ) );
}
return dn;
@@ -119,6 +120,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/GeneralizedTimeComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/GeneralizedTimeComparator.java
index 9fd96c9..b2ddaa1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/GeneralizedTimeComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/GeneralizedTimeComparator.java
@@ -77,7 +77,7 @@
// have been caught by the previous test
if ( ( backendValue == null ) || ( assertValue == null ) )
{
- return ( backendValue == null ? -1 : 1 );
+ return backendValue == null ? -1 : 1;
}
// Both objects must be stored as String for generalized tim.
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/IntegerComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/IntegerComparator.java
index 6765d7a..4904925 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/IntegerComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/IntegerComparator.java
@@ -60,6 +60,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( Object v1, Object v2 )
{
if ( v1 instanceof String )
@@ -93,7 +94,7 @@
// have been caught by the previous test
if ( ( backendValue == null ) || ( assertValue == null ) )
{
- return ( backendValue == null ? -1 : 1 );
+ return backendValue == null ? -1 : 1;
}
return backendValue.compareTo( assertValue );
@@ -120,7 +121,7 @@
// have been caught by the previous test
if ( ( backendValue == null ) || ( assertValue == null ) )
{
- return ( backendValue == null ? -1 : 1 );
+ return backendValue == null ? -1 : 1;
}
// Both objects must be stored as String for numeric.
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/NumericStringComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/NumericStringComparator.java
index f4ca21b..b102697 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/NumericStringComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/NumericStringComparator.java
@@ -75,7 +75,7 @@
// have been caught by the previous test
if ( ( backendValue == null ) || ( assertValue == null ) )
{
- return ( backendValue == null ? -1 : 1 );
+ return backendValue == null ? -1 : 1;
}
// Both objects must be stored as String for numeric.
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectClassTypeComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectClassTypeComparator.java
index e5cb56f..a4a0d7a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectClassTypeComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectClassTypeComparator.java
@@ -28,6 +28,8 @@
* A comparator that compares the objectClass type with values: AUXILIARY,
* ABSTRACT, and STRUCTURAL.
*
+ * @param <T> The type of object to compare
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ObjectClassTypeComparator<T> extends LdapComparator<T>
@@ -51,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( T o1, T o2 )
{
String s1 = getString( o1 );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectIdentifierComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectIdentifierComparator.java
index 8ec67a0..2ee6409 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectIdentifierComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/ObjectIdentifierComparator.java
@@ -54,6 +54,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( Object o1, Object o2 )
{
LOG.debug( "comparing ObjectIdentifier objects '{}' with '{}'", o1, o2 );
@@ -78,11 +79,6 @@
if ( !( o1 instanceof String && o2 instanceof String ) )
{
// Both objects must be strings...
- if ( o1.equals( o2 ) )
- {
- return 0;
- }
-
return -1;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/SerializableComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/SerializableComparator.java
index d679a53..6993bc8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/SerializableComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/SerializableComparator.java
@@ -33,6 +33,8 @@
* A serializable wrapper around a Comparator which uses delayed initialization
* of the underlying wrapped comparator which is JIT resolved from a static
* global registry.
+ *
+ * @param <E> The type of object to compare
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -71,6 +73,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public int compare( E o1, E o2 )
{
if ( wrapped == null )
@@ -93,6 +96,7 @@
* @param schemaManager the schemaManager to set
*/
@SuppressWarnings("unchecked")
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
if ( wrapped == null )
@@ -106,7 +110,7 @@
{
// Not found : get the default comparator
wrapped = ( Comparator<E> )
- new ComparableComparator<Comparable<E>>( matchingRuleOid );
+ new ComparableComparator<>( matchingRuleOid );
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/StringComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/StringComparator.java
index a601326..358fbe3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/StringComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/StringComparator.java
@@ -70,7 +70,7 @@
// -------------------------------------------------------------------
if ( s1 == null )
{
- return ( s2 == null ) ? 0 : -1;
+ return -1;
}
if ( s2 == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/TelephoneNumberComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/TelephoneNumberComparator.java
index bf7b844..951a2f7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/TelephoneNumberComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/TelephoneNumberComparator.java
@@ -102,6 +102,6 @@
String strippedTelephoneNumber1 = strip( telephoneNumber1 );
String strippedTelephoneNumber2 = strip( telephoneNumber2 );
- return ( strippedTelephoneNumber1.compareToIgnoreCase( strippedTelephoneNumber2 ) );
+ return strippedTelephoneNumber1.compareToIgnoreCase( strippedTelephoneNumber2 );
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UniqueMemberComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UniqueMemberComparator.java
index 27742ab..c6ad312 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UniqueMemberComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UniqueMemberComparator.java
@@ -103,8 +103,8 @@
return 1;
}
- Dn dn1 = null;
- Dn dn2 = null;
+ Dn dn1;
+ Dn dn2;
// This is an UID if the '#' is immediatly
// followed by a BitString, except if the '#' is
@@ -161,6 +161,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
@@ -176,13 +177,13 @@
*/
public Dn getDn( Object obj ) throws LdapInvalidDnException
{
- Dn dn = null;
+ Dn dn;
if ( obj instanceof Dn )
{
dn = ( Dn ) obj;
- dn = ( dn.isSchemaAware() ? dn : dn.apply( schemaManager ) );
+ dn = dn.isSchemaAware() ? dn : dn.apply( schemaManager );
}
else if ( obj instanceof String )
{
@@ -190,7 +191,7 @@
}
else
{
- throw new IllegalStateException( I18n.err( I18n.ERR_04218, ( obj == null ? null : obj.getClass() ) ) );
+ throw new IllegalStateException( I18n.err( I18n.ERR_04218, obj == null ? null : obj.getClass() ) );
}
return dn;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UuidComparator.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UuidComparator.java
index bf316bd..8115734 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UuidComparator.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/UuidComparator.java
@@ -40,6 +40,7 @@
private static final Logger LOG = LoggerFactory.getLogger( UuidComparator.class );
private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+ /** A static instance of the UuidComparator */
public static final UuidComparator INSTANCE = new UuidComparator( "1.3.6.1.1.16.4" );
@@ -58,6 +59,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compare( String uuid1, String uuid2 )
{
if ( IS_DEBUG )
@@ -83,7 +85,12 @@
/**
- * {@inheritDoc}
+ * Compare two UUID.
+ *
+ * @param uuid1 The first UUID
+ * @param uuid2 he second UUID
+ * @return -1 if the first UUID is lower than the second UUID, 1 if it's higher, 0
+ * if they are equal
*/
public int compare( UUID uuid1, UUID uuid2 )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/BooleanNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/BooleanNormalizer.java
index 0ae1c9e..35b27bc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/BooleanNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/BooleanNormalizer.java
@@ -49,6 +49,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapInvalidDnException
{
if ( value == null )
@@ -65,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapInvalidDnException
{
if ( value == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimNormalizer.java
index 8aa6386..201a947 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimNormalizer.java
@@ -32,6 +32,9 @@
@SuppressWarnings("serial")
public class CachingDeepTrimNormalizer extends CachingNormalizer
{
+ /**
+ * Creates a new CachingDeepTrimNormalizer instance
+ */
public CachingDeepTrimNormalizer()
{
super( new DeepTrimNormalizer() );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimToLowerNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
index 1fefdf7..2b162e1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
@@ -32,6 +32,9 @@
@SuppressWarnings("serial")
public class CachingDeepTrimToLowerNormalizer extends CachingNormalizer
{
+ /**
+ * Creates a new CachingDeepTrimToLowerNormalizer instance
+ */
public CachingDeepTrimToLowerNormalizer()
{
super( new DeepTrimToLowerNormalizer() );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDnNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDnNormalizer.java
index 96c7887..cb73eb9 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDnNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingDnNormalizer.java
@@ -35,6 +35,9 @@
@SuppressWarnings("serial")
public class CachingDnNormalizer extends CachingNormalizer
{
+ /**
+ * Creates a new CachingDnNormalizer instance
+ */
public CachingDnNormalizer()
{
super( new DnNormalizer() );
@@ -44,6 +47,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
super.normalizer.setSchemaManager( schemaManager );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingNormalizer.java
index a542427..082de00 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/CachingNormalizer.java
@@ -98,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
if ( value == null )
@@ -105,15 +106,14 @@
return null;
}
- Value<?> normalized = normalizer.normalize( value );
-
- return normalized;
+ return normalizer.normalize( value );
}
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
if ( value == null )
@@ -121,9 +121,7 @@
return null;
}
- String normalized = normalizer.normalize( value );
-
- return normalized;
+ return normalizer.normalize( value );
}
@@ -132,6 +130,7 @@
*
* @param schemaManager The SchemaManager
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
normalizer.setSchemaManager( schemaManager );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java
index c9e0e8d..9037b27 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java
@@ -61,7 +61,7 @@
char[] newVal = new char[value.length()];
int escaped = 0;
char high = 0;
- char low = 0;
+ char low;
int pos = 0;
for ( int index = 0; index < value.length(); index++ )
@@ -105,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object normalizeByName( String name, String value ) throws LdapException
{
AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name );
@@ -127,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object normalizeByName( String name, byte[] value ) throws LdapException
{
AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name );
@@ -146,6 +148,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object normalizeByOid( String oid, String value ) throws LdapException
{
return lookup( oid ).normalize( value );
@@ -155,6 +158,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Object normalizeByOid( String oid, byte[] value ) throws LdapException
{
return lookup( oid ).normalize( new BinaryValue( value ) );
@@ -189,12 +193,14 @@
/**
* @see NameComponentNormalizer#isDefined(String)
*/
+ @Override
public boolean isDefined( String id )
{
return schemaManager.getAttributeTypeRegistry().contains( id );
}
+ @Override
public String normalizeName( String attributeName ) throws LdapException
{
return schemaManager.getAttributeTypeRegistry().getOidByName( attributeName );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizer.java
index 6bbe265..d4058fc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizer.java
@@ -65,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
try
@@ -85,14 +86,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
try
{
- String normalized = PrepareString.normalize( value,
- PrepareString.StringType.DIRECTORY_STRING );
-
- return normalized;
+ return PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING );
}
catch ( IOException ioe )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimToLowerNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimToLowerNormalizer.java
index a130fad..709f4dd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimToLowerNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimToLowerNormalizer.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
if ( value == null )
@@ -91,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
if ( value == null )
@@ -100,10 +102,7 @@
try
{
- String normalized = PrepareString.normalize( value,
- PrepareString.StringType.CASE_IGNORE );
-
- return normalized;
+ return PrepareString.normalize( value, PrepareString.StringType.CASE_IGNORE );
}
catch ( IOException ioe )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DefaultStringNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DefaultStringNormalizer.java
index 42df09e..fdada34 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DefaultStringNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DefaultStringNormalizer.java
@@ -53,6 +53,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
String str = value.getString();
@@ -69,6 +70,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
if ( Strings.isEmpty( value ) )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
index d50bf96..9d50d6c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/DnNormalizer.java
@@ -53,9 +53,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
- Dn dn = null;
+ Dn dn;
String dnStr = value.getString();
@@ -68,9 +69,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
- Dn dn = null;
+ Dn dn;
dn = new Dn( schemaManager, value );
@@ -86,7 +88,7 @@
*/
public String normalize( Dn value ) throws LdapException
{
- Dn dn = null;
+ Dn dn;
dn = value.apply( schemaManager );
@@ -97,6 +99,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/GeneralizedTimeNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/GeneralizedTimeNormalizer.java
index 5e274ea..dcc8a15 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/GeneralizedTimeNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/GeneralizedTimeNormalizer.java
@@ -65,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
try
@@ -84,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
try
@@ -91,10 +93,9 @@
String prepared = PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING );
GeneralizedTime time = new GeneralizedTime( prepared );
- String normalized = time.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION,
- FractionDelimiter.DOT, 3, TimeZoneFormat.Z );
- return normalized;
+ return time.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION,
+ FractionDelimiter.DOT, 3, TimeZoneFormat.Z );
}
catch ( IOException ioe )
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java
index 037195d..5226a4e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java
@@ -42,7 +42,7 @@
@SuppressWarnings("serial")
public class NameOrNumericIdNormalizer extends Normalizer
{
- private NumericOidSyntaxChecker checker = new NumericOidSyntaxChecker();
+ private NumericOidSyntaxChecker checker = NumericOidSyntaxChecker.INSTANCE;
/** A reference to the schema manager used to normalize the Name */
private SchemaManager schemaManager;
@@ -63,6 +63,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
if ( value == null )
@@ -99,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
if ( value == null )
@@ -133,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NoOpNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NoOpNormalizer.java
index aa28520..816f20b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NoOpNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NoOpNormalizer.java
@@ -59,6 +59,7 @@
* @return the value argument returned as-is
* @see org.apache.directory.api.ldap.model.schema.Normalizer#normalize(Value)
*/
+ @Override
public Value<?> normalize( Value<?> value )
{
return value;
@@ -72,6 +73,7 @@
* @return the value argument returned as-is
* @see org.apache.directory.api.ldap.model.schema.Normalizer#normalize(String)
*/
+ @Override
public String normalize( String value )
{
return value;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NumericNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NumericNormalizer.java
index 0f6a1e2..c0f2839 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NumericNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NumericNormalizer.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
try
@@ -71,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
try
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
index 28ce7f0..d159ab3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
@@ -48,6 +48,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
if ( value == null )
@@ -76,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
if ( value == null )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
index 04ba6bf..faa77ff 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/OidNormalizer.java
@@ -89,6 +89,7 @@
/**
* Return a String representation of this class
*/
+ @Override
public String toString()
{
return "OidNormalizer : { " + attributeTypeOid + ", " + normalizer.toString() + "}";
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/RegexNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/RegexNormalizer.java
index 999f5f1..1ca1102 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/RegexNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/RegexNormalizer.java
@@ -75,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( final Value<?> value )
{
if ( value == null )
@@ -102,6 +103,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value )
{
if ( value == null )
@@ -124,9 +126,10 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append( "RegexNormalizer( " );
for ( int i = 0; i < regexes.length; i++ )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/TelephoneNumberNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/TelephoneNumberNormalizer.java
index d51b40e..0d0485f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/TelephoneNumberNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/TelephoneNumberNormalizer.java
@@ -52,6 +52,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
try
@@ -71,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String normalize( String value ) throws LdapException
{
try
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/UniqueMemberNormalizer.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/UniqueMemberNormalizer.java
index 26ca408..aca00d7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/UniqueMemberNormalizer.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/UniqueMemberNormalizer.java
@@ -43,12 +43,16 @@
private SchemaManager schemaManager;
+ /**
+ * Creates a new UniqueMemberNormalizer instance
+ */
public UniqueMemberNormalizer()
{
super( SchemaConstants.UNIQUE_MEMBER_MATCH_MR_OID );
}
+ @Override
public Value<?> normalize( Value<?> value ) throws LdapException
{
String nameAndUid = value.getString();
@@ -96,6 +100,7 @@
}
+ @Override
public String normalize( String value ) throws LdapException
{
if ( Strings.isEmpty( value ) )
@@ -144,6 +149,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSchemaManager( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
index 7417767..13794b1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
@@ -38,6 +38,8 @@
/**
* Base class of all schema parsers.
+ *
+ * @param <T> The type of SchemaObject
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -172,26 +174,22 @@
}
catch ( RecognitionException re )
{
- ParseException parseException = wrapRecognitionException( schemaDescription, re );
- throw parseException;
+ throw wrapRecognitionException( schemaDescription, re );
}
catch ( TokenStreamRecognitionException tsre )
{
if ( tsre.recog != null )
{
- ParseException parseException = wrapRecognitionException( schemaDescription, tsre.recog );
- throw parseException;
+ throw wrapRecognitionException( schemaDescription, tsre.recog );
}
else
{
- ParseException parseException = wrapTokenStreamException( schemaDescription, tsre );
- throw parseException;
+ throw wrapTokenStreamException( schemaDescription, tsre );
}
}
catch ( TokenStreamException tse )
{
- ParseException parseException = wrapTokenStreamException( schemaDescription, tse );
- throw parseException;
+ throw wrapTokenStreamException( schemaDescription, tse );
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ConsoleParserMonitor.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ConsoleParserMonitor.java
index 2a05035..2351aa1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ConsoleParserMonitor.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ConsoleParserMonitor.java
@@ -28,9 +28,14 @@
*/
public class ConsoleParserMonitor implements ParserMonitor
{
+ /** The maven property to add on the commmand line */
public static final String TRACE_KEY = "maven.eve.schema.parser.trace";
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void matchedProduction( String prod )
{
if ( System.getProperties().containsKey( TRACE_KEY ) )
@@ -40,6 +45,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void startedParse( String s )
{
if ( System.getProperties().containsKey( TRACE_KEY ) )
@@ -49,6 +58,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void finishedParse( String s )
{
if ( System.getProperties().containsKey( TRACE_KEY ) )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescription.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescription.java
index 69cdd67..9e5f957 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescription.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescription.java
@@ -49,6 +49,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "Comparator description : " + getDescription();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescription.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescription.java
index ecce24f..7b410c5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescription.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescription.java
@@ -49,6 +49,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "SyntaxChecker description : " + getDescription();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
index 9151f63..4045731 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
@@ -21,11 +21,12 @@
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -137,9 +138,9 @@
*/
private void afterParse() throws ParseException
{
- objectClasses = new ArrayList<ObjectClass>();
- attributeTypes = new ArrayList<MutableAttributeType>();
- objectIdentifierMacros = new HashMap<String, OpenLdapObjectIdentifierMacro>();
+ objectClasses = new ArrayList<>();
+ attributeTypes = new ArrayList<>();
+ objectIdentifierMacros = new HashMap<>();
// split parsed schema descriptions
for ( Object obj : schemaDescriptions )
@@ -253,9 +254,10 @@
* @return the schema object
* @throws ParseException If the schemaObject can't be parsed
*/
+ @Override
public SchemaObject parse( String schemaObject ) throws ParseException
{
- if ( schemaObject == null || schemaObject.trim().equals( "" ) )
+ if ( schemaObject == null || ( schemaObject.trim().length() == 0 ) )
{
throw new ParseException( I18n.err( I18n.ERR_04258 ), 0 );
}
@@ -328,7 +330,8 @@
*/
public void parse( File schemaFile ) throws IOException, ParseException
{
- InputStreamReader in = new InputStreamReader( new FileInputStream( schemaFile ), Charset.defaultCharset() );
+ InputStreamReader in = new InputStreamReader(
+ Files.newInputStream( Paths.get( schemaFile.getPath() ) ), Charset.defaultCharset() );
lexer.prepareNextInput( in );
parser.resetState();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserMonitorAdapter.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserMonitorAdapter.java
index b1de815..179bdce 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserMonitorAdapter.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserMonitorAdapter.java
@@ -30,6 +30,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void matchedProduction( String prod )
{
}
@@ -38,6 +39,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void startedParse( String s )
{
}
@@ -46,6 +48,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void finishedParse( String s )
{
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescription.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescription.java
index 9457b17..e850b28 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescription.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescription.java
@@ -49,6 +49,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "SyntaxChecker description : " + getDescription();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java
index 05ccc1f..60e992e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AbstractSchemaLoader.java
@@ -60,9 +60,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public final Collection<Schema> getAllEnabled()
{
- Collection<Schema> enabledSchemas = new ArrayList<Schema>();
+ Collection<Schema> enabledSchemas = new ArrayList<>();
for ( Schema schema : schemaMap.values() )
{
@@ -79,6 +80,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final Collection<Schema> getAllSchemas()
{
return schemaMap.values();
@@ -88,6 +90,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Schema getSchema( String schemaName )
{
return schemaMap.get( Strings.toLowerCaseAscii( schemaName ) );
@@ -97,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addSchema( Schema schema )
{
schemaMap.put( schema.getSchemaName(), schema );
@@ -106,6 +110,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void removeSchema( Schema schema )
{
schemaMap.remove( Strings.toLowerCaseAscii( schema.getSchemaName() ) );
@@ -170,12 +175,12 @@
{
String value = entry.get( MetaSchemaConstants.M_DISABLED_AT ).getString();
value = Strings.upperCase( value );
- isDisabled = value.equals( "TRUE" );
+ isDisabled = "TRUE".equals( value );
}
if ( entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT ) != null )
{
- Set<String> depsSet = new HashSet<String>();
+ Set<String> depsSet = new HashSet<>();
Attribute depsAttr = entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT );
for ( Value<?> value : depsAttr )
@@ -207,11 +212,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadAttributeTypes( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadAttributeTypes( buildSchemaArray( schemaNames ) );
@@ -221,11 +227,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadComparators( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadComparators( buildSchemaArray( schemaNames ) );
@@ -235,11 +242,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitContentRules( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadDitContentRules( buildSchemaArray( schemaNames ) );
@@ -249,11 +257,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitStructureRules( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadDitStructureRules( buildSchemaArray( schemaNames ) );
@@ -263,11 +272,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRules( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadMatchingRules( buildSchemaArray( schemaNames ) );
@@ -277,11 +287,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRuleUses( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadMatchingRuleUses( buildSchemaArray( schemaNames ) );
@@ -291,11 +302,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNameForms( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadNameForms( buildSchemaArray( schemaNames ) );
@@ -305,11 +317,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNormalizers( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadNormalizers( buildSchemaArray( schemaNames ) );
@@ -319,11 +332,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadObjectClasses( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadObjectClasses( buildSchemaArray( schemaNames ) );
@@ -333,11 +347,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxes( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadSyntaxes( buildSchemaArray( schemaNames ) );
@@ -347,11 +362,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxCheckers( String... schemaNames ) throws LdapException, IOException
{
if ( schemaNames == null )
{
- return new ArrayList<Entry>();
+ return new ArrayList<>();
}
return loadSyntaxCheckers( buildSchemaArray( schemaNames ) );
@@ -361,6 +377,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRelaxed()
{
return relaxed == SchemaManager.RELAXED;
@@ -370,6 +387,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isStrict()
{
return relaxed == SchemaManager.STRICT;
@@ -379,6 +397,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRelaxed( boolean relaxed )
{
this.relaxed = relaxed;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AttributeTypeRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AttributeTypeRegistry.java
index 4b42e3f..56a77c5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AttributeTypeRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/AttributeTypeRegistry.java
@@ -139,5 +139,6 @@
*
* @return The copied AttributeTypeRegistry
*/
+ @Override
AttributeTypeRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ComparatorRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ComparatorRegistry.java
index 8148e22..6e37950 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ComparatorRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ComparatorRegistry.java
@@ -39,6 +39,7 @@
* @throws LdapException if the LdapComparator is already registered or
* the registration operation is not supported
*/
+ @Override
void register( LdapComparator<?> comparator ) throws LdapException;
@@ -49,6 +50,7 @@
* @param numericOid the numeric identifier
* @throws LdapException if the numeric identifier is invalid
*/
+ @Override
LdapComparator<?> unregister( String numericOid ) throws LdapException;
@@ -58,11 +60,13 @@
*
* @param schemaName the name of the schema whose LdapComparators will be removed from
*/
+ @Override
void unregisterSchemaElements( String schemaName ) throws LdapException;
/**
* Copy the ComparatorRegistry
*/
+ @Override
ComparatorRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultAttributeTypeRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultAttributeTypeRegistry.java
index 68ec9d4..098893b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultAttributeTypeRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultAttributeTypeRegistry.java
@@ -63,14 +63,15 @@
public DefaultAttributeTypeRegistry()
{
super( SchemaObjectType.ATTRIBUTE_TYPE, new OidRegistry<AttributeType>() );
- oidNormalizerMap = new HashMap<String, OidNormalizer>();
- oidToDescendantSet = new HashMap<String, Set<AttributeType>>();
+ oidNormalizerMap = new HashMap<>();
+ oidToDescendantSet = new HashMap<>();
}
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, OidNormalizer> getNormalizerMapping()
{
return Collections.unmodifiableMap( oidNormalizerMap );
@@ -80,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( String ancestorId ) throws LdapException
{
try
@@ -98,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( AttributeType ancestor ) throws LdapException
{
String oid = ancestor.getOid();
@@ -110,6 +113,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Iterator<AttributeType> descendants( String ancestorId ) throws LdapException
{
try
@@ -135,6 +139,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException
{
String oid = ancestor.getOid();
@@ -152,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException
{
// add this attribute to descendant list of other attributes in superior chain
@@ -166,7 +172,7 @@
// Initialize the descendant Set to store the descendants for the attributeType
if ( descendants == null )
{
- descendants = new HashSet<AttributeType>( 1 );
+ descendants = new HashSet<>( 1 );
oidToDescendantSet.put( ancestor.getOid(), descendants );
}
@@ -178,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException
{
// add this attribute to descendant list of other attributes in superior chain
@@ -193,7 +200,7 @@
{
descendants.remove( attributeType );
- if ( descendants.size() == 0 )
+ if ( descendants.isEmpty() )
{
oidToDescendantSet.remove( ancestor.getOid() );
}
@@ -204,6 +211,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType unregister( String numericOid ) throws LdapException
{
try
@@ -232,6 +240,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addMappingFor( AttributeType attributeType ) throws LdapException
{
MatchingRule equality = attributeType.getEquality();
@@ -262,6 +271,7 @@
/**
* Remove the AttributeType normalizer from the OidNormalizer map
*/
+ @Override
public void removeMappingFor( AttributeType attributeType ) throws LdapException
{
if ( attributeType == null )
@@ -282,6 +292,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType lookup( String oid ) throws LdapException
{
try
@@ -298,6 +309,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultAttributeTypeRegistry copy()
{
DefaultAttributeTypeRegistry copy = new DefaultAttributeTypeRegistry();
@@ -312,6 +324,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// First clear the shared elements
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultComparatorRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultComparatorRegistry.java
index c0da061..4b0bcdd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultComparatorRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultComparatorRegistry.java
@@ -57,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
if ( schemaName == null )
@@ -85,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultComparatorRegistry copy()
{
DefaultComparatorRegistry copy = new DefaultComparatorRegistry();
@@ -99,6 +101,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitContentRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitContentRuleRegistry.java
index c70f027..02b74b5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitContentRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitContentRuleRegistry.java
@@ -44,6 +44,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultDitContentRuleRegistry copy()
{
DefaultDitContentRuleRegistry copy = new DefaultDitContentRuleRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitStructureRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitStructureRuleRegistry.java
index 965b53a..7058b75 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitStructureRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultDitStructureRuleRegistry.java
@@ -57,13 +57,14 @@
public DefaultDitStructureRuleRegistry()
{
super( SchemaObjectType.DIT_STRUCTURE_RULE, new OidRegistry<DitStructureRule>() );
- byRuleId = new HashMap<Integer, DitStructureRule>();
+ byRuleId = new HashMap<>();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( int ruleId )
{
return byRuleId.containsKey( ruleId );
@@ -73,6 +74,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<DitStructureRule> iterator()
{
return byRuleId.values().iterator();
@@ -82,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<Integer> ruleIdIterator()
{
return byRuleId.keySet().iterator();
@@ -91,6 +94,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( int ruleId ) throws LdapException
{
DitStructureRule ditStructureRule = byRuleId.get( ruleId );
@@ -109,6 +113,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( DitStructureRule ditStructureRule ) throws LdapException
{
int ruleId = ditStructureRule.getRuleId();
@@ -132,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule lookup( int ruleId ) throws LdapException
{
DitStructureRule ditStructureRule = byRuleId.get( ruleId );
@@ -155,6 +161,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregister( int ruleId ) throws LdapException
{
DitStructureRule ditStructureRule = byRuleId.remove( ruleId );
@@ -169,6 +176,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName )
{
if ( schemaName == null )
@@ -197,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName )
{
// Loop on all the SchemaObjects stored and remove those associated
@@ -219,6 +228,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultDitStructureRuleRegistry copy()
{
DefaultDitStructureRuleRegistry copy = new DefaultDitStructureRuleRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultLdapSyntaxRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultLdapSyntaxRegistry.java
index d90e62c..ef2963e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultLdapSyntaxRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultLdapSyntaxRegistry.java
@@ -44,6 +44,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultLdapSyntaxRegistry copy()
{
DefaultLdapSyntaxRegistry copy = new DefaultLdapSyntaxRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleRegistry.java
index 2a5b67d..79ef290 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleRegistry.java
@@ -44,6 +44,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultMatchingRuleRegistry copy()
{
DefaultMatchingRuleRegistry copy = new DefaultMatchingRuleRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleUseRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleUseRegistry.java
index dfbdd17..33910bb 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleUseRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultMatchingRuleUseRegistry.java
@@ -47,6 +47,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultMatchingRuleUseRegistry copy()
{
DefaultMatchingRuleUseRegistry copy = new DefaultMatchingRuleUseRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNameFormRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNameFormRegistry.java
index 289fbb3..af58e34 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNameFormRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNameFormRegistry.java
@@ -44,6 +44,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultNameFormRegistry copy()
{
DefaultNameFormRegistry copy = new DefaultNameFormRegistry();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNormalizerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNormalizerRegistry.java
index c78f983..8b76c52 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNormalizerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultNormalizerRegistry.java
@@ -57,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
if ( schemaName == null )
@@ -85,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultNormalizerRegistry copy()
{
DefaultNormalizerRegistry copy = new DefaultNormalizerRegistry();
@@ -99,6 +101,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultObjectClassRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultObjectClassRegistry.java
index cd2da82..16c33a1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultObjectClassRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultObjectClassRegistry.java
@@ -53,13 +53,14 @@
public DefaultObjectClassRegistry()
{
super( SchemaObjectType.OBJECT_CLASS, new OidRegistry<ObjectClass>() );
- oidToDescendants = new HashMap<String, Set<ObjectClass>>();
+ oidToDescendants = new HashMap<>();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( String ancestorId ) throws LdapException
{
try
@@ -79,6 +80,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Iterator<ObjectClass> descendants( String ancestorId ) throws LdapException
{
try
@@ -103,11 +105,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors )
throws LdapException
{
// add this attribute to descendant list of other attributes in superior chain
- if ( ( ancestors == null ) || ( ancestors.size() == 0 ) )
+ if ( ( ancestors == null ) || ancestors.isEmpty() )
{
return;
}
@@ -120,7 +123,7 @@
// Initialize the descendant Set to store the descendants for the attributeType
if ( descendants == null )
{
- descendants = new HashSet<ObjectClass>( 1 );
+ descendants = new HashSet<>( 1 );
oidToDescendants.put( ancestor.getOid(), descendants );
}
@@ -143,11 +146,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors )
throws LdapException
{
// add this attribute to descendant list of other attributes in superior chain
- if ( ( ancestors == null ) || ( ancestors.size() == 0 ) )
+ if ( ( ancestors == null ) || ancestors.isEmpty() )
{
return;
}
@@ -161,7 +165,7 @@
{
descendants.remove( attributeType );
- if ( descendants.size() == 0 )
+ if ( descendants.isEmpty() )
{
oidToDescendants.remove( ancestor.getOid() );
}
@@ -183,6 +187,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass unregister( String numericOid ) throws LdapException
{
try
@@ -209,6 +214,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultObjectClassRegistry copy()
{
DefaultObjectClassRegistry copy = new DefaultObjectClassRegistry();
@@ -223,6 +229,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear the contained SchemaObjects
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchema.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchema.java
index 62534a4..4a943db 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchema.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchema.java
@@ -136,7 +136,7 @@
this.disabled = disabled;
- content = new HashSet<SchemaObjectWrapper>();
+ content = new HashSet<>();
this.schemaLoader = schemaLoader;
}
@@ -145,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String[] getDependencies()
{
String[] copy = new String[dependencies.length];
@@ -156,6 +157,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addDependencies( String... dependenciesToAdd )
{
if ( dependenciesToAdd != null )
@@ -182,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOwner()
{
return owner;
@@ -191,6 +194,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName()
{
return name;
@@ -200,6 +204,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDisabled()
{
return disabled;
@@ -209,6 +214,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEnabled()
{
return !disabled;
@@ -218,6 +224,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void disable()
{
this.disabled = true;
@@ -227,6 +234,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void enable()
{
this.disabled = false;
@@ -236,6 +244,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<SchemaObjectWrapper> getContent()
{
return content;
@@ -245,6 +254,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaLoader getSchemaLoader()
{
return schemaLoader;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java
index b72c210..ff99850 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java
@@ -39,6 +39,8 @@
/**
* Common schema object registry interface.
+ *
+ * @param <T> The type of SchemaObject
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -72,7 +74,7 @@
*/
protected DefaultSchemaObjectRegistry( SchemaObjectType schemaObjectType, OidRegistry<T> oidRegistry )
{
- byName = new HashMap<String, T>();
+ byName = new HashMap<>();
this.schemaObjectType = schemaObjectType;
this.oidRegistry = oidRegistry;
this.isRelaxed = Registries.STRICT;
@@ -126,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
if ( !byName.containsKey( oid ) )
@@ -140,6 +143,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
if ( !Oid.isOid( oid ) )
@@ -165,6 +169,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName )
{
// Loop on all the SchemaObjects stored and remove those associated
@@ -187,6 +192,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<T> iterator()
{
return oidRegistry.iterator();
@@ -196,6 +202,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return byName.keySet().iterator();
@@ -205,6 +212,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T lookup( String oid ) throws LdapException
{
if ( oid == null )
@@ -239,6 +247,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( T schemaObject ) throws LdapException
{
String oid = schemaObject.getOid();
@@ -291,6 +300,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T unregister( String numericOid ) throws LdapException
{
if ( !Oid.isOid( numericOid ) )
@@ -322,6 +332,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T unregister( T schemaObject ) throws LdapException
{
String oid = schemaObject.getOid();
@@ -355,6 +366,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
if ( schemaName == null )
@@ -383,6 +395,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
T schemaObject = byName.get( name );
@@ -407,7 +420,10 @@
/**
- * {@inheritDoc}
+ * Copy a SchemaObject registry
+ *
+ * @param original The SchemaObject registry to copy
+ * @return The copied ShcemaObject registry
*/
// This will suppress PMD.EmptyCatchBlock warnings in this method
@SuppressWarnings("unchecked")
@@ -466,6 +482,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public T get( String oid )
{
try
@@ -482,6 +499,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return schemaObjectType;
@@ -491,6 +509,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return oidRegistry.size();
@@ -500,6 +519,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
@@ -531,6 +551,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
// Clear all the schemaObjects
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSyntaxCheckerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSyntaxCheckerRegistry.java
index 3743ad9..bf68a11 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSyntaxCheckerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DefaultSyntaxCheckerRegistry.java
@@ -57,6 +57,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
if ( schemaName == null )
@@ -85,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DefaultSyntaxCheckerRegistry copy()
{
DefaultSyntaxCheckerRegistry copy = new DefaultSyntaxCheckerRegistry();
@@ -99,6 +101,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitContentRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitContentRuleRegistry.java
index 6317a5b..7d4146c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitContentRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitContentRuleRegistry.java
@@ -34,5 +34,6 @@
/**
* Copy the DitContentRuleRegistry
*/
+ @Override
DitContentRuleRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitStructureRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitStructureRuleRegistry.java
index a189b40..9a6517f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitStructureRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/DitStructureRuleRegistry.java
@@ -50,6 +50,7 @@
*
* @return an Iterator of descriptions
*/
+ @Override
Iterator<DitStructureRule> iterator();
@@ -78,6 +79,7 @@
* @throws LdapException if the DitStructureRule is already registered or
* the registration operation is not supported
*/
+ @Override
void register( DitStructureRule ditStructureRule ) throws LdapException;
@@ -108,6 +110,7 @@
* @param schemaName the name of the schema whose syntaxCheckers will be removed from
* @throws LdapException if no such SchemaElement exists
*/
+ @Override
void unregisterSchemaElements( String schemaName ) throws LdapException;
@@ -118,11 +121,13 @@
* @param newSchemaName The new Schema name
* @throws org.apache.directory.api.ldap.model.exception.LdapException if the schema can't be renamed
*/
+ @Override
void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException;
/**
* Copy the DitStructureRuleRegistry
*/
+ @Override
DitStructureRuleRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableAttributeTypeRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableAttributeTypeRegistry.java
index 193a67f..9b11993 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableAttributeTypeRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableAttributeTypeRegistry.java
@@ -58,6 +58,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, OidNormalizer> getNormalizerMapping()
{
return immutableAttributeTypeRegistry.getNormalizerMapping();
@@ -67,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( String ancestorId ) throws LdapException
{
return immutableAttributeTypeRegistry.hasDescendants( ancestorId );
@@ -76,6 +78,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( AttributeType ancestor ) throws LdapException
{
return immutableAttributeTypeRegistry.hasDescendants( ancestor );
@@ -85,6 +88,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<AttributeType> descendants( String ancestorId ) throws LdapException
{
return immutableAttributeTypeRegistry.descendants( ancestorId );
@@ -94,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException
{
return immutableAttributeTypeRegistry.descendants( ancestor );
@@ -103,6 +108,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( AttributeType attributeType ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -112,6 +118,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -121,6 +128,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -130,6 +138,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION,
@@ -140,6 +149,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void addMappingFor( AttributeType attributeType ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -149,6 +159,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void removeMappingFor( AttributeType attributeType ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -158,6 +169,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType lookup( String oid ) throws LdapException
{
return immutableAttributeTypeRegistry.lookup( oid );
@@ -167,6 +179,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return immutableAttributeTypeRegistry.toString();
@@ -176,15 +189,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeTypeRegistry copy()
{
- return ( AttributeTypeRegistry ) immutableAttributeTypeRegistry.copy();
+ return immutableAttributeTypeRegistry.copy();
}
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableAttributeTypeRegistry.size();
@@ -194,6 +209,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<AttributeType> iterator()
{
return immutableAttributeTypeRegistry.iterator();
@@ -203,6 +219,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableAttributeTypeRegistry.oidsIterator();
@@ -212,6 +229,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableAttributeTypeRegistry.contains( oid );
@@ -221,6 +239,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
try
@@ -237,6 +256,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableAttributeTypeRegistry.getSchemaName( oid );
@@ -246,6 +266,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableAttributeTypeRegistry.getType();
@@ -255,6 +276,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName )
{
// Do nothing
@@ -264,6 +286,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -273,6 +296,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType get( String oid )
{
return immutableAttributeTypeRegistry.get( oid );
@@ -282,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
@@ -291,6 +316,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType unregister( AttributeType schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableComparatorRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableComparatorRegistry.java
index 033f944..9c7106c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableComparatorRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableComparatorRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( LdapComparator<?> comparator ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableComparatorRegistry copy()
{
return ( ImmutableComparatorRegistry ) immutableComparatorRegistry.copy();
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableComparatorRegistry.size();
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableComparatorRegistry.contains( oid );
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableComparatorRegistry.getOidByName( name );
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableComparatorRegistry.getSchemaName( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableComparatorRegistry.getType();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<LdapComparator<?>> iterator()
{
return immutableComparatorRegistry.iterator();
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> lookup( String oid ) throws LdapException
{
return immutableComparatorRegistry.lookup( oid );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableComparatorRegistry.oidsIterator();
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> get( String oid )
{
return immutableComparatorRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> unregister( LdapComparator<?> schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitContentRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitContentRuleRegistry.java
index 1328110..7d2f945 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitContentRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitContentRuleRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableDitContentRuleRegistry copy()
{
return ( ImmutableDitContentRuleRegistry ) immutableDITContentRuleRegistry.copy();
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableDITContentRuleRegistry.size();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableDITContentRuleRegistry.contains( oid );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableDITContentRuleRegistry.getOidByName( name );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableDITContentRuleRegistry.getSchemaName( oid );
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableDITContentRuleRegistry.getType();
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<DitContentRule> iterator()
{
return immutableDITContentRuleRegistry.iterator();
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitContentRule lookup( String oid ) throws LdapException
{
return immutableDITContentRuleRegistry.lookup( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableDITContentRuleRegistry.oidsIterator();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( DitContentRule schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitContentRule unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitContentRule get( String oid )
{
return immutableDITContentRuleRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitContentRule unregister( DitContentRule schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitStructureRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitStructureRuleRegistry.java
index 12b5f7a..05ab382 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitStructureRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableDitStructureRuleRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( int ruleId )
{
return immutableDITStructureRuleRegistry.contains( ruleId );
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<DitStructureRule> iterator()
{
return immutableDITStructureRuleRegistry.iterator();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<Integer> ruleIdIterator()
{
return immutableDITStructureRuleRegistry.ruleIdIterator();
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( int ruleId ) throws LdapException
{
return immutableDITStructureRuleRegistry.getSchemaName( ruleId );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( DitStructureRule ditStructureRule ) throws LdapException
{
}
@@ -99,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule lookup( int ruleId ) throws LdapException
{
return immutableDITStructureRuleRegistry.lookup( ruleId );
@@ -108,6 +114,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregister( int ruleId ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
@@ -117,6 +124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
@@ -126,6 +134,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
@@ -135,6 +144,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableDitStructureRuleRegistry copy()
{
return ( ImmutableDitStructureRuleRegistry ) immutableDITStructureRuleRegistry.copy();
@@ -144,6 +154,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableDITStructureRuleRegistry.size();
@@ -153,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableDITStructureRuleRegistry.contains( oid );
@@ -162,6 +174,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableDITStructureRuleRegistry.getOidByName( name );
@@ -171,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableDITStructureRuleRegistry.getSchemaName( oid );
@@ -180,6 +194,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableDITStructureRuleRegistry.getType();
@@ -189,6 +204,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule lookup( String oid ) throws LdapException
{
return immutableDITStructureRuleRegistry.lookup( oid );
@@ -198,6 +214,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableDITStructureRuleRegistry.oidsIterator();
@@ -207,6 +224,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
@@ -216,6 +234,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule get( String oid )
{
return immutableDITStructureRuleRegistry.get( oid );
@@ -225,6 +244,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
@@ -234,6 +254,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRule unregister( DitStructureRule schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableLdapSyntaxRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableLdapSyntaxRegistry.java
index 69a0500..06df6f3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableLdapSyntaxRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableLdapSyntaxRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableLdapSyntaxRegistry copy()
{
return ( ImmutableLdapSyntaxRegistry ) immutableLdapSyntaxRegistry.copy();
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableLdapSyntaxRegistry.size();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableLdapSyntaxRegistry.contains( oid );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableLdapSyntaxRegistry.getOidByName( name );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableLdapSyntaxRegistry.getSchemaName( oid );
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableLdapSyntaxRegistry.getType();
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<LdapSyntax> iterator()
{
return immutableLdapSyntaxRegistry.iterator();
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax lookup( String oid ) throws LdapException
{
return immutableLdapSyntaxRegistry.lookup( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableLdapSyntaxRegistry.oidsIterator();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( LdapSyntax schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax get( String oid )
{
return immutableLdapSyntaxRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax unregister( LdapSyntax schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleRegistry.java
index 9e4fa4a..3e89cab 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableMatchingRuleRegistry copy()
{
return ( ImmutableMatchingRuleRegistry ) immutableMatchingRuleRegistry.copy();
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableMatchingRuleRegistry.size();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableMatchingRuleRegistry.contains( oid );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableMatchingRuleRegistry.getOidByName( name );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableMatchingRuleRegistry.getSchemaName( oid );
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableMatchingRuleRegistry.getType();
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<MatchingRule> iterator()
{
return immutableMatchingRuleRegistry.iterator();
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRule lookup( String oid ) throws LdapException
{
return immutableMatchingRuleRegistry.lookup( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableMatchingRuleRegistry.oidsIterator();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( MatchingRule schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRule unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRule get( String oid )
{
return immutableMatchingRuleRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRule unregister( MatchingRule schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04280 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleUseRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleUseRegistry.java
index 3e8d235..469bf9d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleUseRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableMatchingRuleUseRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableMatchingRuleUseRegistry copy()
{
return ( ImmutableMatchingRuleUseRegistry ) immutableMatchingRuleUseRegistry.copy();
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableMatchingRuleUseRegistry.size();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableMatchingRuleUseRegistry.contains( oid );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableMatchingRuleUseRegistry.getOidByName( name );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableMatchingRuleUseRegistry.getSchemaName( oid );
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableMatchingRuleUseRegistry.getType();
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<MatchingRuleUse> iterator()
{
return immutableMatchingRuleUseRegistry.iterator();
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleUse lookup( String oid ) throws LdapException
{
return immutableMatchingRuleUseRegistry.lookup( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableMatchingRuleUseRegistry.oidsIterator();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( MatchingRuleUse schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleUse unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleUse get( String oid )
{
return immutableMatchingRuleUseRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleUse unregister( MatchingRuleUse schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04281 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNameFormRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNameFormRegistry.java
index 656b41e..d660fab 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNameFormRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNameFormRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableNameFormRegistry copy()
{
return ( ImmutableNameFormRegistry ) immutableNameFormRegistry.copy();
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableNameFormRegistry.size();
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableNameFormRegistry.contains( oid );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableNameFormRegistry.getOidByName( name );
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableNameFormRegistry.getSchemaName( oid );
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableNameFormRegistry.getType();
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<NameForm> iterator()
{
return immutableNameFormRegistry.iterator();
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NameForm lookup( String oid ) throws LdapException
{
return immutableNameFormRegistry.lookup( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableNameFormRegistry.oidsIterator();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( NameForm schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NameForm unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NameForm get( String oid )
{
return immutableNameFormRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NameForm unregister( NameForm schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04282 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNormalizerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNormalizerRegistry.java
index b15b855..38fd1a8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNormalizerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableNormalizerRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( Normalizer normalizer ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableNormalizerRegistry copy()
{
return ( ImmutableNormalizerRegistry ) immutableNormalizerRegistry.copy();
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableNormalizerRegistry.size();
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableNormalizerRegistry.contains( oid );
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableNormalizerRegistry.getOidByName( name );
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableNormalizerRegistry.getSchemaName( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableNormalizerRegistry.getType();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<Normalizer> iterator()
{
return immutableNormalizerRegistry.iterator();
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer lookup( String oid ) throws LdapException
{
return immutableNormalizerRegistry.lookup( oid );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableNormalizerRegistry.oidsIterator();
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer get( String oid )
{
return immutableNormalizerRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer unregister( Normalizer schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04283 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableObjectClassRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableObjectClassRegistry.java
index 1324c46..20acb68 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableObjectClassRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableObjectClassRegistry.java
@@ -56,6 +56,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasDescendants( String ancestorId ) throws LdapException
{
return immutableObjectClassRegistry.hasDescendants( ancestorId );
@@ -65,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<ObjectClass> descendants( String ancestorId ) throws LdapException
{
return immutableObjectClassRegistry.descendants( ancestorId );
@@ -74,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -83,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -92,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( ObjectClass objectClass ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -101,6 +106,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -110,6 +116,7 @@
/**
* Clone the ObjectClassRegistry
*/
+ @Override
public ImmutableObjectClassRegistry copy()
{
return ( ImmutableObjectClassRegistry ) immutableObjectClassRegistry.copy();
@@ -119,6 +126,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableObjectClassRegistry.size();
@@ -128,6 +136,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableObjectClassRegistry.contains( oid );
@@ -137,6 +146,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableObjectClassRegistry.getOidByName( name );
@@ -146,6 +156,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableObjectClassRegistry.getSchemaName( oid );
@@ -155,6 +166,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableObjectClassRegistry.getType();
@@ -164,6 +176,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<ObjectClass> iterator()
{
return immutableObjectClassRegistry.iterator();
@@ -173,6 +186,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass lookup( String oid ) throws LdapException
{
return immutableObjectClassRegistry.lookup( oid );
@@ -182,6 +196,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableObjectClassRegistry.oidsIterator();
@@ -191,6 +206,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -200,6 +216,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -209,6 +226,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass get( String oid )
{
return immutableObjectClassRegistry.get( oid );
@@ -218,6 +236,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
@@ -227,6 +246,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass unregister( ObjectClass schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableSyntaxCheckerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableSyntaxCheckerRegistry.java
index 7c7c854..ef71f0b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableSyntaxCheckerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ImmutableSyntaxCheckerRegistry.java
@@ -55,6 +55,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void register( SyntaxChecker syntaxChecker ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
@@ -64,6 +65,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker unregister( String numericOid ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
@@ -73,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void unregisterSchemaElements( String schemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
@@ -82,6 +85,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ImmutableSyntaxCheckerRegistry copy()
{
return ( ImmutableSyntaxCheckerRegistry ) immutableSyntaxCheckerRegistry.copy();
@@ -91,6 +95,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return immutableSyntaxCheckerRegistry.size();
@@ -100,6 +105,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String oid )
{
return immutableSyntaxCheckerRegistry.contains( oid );
@@ -109,6 +115,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOidByName( String name ) throws LdapException
{
return immutableSyntaxCheckerRegistry.getOidByName( name );
@@ -118,6 +125,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSchemaName( String oid ) throws LdapException
{
return immutableSyntaxCheckerRegistry.getSchemaName( oid );
@@ -127,6 +135,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObjectType getType()
{
return immutableSyntaxCheckerRegistry.getType();
@@ -136,6 +145,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<SyntaxChecker> iterator()
{
return immutableSyntaxCheckerRegistry.iterator();
@@ -145,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker lookup( String oid ) throws LdapException
{
return immutableSyntaxCheckerRegistry.lookup( oid );
@@ -154,6 +165,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Iterator<String> oidsIterator()
{
return immutableSyntaxCheckerRegistry.oidsIterator();
@@ -163,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
@@ -172,6 +185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker get( String oid )
{
return immutableSyntaxCheckerRegistry.get( oid );
@@ -181,6 +195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void clear() throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
@@ -190,6 +205,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker unregister( SyntaxChecker schemaObject ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04285 ) );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/LdapSyntaxRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/LdapSyntaxRegistry.java
index 05326a5..6832c4e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/LdapSyntaxRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/LdapSyntaxRegistry.java
@@ -34,5 +34,6 @@
/**
* Copy the LdapSyntaxRegistry
*/
+ @Override
LdapSyntaxRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleRegistry.java
index 9d1ddc8..92b780c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleRegistry.java
@@ -34,5 +34,6 @@
/**
* Copy the MatchingRuleRegistry
*/
+ @Override
MatchingRuleRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleUseRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleUseRegistry.java
index e529f79..050bfac 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleUseRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/MatchingRuleUseRegistry.java
@@ -36,5 +36,6 @@
/**
* Copy the MatchingRuleUseRegistry
*/
+ @Override
MatchingRuleUseRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NameFormRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NameFormRegistry.java
index fc3a4af..5ebbba6 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NameFormRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NameFormRegistry.java
@@ -34,5 +34,6 @@
/**
* Copy the NameFormRegistry
*/
+ @Override
NameFormRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NormalizerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NormalizerRegistry.java
index c459ce8..6b4187f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NormalizerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/NormalizerRegistry.java
@@ -39,6 +39,7 @@
* @throws LdapException if the Normalizer is already registered or
* the registration operation is not supported
*/
+ @Override
void register( Normalizer normalizer ) throws LdapException;
@@ -49,6 +50,7 @@
* @param numericOid the numeric identifier
* @throws LdapException if the numeric identifier is invalid
*/
+ @Override
Normalizer unregister( String numericOid ) throws LdapException;
@@ -58,11 +60,13 @@
*
* @param schemaName the name of the schema whose Normalizers will be removed from
*/
+ @Override
void unregisterSchemaElements( String schemaName ) throws LdapException;
/**
* Copy the NormalizerRegistry
*/
+ @Override
NormalizerRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ObjectClassRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ObjectClassRegistry.java
index d561c8e..c430f84 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ObjectClassRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/ObjectClassRegistry.java
@@ -91,6 +91,7 @@
* @throws LdapException if the ObjectClass is already registered or
* the registration operation is not supported
*/
+ @Override
void register( ObjectClass objectClass ) throws LdapException;
@@ -100,11 +101,13 @@
* @param numericOid the numeric identifier
* @throws LdapException if the numeric identifier is invalid
*/
+ @Override
ObjectClass unregister( String numericOid ) throws LdapException;
/**
* Copy the ObjectClassRegistry
*/
+ @Override
ObjectClassRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java
index 09fb19b..1828d2c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/OidRegistry.java
@@ -38,7 +38,9 @@
/**
* Object identifier registry. It stores the OIDs for AT, OC, MR, LS, MRU, DSR, DCR and NF.
* An OID is unique, and associated with a SO.
- *
+ *
+ * @param <T> The type of SchemaObject
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OidRegistry<T extends SchemaObject> implements Iterable<T>
@@ -50,10 +52,10 @@
private static final boolean IS_DEBUG = LOG.isDebugEnabled();
/** Maps OID to a type of SchemaObject */
- private Map<String, T> byOid = new HashMap<String, T>();
+ private Map<String, T> byOid = new HashMap<>();
/** A flag indicating that the Registry is relaxed or not */
- private boolean isRelaxed = Registries.STRICT;;
+ private boolean isRelaxed = Registries.STRICT;
/**
@@ -167,6 +169,7 @@
*
* @return all the SchemaObject registered
*/
+ @Override
public Iterator<T> iterator()
{
return byOid.values().iterator();
@@ -310,10 +313,10 @@
*/
public OidRegistry<T> copy()
{
- OidRegistry<T> copy = new OidRegistry<T>();
+ OidRegistry<T> copy = new OidRegistry<>();
// Clone the map
- copy.byOid = new HashMap<String, T>();
+ copy.byOid = new HashMap<>();
return copy;
}
@@ -328,6 +331,9 @@
}
+ /**
+ * Empty the byOid map
+ */
public void clear()
{
// remove all the OID
@@ -338,6 +344,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
index 5b51356..a52e7a2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
@@ -80,7 +80,7 @@
* A String name to Schema object map for the schemas loaded into this
* registry. The loaded schemas may be disabled.
*/
- protected Map<String, Schema> loadedSchemas = new HashMap<String, Schema>();
+ protected Map<String, Schema> loadedSchemas = new HashMap<>();
/** The AttributeType registry */
protected DefaultAttributeTypeRegistry attributeTypeRegistry;
@@ -127,8 +127,11 @@
/** A flag indicating that disabled SchemaObject are accepted */
private boolean disabledAccepted;
- /** Two flags for RELAXED and STRUCT */
+ /** Two flags for RELAXED and STRICT modes */
+ /** The strict mode */
public static final boolean STRICT = false;
+
+ /** The relaxed mode */
public static final boolean RELAXED = true;
/**
@@ -149,7 +152,7 @@
*/
public Registries()
{
- globalOidRegistry = new OidRegistry<SchemaObject>();
+ globalOidRegistry = new OidRegistry<>();
attributeTypeRegistry = new DefaultAttributeTypeRegistry();
comparatorRegistry = new DefaultComparatorRegistry();
ditContentRuleRegistry = new DefaultDitContentRuleRegistry();
@@ -161,9 +164,9 @@
normalizerRegistry = new DefaultNormalizerRegistry();
objectClassRegistry = new DefaultObjectClassRegistry();
syntaxCheckerRegistry = new DefaultSyntaxCheckerRegistry();
- schemaObjects = new HashMap<String, Set<SchemaObjectWrapper>>();
- usedBy = new HashMap<SchemaObjectWrapper, Set<SchemaObjectWrapper>>();
- using = new HashMap<SchemaObjectWrapper, Set<SchemaObjectWrapper>>();
+ schemaObjects = new HashMap<>();
+ usedBy = new HashMap<>();
+ using = new HashMap<>();
isRelaxed = STRICT;
disabledAccepted = false;
@@ -464,7 +467,7 @@
*/
public List<Throwable> checkRefInteg()
{
- ArrayList<Throwable> errors = new ArrayList<Throwable>();
+ ArrayList<Throwable> errors = new ArrayList<>();
// Step 1 :
// We start with Normalizers, Comparators and SyntaxCheckers
@@ -830,7 +833,7 @@
private void buildObjectClassReferences( List<Throwable> errors )
{
// Remember the OC we have already processed
- Set<String> done = new HashSet<String>();
+ Set<String> done = new HashSet<>();
// The ObjectClass
for ( ObjectClass objectClass : objectClassRegistry )
@@ -880,7 +883,7 @@
*/
public List<Throwable> buildReferences()
{
- List<Throwable> errors = new ArrayList<Throwable>();
+ List<Throwable> errors = new ArrayList<>();
// The Comparator references
buildComparatorReferences( errors );
@@ -1176,7 +1179,7 @@
// This set is used to avoid having more than one error
// for an AttributeType. It's mandatory when processing
// a Superior, as it may be broken and referenced more than once.
- Set<String> processed = new HashSet<String>();
+ Set<String> processed = new HashSet<>();
// Store the AttributeType itself in the processed, to avoid cycle
processed.add( attributeType.getOid() );
@@ -1220,7 +1223,7 @@
// This set is used to avoid having more than one error
// for an ObjectClass. It's mandatory when processing
// the Superiors, as they may be broken and referenced more than once.
- Set<String> processed = new HashSet<String>();
+ Set<String> processed = new HashSet<>();
// Store the ObjectClass itself in the processed, to avoid cycle
processed.add( objectClass.getOid() );
@@ -1439,6 +1442,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void schemaLoaded( Schema schema )
{
this.loadedSchemas.put( Strings.toLowerCaseAscii( schema.getSchemaName() ), schema );
@@ -1451,6 +1455,7 @@
*
* {@inheritDoc}
*/
+ @Override
public void schemaUnloaded( Schema schema )
{
this.loadedSchemas.remove( Strings.toLowerCaseAscii( schema.getSchemaName() ) );
@@ -1528,7 +1533,7 @@
*/
public Set<SchemaObjectWrapper> addSchema( String schemaName )
{
- Set<SchemaObjectWrapper> content = new HashSet<SchemaObjectWrapper>();
+ Set<SchemaObjectWrapper> content = new HashSet<>();
schemaObjects.put( schemaName, content );
return content;
@@ -1543,18 +1548,13 @@
LOG.debug( "Registering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
// Check that the SchemaObject is not already registered
- // TODO : Check for existing Loadable SchemaObject
- if ( !( schemaObject instanceof LoadableSchemaObject ) )
+ if ( !( schemaObject instanceof LoadableSchemaObject ) && globalOidRegistry.contains( schemaObject.getOid() ) )
{
- if ( globalOidRegistry.contains( schemaObject.getOid() ) )
- {
- // TODO : throw an exception here
- String msg = I18n.err( I18n.ERR_04301, schemaObject.getObjectType(), schemaObject.getOid() );
- LOG.error( msg );
- Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
- errors.add( error );
- return;
- }
+ String msg = I18n.err( I18n.ERR_04301, schemaObject.getObjectType(), schemaObject.getOid() );
+ LOG.error( msg );
+ Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
+ errors.add( error );
+ return;
}
try
@@ -1631,11 +1631,11 @@
// Check that the SchemaObject is not already registered
if ( !( schemaObject instanceof LoadableSchemaObject ) && globalOidRegistry.contains( schemaObject.getOid() ) )
{
- // TODO : throw an exception here
String msg = I18n.err( I18n.ERR_04301, schemaObject.getObjectType(), schemaObject.getOid() );
LOG.error( msg );
Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
errors.add( error );
+
return;
}
@@ -1647,7 +1647,7 @@
if ( content == null )
{
- content = new HashSet<SchemaObjectWrapper>();
+ content = new HashSet<>();
schemaObjects.put( Strings.toLowerCaseAscii( schemaName ), content );
}
@@ -1701,11 +1701,11 @@
// Check that the SchemaObject is already registered
if ( !( schemaObject instanceof LoadableSchemaObject ) && !globalOidRegistry.contains( schemaObject.getOid() ) )
{
- // TODO : throw an exception here
String msg = I18n.err( I18n.ERR_04302, schemaObject.getObjectType(), schemaObject.getOid() );
LOG.error( msg );
Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
errors.add( error );
+
return;
}
@@ -1761,19 +1761,14 @@
LOG.debug( "Unregistering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
// Check that the SchemaObject is present in the registries
- // TODO : check for an existing Loadable SchemaObject
- if ( !( schemaObject instanceof LoadableSchemaObject ) )
+ if ( !( schemaObject instanceof LoadableSchemaObject ) && !globalOidRegistry.contains( schemaObject.getOid() ) )
{
- if ( !globalOidRegistry.contains( schemaObject.getOid() ) )
- {
- // TODO : throw an exception here
- String msg = I18n.err( I18n.ERR_04302, schemaObject.getObjectType(), schemaObject.getOid() );
- LOG.error( msg );
- throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
- }
+ String msg = I18n.err( I18n.ERR_04302, schemaObject.getObjectType(), schemaObject.getOid() );
+ LOG.error( msg );
+ throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg );
}
- SchemaObject unregistered = null;
+ SchemaObject unregistered;
// First call the specific registry's register method
switch ( schemaObject.getObjectType() )
@@ -1883,7 +1878,7 @@
Set<SchemaObjectWrapper> set = usedBy.get( wrapper );
- boolean referenced = ( set != null ) && ( set.size() != 0 );
+ boolean referenced = ( set != null ) && !set.isEmpty();
if ( LOG.isDebugEnabled() )
{
@@ -2044,7 +2039,7 @@
if ( uses == null )
{
- uses = new HashSet<SchemaObjectWrapper>();
+ uses = new HashSet<>();
}
uses.add( new SchemaObjectWrapper( referee ) );
@@ -2099,7 +2094,7 @@
if ( uses == null )
{
- uses = new HashSet<SchemaObjectWrapper>();
+ uses = new HashSet<>();
}
uses.add( new SchemaObjectWrapper( reference ) );
@@ -2133,7 +2128,7 @@
SchemaObjectWrapper wrapper = new SchemaObjectWrapper( reference );
- if ( uses.size() == 0 )
+ if ( uses.isEmpty() )
{
using.remove( wrapper );
}
@@ -2168,7 +2163,7 @@
SchemaObjectWrapper wrapper = new SchemaObjectWrapper( referee );
- if ( uses.size() == 0 )
+ if ( uses.isEmpty() )
{
usedBy.remove( wrapper );
}
@@ -2544,6 +2539,7 @@
* - second restore the relation between them
*/
// False positive
+ @Override
public Registries clone() throws CloneNotSupportedException
{
// First clone the structure
@@ -2607,7 +2603,7 @@
}
// Clone the schema list
- clone.loadedSchemas = new HashMap<String, Schema>();
+ clone.loadedSchemas = new HashMap<>();
for ( Map.Entry<String, Set<SchemaObjectWrapper>> entry : schemaObjects.entrySet() )
{
@@ -2617,8 +2613,8 @@
// Clone the Using and usedBy structures
// They will be empty
- clone.using = new HashMap<SchemaObjectWrapper, Set<SchemaObjectWrapper>>();
- clone.usedBy = new HashMap<SchemaObjectWrapper, Set<SchemaObjectWrapper>>();
+ clone.using = new HashMap<>();
+ clone.usedBy = new HashMap<>();
// Last, rebuild the using and usedBy references
clone.buildReferences();
@@ -2626,13 +2622,13 @@
// Now, check the registries. We don't care about errors
clone.checkRefInteg();
- clone.schemaObjects = new HashMap<String, Set<SchemaObjectWrapper>>();
+ clone.schemaObjects = new HashMap<>();
// Last, not least, clone the SchemaObjects Map, and reference all the copied
// SchemaObjects
for ( Map.Entry<String, Set<SchemaObjectWrapper>> entry : schemaObjects.entrySet() )
{
- Set<SchemaObjectWrapper> objects = new HashSet<SchemaObjectWrapper>();
+ Set<SchemaObjectWrapper> objects = new HashSet<>();
for ( SchemaObjectWrapper schemaObjectWrapper : entry.getValue() )
{
@@ -2878,6 +2874,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SyntaxCheckerRegistry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SyntaxCheckerRegistry.java
index 13ca103..bc5920a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SyntaxCheckerRegistry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/SyntaxCheckerRegistry.java
@@ -39,6 +39,7 @@
* @throws LdapException if the SyntaxChecker is already registered or
* the registration operation is not supported
*/
+ @Override
void register( SyntaxChecker syntaxChecker ) throws LdapException;
@@ -49,6 +50,7 @@
* @param numericOid the numeric identifier
* @throws LdapException if the numeric identifier is invalid
*/
+ @Override
SyntaxChecker unregister( String numericOid ) throws LdapException;
@@ -58,11 +60,13 @@
*
* @param schemaName the name of the schema whose SyntaxCheckers will be removed from
*/
+ @Override
void unregisterSchemaElements( String schemaName ) throws LdapException;
/**
* Copy the SyntaxCheckerRegistry
*/
+ @Override
SyntaxCheckerRegistry copy();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/AttributeTypeHelper.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/AttributeTypeHelper.java
index 3b8944f..98fc64e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/AttributeTypeHelper.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/AttributeTypeHelper.java
@@ -45,13 +45,13 @@
*/
public final class AttributeTypeHelper
{
+ /** A logger for this class */
+ private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeHelper.class );
+
private AttributeTypeHelper()
{
}
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeHelper.class );
-
/**
* Inject the AttributeType into the Registries, updating the references to
* other SchemaObject
@@ -148,7 +148,7 @@
*/
private static boolean buildSuperior( MutableAttributeType attributeType, List<Throwable> errors, Registries registries )
{
- MutableAttributeType currentSuperior = null;
+ MutableAttributeType currentSuperior;
AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
String superiorOid = attributeType.getSuperiorOid();
@@ -217,7 +217,7 @@
}
// Check for cycles now
- Set<String> superiors = new HashSet<String>();
+ Set<String> superiors = new HashSet<>();
superiors.add( attributeType.getOid() );
AttributeType tmp = currentSuperior;
boolean isOk = true;
@@ -329,7 +329,23 @@
// We inherit from the superior's syntax, if any
if ( attributeType.getSuperior() != null )
{
- attributeType.setSyntax( attributeType.getSuperior().getSyntax() );
+ if ( attributeType.getSuperior().getSyntax() != null )
+ {
+ attributeType.setSyntax( attributeType.getSuperior().getSyntax() );
+ }
+ else
+ {
+ String msg = I18n.err( I18n.ERR_04306, syntaxOid, attributeType.getName() );
+
+ LdapSchemaException ldapSchemaException = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_SYNTAX, msg );
+ ldapSchemaException.setSourceObject( attributeType );
+ ldapSchemaException.setRelatedId( syntaxOid );
+ errors.add( ldapSchemaException );
+ LOG.info( msg );
+
+ return;
+ }
}
else
{
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
index 29e4e63..8d4a9bd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
@@ -70,7 +70,7 @@
catch ( LdapException ne )
{
// No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
- syntaxChecker = new OctetStringSyntaxChecker( ldapSyntax.getOid() );
+ syntaxChecker = OctetStringSyntaxChecker.builder().setOid( ldapSyntax.getOid() ).build();
}
// Add the references for S :
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AccessPointSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AccessPointSyntaxChecker.java
index 6c3abbf..da9212d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AccessPointSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AccessPointSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class AccessPointSyntaxChecker extends SyntaxChecker
+public final class AccessPointSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( AccessPointSyntaxChecker.class );
-
+ /**
+ * A static instance of AccessPointSyntaxChecker
+ */
+ public static final AccessPointSyntaxChecker INSTANCE =
+ new AccessPointSyntaxChecker( SchemaConstants.ACCESS_POINT_SYNTAX );
/**
- * The AccessPoint SyntaxChecker constructor
+ * A static Builder for this class
*/
- public AccessPointSyntaxChecker()
+ public static final class Builder extends SCBuilder<AccessPointSyntaxChecker>
{
- super( SchemaConstants.ACCESS_POINT_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.ACCESS_POINT_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of AccessPointSyntaxChecker
+ * @return A new instance of AccessPointSyntaxChecker
+ */
+ @Override
+ public AccessPointSyntaxChecker build()
+ {
+ return new AccessPointSyntaxChecker( oid );
+ }
}
/**
- * {@inheritDoc}
+ * The AccessPoint SyntaxChecker constructor
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private AccessPointSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeDescriptionSyntaxChecker.java
index d842c28..2c7d220 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeDescriptionSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -65,43 +64,84 @@
* COLLECTIVE requires usage userApplications.
*
* NO-USER-MODIFICATION requires an operational usage.
- *
- *
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class AttributeTypeDescriptionSyntaxChecker extends SyntaxChecker
+public final class AttributeTypeDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the AttributeTypeDescription Syntax */
- private AttributeTypeDescriptionSchemaParser schemaParser = new AttributeTypeDescriptionSchemaParser();
+ private transient AttributeTypeDescriptionSchemaParser schemaParser = new AttributeTypeDescriptionSchemaParser();
+
+ /**
+ * A static instance of AttributeTypeDescriptionSyntaxChecker
+ */
+ public static final AttributeTypeDescriptionSyntaxChecker INSTANCE = new AttributeTypeDescriptionSyntaxChecker(
+ SchemaConstants.ATTRIBUTE_TYPE_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<AttributeTypeDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.ATTRIBUTE_TYPE_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of AttributeTypeDescriptionSyntaxChecker
+ * @return A new instance of AttributeTypeDescriptionSyntaxChecker
+ */
+ @Override
+ public AttributeTypeDescriptionSyntaxChecker build()
+ {
+ return new AttributeTypeDescriptionSyntaxChecker( oid );
+ }
+ }
/**
- *
* Creates a new instance of AttributeTypeDescriptionSchemaParser.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*
*/
- public AttributeTypeDescriptionSyntaxChecker()
+ private AttributeTypeDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.ATTRIBUTE_TYPE_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -121,12 +161,21 @@
try
{
schemaParser.parseAttributeTypeDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeUsageSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeUsageSyntaxChecker.java
index f00c93a..d5e4eac 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeUsageSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AttributeTypeUsageSyntaxChecker.java
@@ -20,51 +20,95 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A syntax checker which checks to see if an attributeType's type is either:
- * userApplications
- * directoryOperation
- * distributedOperation
- * dSAOperation
-.* The case is NOT ignored.
+ * <ul>
+ * <li>userApplications</li>
+ * <lidirectoryOperation</li>
+ * <lidistributedOperation</li>
+ * <lidSAOperation</li>
+ * </ul>
+.*
+ * The case is NOT ignored.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class AttributeTypeUsageSyntaxChecker extends SyntaxChecker
+public final class AttributeTypeUsageSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeUsageSyntaxChecker.class );
+ /**
+ * A static instance of AttributeTypeUsageSyntaxChecker
+ */
+ public static final AttributeTypeUsageSyntaxChecker INSTANCE =
+ new AttributeTypeUsageSyntaxChecker( SchemaConstants.ATTRIBUTE_TYPE_USAGE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<AttributeTypeUsageSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.ATTRIBUTE_TYPE_USAGE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of AttributeTypeUsageSyntaxChecker
+ * @return A new instance of AttributeTypeUsageSyntaxChecker
+ */
+ @Override
+ public AttributeTypeUsageSyntaxChecker build()
+ {
+ return new AttributeTypeUsageSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of AttributeTypeUsageSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private AttributeTypeUsageSyntaxChecker( String oid )
+ {
+ super( oid );
+ }
/**
- *
- * Creates a new instance of AttributeTypeUsageSyntaxChecker.
- *
+ * @return An instance of the Builder for this class
*/
- public AttributeTypeUsageSyntaxChecker()
+ public static Builder builder()
{
- super( SchemaConstants.ATTRIBUTE_TYPE_USAGE_SYNTAX );
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -81,46 +125,25 @@
strValue = value.toString();
}
- if ( ( strValue.length() < "userApplications".length() )
- || ( strValue.length() > "userApplications".length() ) )
+ switch ( strValue )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
-
- char ch = strValue.charAt( 0 );
-
- switch ( ch )
- {
- case ( 'd' ):
- if ( "dSAOperation".equals( strValue )
- || "directoryOperation".equals( strValue )
- || "distributedOperation".equals( strValue ) )
+ case "dSAOperation" :
+ case "directoryOperation" :
+ case "distributedOperation" :
+ case "userApplications" :
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
}
+
+ return true;
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
-
- case ( 'u' ):
- boolean comp = "userApplications".equals( strValue );
-
- if ( comp )
+ default :
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
}
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
-
- }
-
- return comp;
-
- default:
- LOG.debug( "Syntax invalid for '{}'", value );
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AudioSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AudioSyntaxChecker.java
index 218341d..3cd7d41 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AudioSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/AudioSyntaxChecker.java
@@ -21,44 +21,72 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is an Audio according to RFC 2252.
*
+ * <pre>
* The encoding of a value with Audio syntax is the octets of the value
* itself, an 8KHz uncompressed encoding compatible with the SunOS
* 4.1.3 'play' utility. We implement it as a binary element.
+ * </pre>
*
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class AudioSyntaxChecker extends BinarySyntaxChecker
+public final class AudioSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( AudioSyntaxChecker.class );
-
+ /**
+ * A static instance of AudioSyntaxChecker
+ */
+ public static final AudioSyntaxChecker INSTANCE = new AudioSyntaxChecker( SchemaConstants.AUDIO_SYNTAX );
/**
- * Creates a new instance of AudioSyntaxChecker
+ * A static Builder for this class
*/
- public AudioSyntaxChecker()
+ public static final class Builder extends SCBuilder<AudioSyntaxChecker>
{
- super();
- setOid( SchemaConstants.AUDIO_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.AUDIO_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of AudioSyntaxChecker
+ * @return A new instance of AudioSyntaxChecker
+ */
+ @Override
+ public AudioSyntaxChecker build()
+ {
+ return new AudioSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of AudioSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private AudioSyntaxChecker( String oid )
+ {
+ super( oid );
}
/**
- * {@inheritDoc}
+ * @return An instance of the Builder for this class
*/
- public boolean isValidSyntax( Object value )
+ public static Builder builder()
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BinarySyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BinarySyntaxChecker.java
index 9df5238..d36b594 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BinarySyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BinarySyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,54 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class BinarySyntaxChecker extends SyntaxChecker
+public final class BinarySyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( BinarySyntaxChecker.class );
-
+ /**
+ * A static instance of BinarySyntaxChecker
+ */
+ public static final BinarySyntaxChecker INSTANCE = new BinarySyntaxChecker( SchemaConstants.BINARY_SYNTAX );
/**
- * Creates a new instance of BinarySyntaxChecker
+ * A static Builder for this class
*/
- public BinarySyntaxChecker()
+ public static final class Builder extends SCBuilder<BinarySyntaxChecker>
{
- super( SchemaConstants.BINARY_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.ACCESS_POINT_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of BinarySyntaxChecker
+ * @return A new instance of BinarySyntaxChecker
+ */
+ @Override
+ public BinarySyntaxChecker build()
+ {
+ return new BinarySyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of the child class
+ * @param oid The child's OID
+ */
+ private BinarySyntaxChecker( String oid )
+ {
+ super( oid );
}
/**
- * {@inheritDoc}
+ * @return An instance of the Builder for this class
*/
- public boolean isValidSyntax( Object value )
+ public static Builder builder()
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BitStringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BitStringSyntaxChecker.java
index 3b898f6..a1f6cbe 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BitStringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BitStringSyntaxChecker.java
@@ -20,12 +20,11 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -41,20 +40,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class BitStringSyntaxChecker extends SyntaxChecker
+public final class BitStringSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( BitStringSyntaxChecker.class );
+ /**
+ * A static instance of BitStringSyntaxChecker
+ */
+ public static final BitStringSyntaxChecker INSTANCE = new BitStringSyntaxChecker( SchemaConstants.BIT_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<BitStringSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.BIT_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of BitStringSyntaxChecker
+ * @return A new instance of BitStringSyntaxChecker
+ */
+ @Override
+ public BitStringSyntaxChecker build()
+ {
+ return new BitStringSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of BitStringSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private BitStringSyntaxChecker( String oid )
+ {
+ super( oid );
+ }
/**
- *
- * Creates a new instance of BitStringSyntaxChecker.
- *
+ * @return An instance of the Builder for this class
*/
- public BitStringSyntaxChecker()
+ public static Builder builder()
{
- super( SchemaConstants.BIT_STRING_SYNTAX );
+ return new Builder();
}
@@ -71,7 +106,11 @@
{
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
@@ -80,14 +119,22 @@
// Check that the String respect the syntax : ' ([01]+) ' B
if ( !Strings.isCharASCII( strValue, pos++, '\'' ) )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
// We must have at least one bit
if ( !Chars.isBit( strValue, pos++ ) )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
@@ -100,18 +147,30 @@
// Now, we must have a simple quote
if ( !Strings.isCharASCII( strValue, pos++, '\'' ) )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
// followed by a 'B'
if ( !Strings.isCharASCII( strValue, pos, 'B' ) )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
- LOG.debug( "Syntax valid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, strValue ) );
+ }
+
return true;
}
@@ -119,13 +178,18 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BooleanSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BooleanSyntaxChecker.java
index 511c2f2..b4f963e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BooleanSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/BooleanSyntaxChecker.java
@@ -20,49 +20,92 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Boolean according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
*
+ * <pre>
* Boolean = "TRUE" / "FALSE"
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class BooleanSyntaxChecker extends SyntaxChecker
+public final class BooleanSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( BooleanSyntaxChecker.class );
+ /**
+ * A static instance of BooleanSyntaxChecker
+ */
+ public static final BooleanSyntaxChecker INSTANCE = new BooleanSyntaxChecker( SchemaConstants.BOOLEAN_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<BooleanSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.BOOLEAN_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of BooleanSyntaxChecker
+ * @return A new instance of BooleanSyntaxChecker
+ */
+ @Override
+ public BooleanSyntaxChecker build()
+ {
+ return new BooleanSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of BooleanSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public BooleanSyntaxChecker()
+ private BooleanSyntaxChecker( String oid )
{
- super( SchemaConstants.BOOLEAN_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -81,19 +124,26 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
+
return false;
}
- boolean valid = ( ( "TRUE".equalsIgnoreCase( strValue ) ) || ( "FALSE".equalsIgnoreCase( strValue ) ) );
+ boolean valid = "TRUE".equalsIgnoreCase( strValue ) || "FALSE".equalsIgnoreCase( strValue );
- if ( valid )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", strValue );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", strValue );
+ if ( valid )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, strValue ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
}
return valid;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateListSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateListSyntaxChecker.java
index af5aa43..9937cc5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateListSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateListSyntaxChecker.java
@@ -21,46 +21,75 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a certificateList according to RFC 4523 :
*
+ * <pre>
* "Due to changes made to the definition of a CertificateList through time,
* no LDAP-specific encoding is defined for this syntax. Values of this
* syntax SHOULD be encoded using Distinguished Encoding Rules (DER)
* [X.690] and MUST only be transferred using the ;binary transfer
* option"
+ * </pre>
*
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CertificateListSyntaxChecker extends BinarySyntaxChecker
+public final class CertificateListSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CertificateListSyntaxChecker.class );
-
-
/**
- * Creates a new instance of CertificateListSyntaxChecker.
+ * A static instance of CertificateListSyntaxChecker
*/
- public CertificateListSyntaxChecker()
+ public static final CertificateListSyntaxChecker INSTANCE = new CertificateListSyntaxChecker(
+ SchemaConstants.CERTIFICATE_LIST_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CertificateListSyntaxChecker>
{
- super();
- setOid( SchemaConstants.CERTIFICATE_LIST_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.BOOLEAN_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CertificateListSyntaxChecker
+ * @return A new instance of CertificateListSyntaxChecker
+ */
+ @Override
+ public CertificateListSyntaxChecker build()
+ {
+ return new CertificateListSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of CertificateListSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private CertificateListSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificatePairSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificatePairSyntaxChecker.java
index 70982f4..a68d331 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificatePairSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificatePairSyntaxChecker.java
@@ -21,46 +21,75 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a certificate pair according to RFC 4523 :
*
+ * <pre>
* "Due to changes made to the definition of a CertificatePair through time,
* no LDAP-specific encoding is defined for this syntax. Values of this
* syntax SHOULD be encoded using Distinguished Encoding Rules (DER)
* [X.690] and MUST only be transferred using the ;binary transfer
* option"
+ * </pre>
*
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CertificatePairSyntaxChecker extends BinarySyntaxChecker
+public final class CertificatePairSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CertificatePairSyntaxChecker.class );
-
-
/**
- * Creates a new instance of CertificatePairSyntaxChecker.
+ * A static instance of CertificatePairSyntaxChecker
*/
- public CertificatePairSyntaxChecker()
+ public static final CertificatePairSyntaxChecker INSTANCE = new CertificatePairSyntaxChecker(
+ SchemaConstants.CERTIFICATE_PAIR_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CertificatePairSyntaxChecker>
{
- super();
- setOid( SchemaConstants.CERTIFICATE_PAIR_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.CERTIFICATE_PAIR_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CertificatePairSyntaxChecker
+ * @return A new instance of CertificatePairSyntaxChecker
+ */
+ @Override
+ public CertificatePairSyntaxChecker build()
+ {
+ return new CertificatePairSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of CertificatePairSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private CertificatePairSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateSyntaxChecker.java
index 516b892..44dafde 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CertificateSyntaxChecker.java
@@ -21,46 +21,75 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a certificate according to RFC 4523 :
*
+ * <pre>
* "Due to changes made to the definition of a Certificate through time,
* no LDAP-specific encoding is defined for this syntax. Values of this
* syntax SHOULD be encoded using Distinguished Encoding Rules (DER)
* [X.690] and MUST only be transferred using the ;binary transfer
* option"
+ * </pre>
*
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CertificateSyntaxChecker extends BinarySyntaxChecker
+public final class CertificateSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CertificateSyntaxChecker.class );
-
-
/**
- * Creates a new instance of CertificateSyntaxChecker.
+ * A static instance of CertificateSyntaxChecker
*/
- public CertificateSyntaxChecker()
+ public static final CertificateSyntaxChecker INSTANCE = new CertificateSyntaxChecker(
+ SchemaConstants.CERTIFICATE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CertificateSyntaxChecker>
{
- super();
- setOid( SchemaConstants.CERTIFICATE_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.CERTIFICATE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CertificateSyntaxChecker
+ * @return A new instance of CertificateSyntaxChecker
+ */
+ @Override
+ public CertificateSyntaxChecker build()
+ {
+ return new CertificateSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of CertificateSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private CertificateSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ComparatorSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ComparatorSyntaxChecker.java
index 895ad64..4f5fda2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ComparatorSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ComparatorSyntaxChecker.java
@@ -20,7 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.util.Strings;
/**
@@ -29,16 +32,104 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ComparatorSyntaxChecker extends Ia5StringSyntaxChecker
+public final class ComparatorSyntaxChecker extends SyntaxChecker
{
/**
- *
+ * A static instance of ComparatorSyntaxChecker
+ */
+ public static final ComparatorSyntaxChecker INSTANCE = new ComparatorSyntaxChecker( SchemaConstants.COMPARATOR_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ComparatorSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.COMPARATOR_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of ComparatorSyntaxChecker
+ * @return A new instance of ComparatorSyntaxChecker
+ */
+ @Override
+ public ComparatorSyntaxChecker build()
+ {
+ return new ComparatorSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of ComparatorSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public ComparatorSyntaxChecker()
+ private ComparatorSyntaxChecker( String oid )
{
- super();
- setOid( SchemaConstants.COMPARATOR_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValidSyntax( Object value )
+ {
+ String strValue;
+
+ if ( value == null )
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
+ return true;
+ }
+
+ if ( value instanceof String )
+ {
+ strValue = ( String ) value;
+ }
+ else if ( value instanceof byte[] )
+ {
+ strValue = Strings.utf8ToString( ( byte[] ) value );
+ }
+ else
+ {
+ strValue = value.toString();
+ }
+
+ boolean result = Strings.isIA5String( strValue );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ }
+
+ return result;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CountrySyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CountrySyntaxChecker.java
index b6e63f2..3f7a339 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CountrySyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CountrySyntaxChecker.java
@@ -23,11 +23,10 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -35,18 +34,16 @@
*
* From RFC 4517 :
*
+ * <pre>
* A value of the Country String syntax is one of the two-character
* codes from ISO 3166 [ISO3166] for representing a country.
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CountrySyntaxChecker extends SyntaxChecker
+public final class CountrySyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CountrySyntaxChecker.class );
-
/** The ISO 3166 list of countries, as of 2006 */
private static final String[] COUNTRY_ISO_3166 =
{
@@ -297,7 +294,7 @@
};
/** The Set which contains the countries */
- private static final Set<String> COUNTRIES = new HashSet<String>();
+ private static final Set<String> COUNTRIES = new HashSet<>();
/** Initialization of the country set */
static
@@ -307,29 +304,73 @@
COUNTRIES.add( country );
}
}
+
+ /**
+ * A static instance of CountrySyntaxChecker
+ */
+ public static final CountrySyntaxChecker INSTANCE = new CountrySyntaxChecker( SchemaConstants.COUNTRY_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CountrySyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.COUNTRY_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CountrySyntaxChecker
+ * @return A new instance of CountrySyntaxChecker
+ */
+ @Override
+ public CountrySyntaxChecker build()
+ {
+ return new CountrySyntaxChecker( oid );
+ }
+ }
/**
- *
* Creates a new instance of CountrySyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public CountrySyntaxChecker()
+ private CountrySyntaxChecker( String oid )
{
- super( SchemaConstants.COUNTRY_STRING_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -348,19 +389,26 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
boolean result = COUNTRIES.contains( Strings.toUpperCaseAscii( strValue ) );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSidSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSidSyntaxChecker.java
index 8409870..fda27df 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSidSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSidSyntaxChecker.java
@@ -20,10 +20,9 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,35 +31,82 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CsnSidSyntaxChecker extends SyntaxChecker
+public final class CsnSidSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CsnSidSyntaxChecker.class );
+ /**
+ * A static instance of CsnSidSyntaxChecker
+ */
+ public static final CsnSidSyntaxChecker INSTANCE = new CsnSidSyntaxChecker( SchemaConstants.CSN_SID_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CsnSidSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.CSN_SID_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CsnSidSyntaxChecker
+ * @return A new instance of CsnSidSyntaxChecker
+ */
+ @Override
+ public CsnSidSyntaxChecker build()
+ {
+ return new CsnSidSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of CsnSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public CsnSidSyntaxChecker()
+ private CsnSidSyntaxChecker( String oid )
{
- super( SchemaConstants.CSN_SID_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
if ( !( value instanceof String ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -68,7 +114,11 @@
if ( sidStr.length() > 3 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -80,17 +130,29 @@
if ( ( sid < 0 ) || ( sid > 0x0fff ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
catch ( NumberFormatException nfe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSyntaxChecker.java
index 780e410..09bffee 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/CsnSyntaxChecker.java
@@ -20,12 +20,11 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.csn.Csn;
import org.apache.directory.api.ldap.model.csn.InvalidCSNException;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -34,35 +33,82 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class CsnSyntaxChecker extends SyntaxChecker
+public final class CsnSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( CsnSyntaxChecker.class );
+ /**
+ * A static instance of CsnSyntaxChecker
+ */
+ public static final CsnSyntaxChecker INSTANCE = new CsnSyntaxChecker( SchemaConstants.CSN_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<CsnSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.CSN_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of CsnSyntaxChecker
+ * @return A new instance of CsnSyntaxChecker
+ */
+ @Override
+ public CsnSyntaxChecker build()
+ {
+ return new CsnSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of CsnSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public CsnSyntaxChecker()
+ private CsnSyntaxChecker( String oid )
{
- super( SchemaConstants.CSN_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
if ( !( value instanceof String ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -73,20 +119,27 @@
{
boolean result = Csn.isValid( csnStr );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
}
catch ( InvalidCSNException icsne )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DataQualitySyntaxSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DataQualitySyntaxSyntaxChecker.java
index 3819b11..e390e63 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DataQualitySyntaxSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DataQualitySyntaxSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DataQualitySyntaxSyntaxChecker extends SyntaxChecker
+public final class DataQualitySyntaxSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DataQualitySyntaxSyntaxChecker.class );
-
-
/**
- * Creates a new instance of DataQualitySyntaxSyntaxChecker.
+ * A static instance of DataQualitySyntaxSyntaxChecker
*/
- public DataQualitySyntaxSyntaxChecker()
+ public static final DataQualitySyntaxSyntaxChecker INSTANCE =
+ new DataQualitySyntaxSyntaxChecker( SchemaConstants.DATA_QUALITY_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DataQualitySyntaxSyntaxChecker>
{
- super( SchemaConstants.DATA_QUALITY_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DATA_QUALITY_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DataQualitySyntaxSyntaxChecker
+ * @return A new instance of DataQualitySyntaxSyntaxChecker
+ */
+ @Override
+ public DataQualitySyntaxSyntaxChecker build()
+ {
+ return new DataQualitySyntaxSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of DataQualitySyntaxSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private DataQualitySyntaxSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DeliveryMethodSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DeliveryMethodSyntaxChecker.java
index 377ef57..25e0273 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DeliveryMethodSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DeliveryMethodSyntaxChecker.java
@@ -23,12 +23,11 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -50,19 +49,16 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DeliveryMethodSyntaxChecker extends SyntaxChecker
+public final class DeliveryMethodSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DeliveryMethodSyntaxChecker.class );
-
private static final String[] PDMS =
{
"any", "mhs", "physical", "telex", "teletex",
"g3fax", "g4fax", "ia5", "videotex", "telephone"
- };
+ };
/** The Set which contains the delivery methods */
- private static final Set<String> DELIVERY_METHODS = new HashSet<String>();
+ private static final Set<String> DELIVERY_METHODS = new HashSet<>();
/** Initialization of the delivery methods set */
static
@@ -72,16 +68,56 @@
DELIVERY_METHODS.add( country );
}
}
+
+ /**
+ * A static instance of DeliveryMethodSyntaxChecker
+ */
+ public static final DeliveryMethodSyntaxChecker INSTANCE =
+ new DeliveryMethodSyntaxChecker( SchemaConstants.DELIVERY_METHOD_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DeliveryMethodSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DELIVERY_METHOD_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DeliveryMethodSyntaxChecker
+ * @return A new instance of DeliveryMethodSyntaxChecker
+ */
+ @Override
+ public DeliveryMethodSyntaxChecker build()
+ {
+ return new DeliveryMethodSyntaxChecker( oid );
+ }
+ }
/**
- *
* Creates a new instance of DeliveryMethodSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DeliveryMethodSyntaxChecker()
+ private DeliveryMethodSyntaxChecker( String oid )
{
- super( SchemaConstants.DELIVERY_METHOD_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
@@ -137,13 +173,18 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -162,19 +203,28 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// We will get the first delivery method
int length = strValue.length();
int pos = 0;
- Set<String> pmds = new HashSet<String>();
+ Set<String> pmds = new HashSet<>();
pos = isPdm( strValue, pos, pmds );
+
if ( pos == -1 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -192,7 +242,11 @@
if ( !Strings.isCharASCII( strValue, pos, '$' ) )
{
// A '$' was expected
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -207,14 +261,23 @@
}
pos = isPdm( strValue, pos, pmds );
+
if ( pos == -1 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java
index 1884115..a3d9311 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java
@@ -20,11 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -41,31 +40,74 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DerefAliasSyntaxChecker extends SyntaxChecker
+public final class DerefAliasSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DerefAliasSyntaxChecker.class );
-
+ /**
+ * A static instance of DerefAliasSyntaxChecker
+ */
+ public static final DerefAliasSyntaxChecker INSTANCE =
+ new DerefAliasSyntaxChecker( SchemaConstants.DEREF_ALIAS_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DerefAliasSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DEREF_ALIAS_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DerefAliasSyntaxChecker
+ * @return A new instance of DerefAliasSyntaxChecker
+ */
+ @Override
+ public DerefAliasSyntaxChecker build()
+ {
+ return new DerefAliasSyntaxChecker( oid );
+ }
+ }
/**
* Creates a new instance of DerefAliasSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DerefAliasSyntaxChecker()
+ private DerefAliasSyntaxChecker( String oid )
{
- super( SchemaConstants.DEREF_ALIAS_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -84,7 +126,7 @@
strValue = Strings.trim( Strings.toLowerCaseAscii( strValue ) );
- return ( "never".equals( strValue ) || "finding".equals( strValue ) || "searching".equals( strValue ) || "always"
- .equals( strValue ) );
+ return "never".equals( strValue ) || "finding".equals( strValue ) || "searching".equals( strValue ) || "always"
+ .equals( strValue );
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DirectoryStringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DirectoryStringSyntaxChecker.java
index e8719843c..cf7a728 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DirectoryStringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DirectoryStringSyntaxChecker.java
@@ -20,47 +20,93 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Directory String according to RFC 4517.
*
* From RFC 4517 :
+ *
+ * <pre>
* DirectoryString = 1*UTF8
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DirectoryStringSyntaxChecker extends SyntaxChecker
+public final class DirectoryStringSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DirectoryStringSyntaxChecker.class );
+ /**
+ * A static instance of DirectoryStringSyntaxChecker
+ */
+ public static final DirectoryStringSyntaxChecker INSTANCE =
+ new DirectoryStringSyntaxChecker( SchemaConstants.DIRECTORY_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DirectoryStringSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DIRECTORY_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DirectoryStringSyntaxChecker
+ * @return A new instance of DirectoryStringSyntaxChecker
+ */
+ @Override
+ public DirectoryStringSyntaxChecker build()
+ {
+ return new DirectoryStringSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of DirectoryStringSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DirectoryStringSyntaxChecker()
+ private DirectoryStringSyntaxChecker( String oid )
{
- super( SchemaConstants.DIRECTORY_STRING_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -82,7 +128,11 @@
// return an empty string
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -92,12 +142,20 @@
{
if ( c == 0xFFFD )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitContentRuleDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitContentRuleDescriptionSyntaxChecker.java
index f2b7fb2..9181704 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitContentRuleDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitContentRuleDescriptionSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.DitContentRuleDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -50,34 +49,77 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DitContentRuleDescriptionSyntaxChecker extends SyntaxChecker
+public final class DitContentRuleDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DitContentRuleDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the DITContentRuleDescription Syntax */
- private DitContentRuleDescriptionSchemaParser schemaParser = new DitContentRuleDescriptionSchemaParser();
+ private transient DitContentRuleDescriptionSchemaParser schemaParser = new DitContentRuleDescriptionSchemaParser();
+
+ /**
+ * A static instance of DitContentRuleDescriptionSyntaxChecker
+ */
+ public static final DitContentRuleDescriptionSyntaxChecker INSTANCE =
+ new DitContentRuleDescriptionSyntaxChecker( SchemaConstants.DIT_CONTENT_RULE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DitContentRuleDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DIT_CONTENT_RULE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DitContentRuleDescriptionSyntaxChecker
+ * @return A new instance of DitContentRuleDescriptionSyntaxChecker
+ */
+ @Override
+ public DitContentRuleDescriptionSyntaxChecker build()
+ {
+ return new DitContentRuleDescriptionSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of DITContentRuleDescriptionSyntaxChecker.
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DitContentRuleDescriptionSyntaxChecker()
+ private DitContentRuleDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.DIT_CONTENT_RULE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -97,12 +139,21 @@
try
{
schemaParser.parseDITContentRuleDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitStructureRuleDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitStructureRuleDescriptionSyntaxChecker.java
index 4839d74..953a079 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitStructureRuleDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DitStructureRuleDescriptionSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.DitStructureRuleDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -52,34 +51,78 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DitStructureRuleDescriptionSyntaxChecker extends SyntaxChecker
+public final class DitStructureRuleDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DitStructureRuleDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the DITContentRuleDescription Syntax */
- private DitStructureRuleDescriptionSchemaParser schemaParser = new DitStructureRuleDescriptionSchemaParser();
+ private transient DitStructureRuleDescriptionSchemaParser schemaParser = new DitStructureRuleDescriptionSchemaParser();
+
+ /**
+ * A static instance of DitStructureRuleDescriptionSyntaxChecker
+ */
+ public static final DitStructureRuleDescriptionSyntaxChecker INSTANCE =
+ new DitStructureRuleDescriptionSyntaxChecker( SchemaConstants.DIT_STRUCTURE_RULE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DitStructureRuleDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DIT_STRUCTURE_RULE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DitStructureRuleDescriptionSyntaxChecker
+ * @return A new instance of DitStructureRuleDescriptionSyntaxChecker
+ */
+ @Override
+ public DitStructureRuleDescriptionSyntaxChecker build()
+ {
+ return new DitStructureRuleDescriptionSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of DITContentRuleDescriptionSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DitStructureRuleDescriptionSyntaxChecker()
+ private DitStructureRuleDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.DIT_STRUCTURE_RULE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -99,12 +142,21 @@
try
{
schemaParser.parseDITStructureRuleDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DlSubmitPermissionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DlSubmitPermissionSyntaxChecker.java
index 7d9058d..04f3349 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DlSubmitPermissionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DlSubmitPermissionSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DlSubmitPermissionSyntaxChecker extends SyntaxChecker
+public final class DlSubmitPermissionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DlSubmitPermissionSyntaxChecker.class );
-
-
/**
- * Creates a new instance of DLSubmitPermissionSyntaxChecker.
+ * A static instance of DlSubmitPermissionSyntaxChecker
*/
- public DlSubmitPermissionSyntaxChecker()
+ public static final DlSubmitPermissionSyntaxChecker INSTANCE =
+ new DlSubmitPermissionSyntaxChecker( SchemaConstants.DL_SUBMIT_PERMISSION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DlSubmitPermissionSyntaxChecker>
{
- super( SchemaConstants.DL_SUBMIT_PERMISSION_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DL_SUBMIT_PERMISSION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DlSubmitPermissionSyntaxChecker
+ * @return A new instance of DlSubmitPermissionSyntaxChecker
+ */
+ @Override
+ public DlSubmitPermissionSyntaxChecker build()
+ {
+ return new DlSubmitPermissionSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of DLSubmitPermissionSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private DlSubmitPermissionSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DnSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DnSyntaxChecker.java
index aa72a3c..6df5a4f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DnSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DnSyntaxChecker.java
@@ -20,46 +20,88 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * A SyntaxChecker which verifies that a value is a valid Dn. We just check
- * that the Dn is valid, we don't need to verify each of the Rdn syntax.
+ * A SyntaxChecker which verifies that a value is a valid {@link Dn}. We just check
+ * that the {@link Dn} is valid, we don't need to verify each of the {@link Rdn} syntax.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DnSyntaxChecker extends SyntaxChecker
+public final class DnSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DnSyntaxChecker.class );
+ /**
+ * A static instance of DnSyntaxChecker
+ */
+ public static final DnSyntaxChecker INSTANCE = new DnSyntaxChecker( SchemaConstants.DN_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DnSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DN_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DnSyntaxChecker
+ * @return A new instance of DnSyntaxChecker
+ */
+ @Override
+ public DnSyntaxChecker build()
+ {
+ return new DnSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of DNSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DnSyntaxChecker()
+ private DnSyntaxChecker( String oid )
{
- super( SchemaConstants.DN_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -81,20 +123,27 @@
// TODO: this should be a false, but for
// some reason, the principal is empty in
// some cases.
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, strValue ) );
+ }
+
return true;
}
// Check that the value is a valid Dn
boolean result = Dn.isValid( strValue );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, strValue ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, strValue ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DsaQualitySyntaxSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DsaQualitySyntaxSyntaxChecker.java
index 22c3000..207d0be 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DsaQualitySyntaxSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DsaQualitySyntaxSyntaxChecker.java
@@ -20,11 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -42,31 +41,75 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DsaQualitySyntaxSyntaxChecker extends SyntaxChecker
+public final class DsaQualitySyntaxSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DsaQualitySyntaxSyntaxChecker.class );
+ /**
+ * A static instance of DsaQualitySyntaxSyntaxChecker
+ */
+ public static final DsaQualitySyntaxSyntaxChecker INSTANCE =
+ new DsaQualitySyntaxSyntaxChecker( SchemaConstants.DSA_QUALITY_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DsaQualitySyntaxSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DSA_QUALITY_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DsaQualitySyntaxSyntaxChecker
+ * @return A new instance of DsaQualitySyntaxSyntaxChecker
+ */
+ @Override
+ public DsaQualitySyntaxSyntaxChecker build()
+ {
+ return new DsaQualitySyntaxSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of DSAQualitySyntaxSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DsaQualitySyntaxSyntaxChecker()
+ private DsaQualitySyntaxSyntaxChecker( String oid )
{
- super( SchemaConstants.DSA_QUALITY_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -85,18 +128,26 @@
if ( strValue.length() < 7 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- String remaining = null;
+ String remaining;
switch ( strValue.charAt( 0 ) )
{
case 'B':
if ( !strValue.startsWith( "BEST-EFFORT" ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -106,7 +157,11 @@
case 'D':
if ( !strValue.startsWith( "DEFUNCT" ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -116,7 +171,11 @@
case 'E':
if ( !strValue.startsWith( "EXPERIMENTAL" ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -126,7 +185,11 @@
case 'F':
if ( !strValue.startsWith( "FULL-SERVICE" ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -136,7 +199,11 @@
case 'P':
if ( !strValue.startsWith( "PILOT-SERVICE" ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -144,7 +211,11 @@
break;
default:
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -152,27 +223,38 @@
// but this is optional
if ( remaining.length() == 0 )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
if ( remaining.charAt( 0 ) != '#' )
{
// We were expecting a '#'
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Check that the description is a PrintableString
boolean result = Strings.isPrintableString( remaining.substring( 1 ) );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DseTypeSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DseTypeSyntaxChecker.java
index 252ff24..7c2e780 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DseTypeSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DseTypeSyntaxChecker.java
@@ -23,12 +23,11 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -45,11 +44,8 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class DseTypeSyntaxChecker extends SyntaxChecker
+public final class DseTypeSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( DseTypeSyntaxChecker.class );
-
/** The DSE BITS keywords */
private static final String[] DSE_BITS_STRINGS =
{
@@ -59,8 +55,39 @@
};
/** The Set which contains the DESBits */
- private static final Set<String> DSE_BITS = new HashSet<String>();
+ private static final Set<String> DSE_BITS = new HashSet<>();
+
+ /**
+ * A static instance of DseTypeSyntaxChecker
+ */
+ public static final DseTypeSyntaxChecker INSTANCE = new DseTypeSyntaxChecker( SchemaConstants.DSE_TYPE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<DseTypeSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DSE_TYPE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DseTypeSyntaxChecker
+ * @return A new instance of DseTypeSyntaxChecker
+ */
+ @Override
+ public DseTypeSyntaxChecker build()
+ {
+ return new DseTypeSyntaxChecker( oid );
+ }
+ }
+
/** Initialization of the country set */
static
{
@@ -72,26 +99,40 @@
/**
- *
* Creates a new instance of DSETypeSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public DseTypeSyntaxChecker()
+ private DseTypeSyntaxChecker( String oid )
{
- super( SchemaConstants.DSE_TYPE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -111,7 +152,11 @@
// We must have at least '(cp)', '(xr)' or '(ca)'
if ( strValue.length() < 4 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -119,11 +164,15 @@
if ( ( strValue.charAt( 0 ) != '(' )
|| ( strValue.charAt( strValue.length() - 1 ) != ')' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- Set<String> keywords = new HashSet<String>();
+ Set<String> keywords = new HashSet<>();
int len = strValue.length() - 1;
boolean needKeyword = true;
@@ -147,7 +196,11 @@
if ( pos == i )
{
// No keyword : error
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -157,14 +210,22 @@
if ( !DSE_BITS.contains( keyword ) )
{
// Unknown keyword
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Check that the keyword has not been met
if ( keywords.contains( keyword ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -188,13 +249,16 @@
}
// We are done
- if ( needKeyword )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( needKeyword )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
}
return !needKeyword;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/EnhancedGuideSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/EnhancedGuideSyntaxChecker.java
index 21d6a1e..02a3d43 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/EnhancedGuideSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/EnhancedGuideSyntaxChecker.java
@@ -21,8 +21,7 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
@@ -34,28 +33,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class EnhancedGuideSyntaxChecker extends BinarySyntaxChecker
+public final class EnhancedGuideSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( EnhancedGuideSyntaxChecker.class );
-
-
/**
- * Creates a new instance of EnhancedGuideSyntaxChecker.
+ * A static instance of EnhancedGuideSyntaxChecker
*/
- public EnhancedGuideSyntaxChecker()
+ public static final EnhancedGuideSyntaxChecker INSTANCE =
+ new EnhancedGuideSyntaxChecker( SchemaConstants.ENHANCED_GUIDE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<EnhancedGuideSyntaxChecker>
{
- super();
- setOid( SchemaConstants.ENHANCED_GUIDE_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.DIRECTORY_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of EnhancedGuideSyntaxChecker
+ * @return A new instance of EnhancedGuideSyntaxChecker
+ */
+ @Override
+ public EnhancedGuideSyntaxChecker build()
+ {
+ return new EnhancedGuideSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of EnhancedGuideSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private EnhancedGuideSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
index 506cce3..31840bd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
@@ -22,11 +22,13 @@
import java.util.HashSet;
import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -34,6 +36,7 @@
* to ITU recommendation E.123 for the Telephone number part, and from RFC 4517, par.
* 3.3.11 :
*
+ * <pre>
* fax-number = telephone-number *( DOLLAR fax-parameter )
* telephone-number = PrintableString
* fax-parameter = "twoDimensional" |
@@ -43,7 +46,7 @@
* "a3Width" |
* "b4Width" |
* "uncompressed"
- *
+ * </pre>
*
* If needed, and to allow more syntaxes, a list of regexps has been added
* which can be initialized to other values
@@ -51,11 +54,17 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class FacsimileTelephoneNumberSyntaxChecker extends TelephoneNumberSyntaxChecker
+public final class FacsimileTelephoneNumberSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( FacsimileTelephoneNumberSyntaxChecker.class );
+ /** The default pattern used to check a TelephoneNumber */
+ private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;/#*]+\\))|[0-9- ,;/#*]+)+$";
+
+ /** The default pattern */
+ private final String defaultRegexp;
+ /** The compiled default pattern */
+ private Pattern defaultPattern;
+
/** Fax parameters possible values */
private static final String TWO_DIMENSIONAL = "twoDimensional";
private static final String FINE_RESOLUTION = "fineResolution";
@@ -65,8 +74,8 @@
private static final String B4_WIDTH = "b4Width";
private static final String UNCOMPRESSED = "uncompressed";
- /** A set which contaons all the possible fax parameters values */
- private static Set<String> faxParameters = new HashSet<String>();
+ /** A set which contains all the possible fax parameters values */
+ private static Set<String> faxParameters = new HashSet<>();
/** Initialization of the fax parameters set of values */
static
@@ -79,28 +88,132 @@
faxParameters.add( Strings.toLowerCaseAscii( B4_WIDTH ) );
faxParameters.add( Strings.toLowerCaseAscii( UNCOMPRESSED ) );
}
+
+ /**
+ * A static instance of FacsimileTelephoneNumberSyntaxChecker
+ */
+ public static final FacsimileTelephoneNumberSyntaxChecker INSTANCE =
+ new FacsimileTelephoneNumberSyntaxChecker( SchemaConstants.FACSIMILE_TELEPHONE_NUMBER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<FacsimileTelephoneNumberSyntaxChecker>
+ {
+ /** The compiled default pattern */
+ private String defaultRegexp;
+
+ /** The compiled default pattern */
+ private Pattern defaultPattern;
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.FACSIMILE_TELEPHONE_NUMBER_SYNTAX );
+ setDefaultRegexp( DEFAULT_REGEXP );
+ }
+
+
+ /**
+ * Create a new instance of FacsimileTelephoneNumberSyntaxChecker
+ * @return A new instance of FacsimileTelephoneNumberSyntaxChecker
+ */
+ @Override
+ public FacsimileTelephoneNumberSyntaxChecker build()
+ {
+ return new FacsimileTelephoneNumberSyntaxChecker( oid, defaultRegexp, defaultPattern );
+ }
+
+
+ /**
+ * Set the default regular expression for the Telephone number
+ *
+ * @param regexp the default regular expression.
+ */
+ public Builder setDefaultRegexp( String regexp )
+ {
+ defaultRegexp = regexp;
+
+ try
+ {
+ defaultPattern = Pattern.compile( regexp );
+ }
+ catch ( PatternSyntaxException pse )
+ {
+ // Roll back to the default pattern
+ defaultPattern = Pattern.compile( DEFAULT_REGEXP );
+ }
+
+ return this;
+ }
+ }
/**
* Creates a new instance of TelephoneNumberSyntaxChecker.
*/
- public FacsimileTelephoneNumberSyntaxChecker()
+ private FacsimileTelephoneNumberSyntaxChecker( String oid )
{
- super();
- setOid( SchemaConstants.FACSIMILE_TELEPHONE_NUMBER_SYNTAX );
+ this( oid, DEFAULT_REGEXP, Pattern.compile( DEFAULT_REGEXP ) );
+ }
+
+
+ /**
+ * Creates a new instance of TelephoneNumberSyntaxChecker.
+ */
+ private FacsimileTelephoneNumberSyntaxChecker( String oid, String defaultRegexp, Pattern defaultPattern )
+ {
+ super( oid );
+
+ this.defaultPattern = defaultPattern;
+ this.defaultRegexp = defaultRegexp;
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+
+ /**
+ * Get the default regexp (either the original one, or the one that has been set)
+ *
+ * @return The default regexp
+ */
+ public String getRegexp()
+ {
+ if ( defaultRegexp == null )
+ {
+ return DEFAULT_REGEXP;
+ }
+ else
+ {
+ return defaultRegexp;
+ }
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -119,7 +232,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -130,15 +247,18 @@
if ( dollarPos == -1 )
{
// We have no fax-parameter : check the Telephone number
- boolean result = super.isValidSyntax( strValue );
+ boolean result = defaultPattern.matcher( strValue ).matches();
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
@@ -147,20 +267,30 @@
// First check the telephone number if the '$' is not at the first position
if ( dollarPos > 0 )
{
- if ( !super.isValidSyntax( strValue.substring( 0, dollarPos - 1 ) ) )
+ boolean result = defaultPattern.matcher( strValue.substring( 0, dollarPos - 1 ) ).matches();
+
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+
+ return false;
+ }
}
// Now, try to validate the fax-parameters : we may
// have more than one, so we will store the seen params
// in a set to check that we don't have the same param twice
- Set<String> paramsSeen = new HashSet<String>();
+ Set<String> paramsSeen = new HashSet<>();
while ( dollarPos > 0 )
{
- String faxParam = null;
+ String faxParam;
int newDollar = strValue.indexOf( '$', dollarPos + 1 );
if ( newDollar == -1 )
@@ -175,23 +305,25 @@
if ( faxParam.length() == 0 )
{
// Not allowed
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Relax a little bit the syntax by lowercasing the param
faxParam = Strings.toLowerCaseAscii( faxParam );
- if ( !faxParameters.contains( faxParam ) )
+ if ( !faxParameters.contains( faxParam ) || paramsSeen.contains( faxParam ) )
{
// This parameter is not in the possible set
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( paramsSeen.contains( faxParam ) )
- {
- // We have the same parameters twice...
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -204,12 +336,20 @@
dollarPos = newDollar;
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
// We must have a valid telephone number !
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FaxSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FaxSyntaxChecker.java
index bfff009..01a7108 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FaxSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FaxSyntaxChecker.java
@@ -21,41 +21,67 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a Fax according to RFC 4517.
- *
+ * <p>
* We didn't implemented the check against RFC 804, so the value is considered
* to contain an OctetString.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class FaxSyntaxChecker extends BinarySyntaxChecker
+public final class FaxSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( FaxSyntaxChecker.class );
-
-
/**
- * Private default constructor to prevent unnecessary instantiation.
+ * A static instance of FaxSyntaxChecker
*/
- public FaxSyntaxChecker()
+ public static final FaxSyntaxChecker INSTANCE = new FaxSyntaxChecker( SchemaConstants.FAX_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<FaxSyntaxChecker>
{
- super();
- setOid( SchemaConstants.FAX_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.FAX_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of FaxSyntaxChecker
+ * @return A new instance of FaxSyntaxChecker
+ */
+ @Override
+ public FaxSyntaxChecker build()
+ {
+ return new FaxSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Private default constructor to prevent unnecessary instantiation.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private FaxSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
index 6efecbd..890e57e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
@@ -22,18 +22,18 @@
import java.util.regex.Pattern;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a generalized time
* according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
+ * <pre>
* GeneralizedTime = century year month day hour
* [ minute [ second / leap-second ] ]
* [ fraction ]
@@ -63,16 +63,13 @@
* PLUS = %x2B ; plus sign ("+")
* DOT = %x2E ; period (".")
* COMMA = %x2C ; comma (",")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class GeneralizedTimeSyntaxChecker extends SyntaxChecker
+public final class GeneralizedTimeSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( GeneralizedTimeSyntaxChecker.class );
-
/** The GeneralizedDate pattern matching */
private static final String GENERALIZED_TIME_PATTERN =
// century + year : 0000 to 9999
@@ -96,27 +93,74 @@
/** The date pattern. The regexp pattern is immutable, only one instance needed. */
private static final Pattern DATE_PATTERN = Pattern.compile( GENERALIZED_TIME_PATTERN );
+
+ /**
+ * A static instance of GeneralizedTimeSyntaxChecker
+ */
+ public static final GeneralizedTimeSyntaxChecker INSTANCE =
+ new GeneralizedTimeSyntaxChecker( SchemaConstants.GENERALIZED_TIME_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<GeneralizedTimeSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.GENERALIZED_TIME_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of GeneralizedTimeSyntaxChecker
+ * @return A new instance of GeneralizedTimeSyntaxChecker
+ */
+ @Override
+ public GeneralizedTimeSyntaxChecker build()
+ {
+ return new GeneralizedTimeSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of GeneralizedTimeSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public GeneralizedTimeSyntaxChecker()
+ private GeneralizedTimeSyntaxChecker( String oid )
{
- super( SchemaConstants.GENERALIZED_TIME_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -136,20 +180,27 @@
// A generalized time must have a minimal length of 11
if ( strValue.length() < 11 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Start the date parsing
boolean result = DATE_PATTERN.matcher( strValue ).find();
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GuideSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GuideSyntaxChecker.java
index 2a49346..ef38825 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GuideSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/GuideSyntaxChecker.java
@@ -21,40 +21,66 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a Guide according to RFC 4517.
- *
+ * <p>
* Implemented as binary right now ...
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class GuideSyntaxChecker extends BinarySyntaxChecker
+public final class GuideSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( GuideSyntaxChecker.class );
+ /**
+ * A static instance of GuideSyntaxChecker
+ */
+ public static final GuideSyntaxChecker INSTANCE = new GuideSyntaxChecker( SchemaConstants.GUIDE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<GuideSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.GUIDE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of GuideSyntaxChecker
+ * @return A new instance of GuideSyntaxChecker
+ */
+ @Override
+ public GuideSyntaxChecker build()
+ {
+ return new GuideSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of GuideSyntaxChecker
*/
- public GuideSyntaxChecker()
+ private GuideSyntaxChecker( String oid )
{
- super();
- setOid( SchemaConstants.GUIDE_SYNTAX );
+ super( oid );
}
-
+
/**
- * {@inheritDoc}
+ * @return An instance of the Builder for this class
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ public static Builder builder()
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/Ia5StringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/Ia5StringSyntaxChecker.java
index d17d285..f664d15 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/Ia5StringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/Ia5StringSyntaxChecker.java
@@ -20,47 +20,89 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a IA5 String according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
+ * <pre>
* IA5String = *(%x00-7F)
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class Ia5StringSyntaxChecker extends SyntaxChecker
+public final class Ia5StringSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( Ia5StringSyntaxChecker.class );
-
-
/**
- * Creates a new instance of Ia5StringSyntaxChecker.
+ * A static instance of Ia5StringSyntaxChecker
*/
- public Ia5StringSyntaxChecker()
+ public static final Ia5StringSyntaxChecker INSTANCE = new Ia5StringSyntaxChecker( SchemaConstants.IA5_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<Ia5StringSyntaxChecker>
{
- super( SchemaConstants.IA5_STRING_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.IA5_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of Ia5StringSyntaxChecker
+ * @return A new instance of Ia5StringSyntaxChecker
+ */
+ @Override
+ public Ia5StringSyntaxChecker build()
+ {
+ return new Ia5StringSyntaxChecker( oid );
+ }
}
+ /**
+ * Creates a new instance of a child with a given OID.
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private Ia5StringSyntaxChecker( String oid )
+ {
+ super( oid );
+ }
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return true;
}
@@ -81,11 +123,17 @@
if ( result )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
}
else
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/IntegerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/IntegerSyntaxChecker.java
index 9f7dc90..f2f5c7a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/IntegerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/IntegerSyntaxChecker.java
@@ -20,12 +20,11 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -33,6 +32,7 @@
*
* From RFC 4517 :
*
+ * <pre>
* Integer = ( HYPHEN LDIGIT *DIGIT ) | number
*
* From RFC 4512 :
@@ -40,36 +40,79 @@
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* HYPHEN = %x2D ; hyphen ("-")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class IntegerSyntaxChecker extends SyntaxChecker
+public final class IntegerSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( IntegerSyntaxChecker.class );
+ /**
+ * A static instance of IntegerSyntaxChecker
+ */
+ public static final IntegerSyntaxChecker INSTANCE = new IntegerSyntaxChecker( SchemaConstants.INTEGER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<IntegerSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.INTEGER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of IntegerSyntaxChecker
+ * @return A new instance of IntegerSyntaxChecker
+ */
+ @Override
+ public IntegerSyntaxChecker build()
+ {
+ return new IntegerSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of IntegerSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public IntegerSyntaxChecker()
+ private IntegerSyntaxChecker( String oid )
{
- super( SchemaConstants.INTEGER_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -88,7 +131,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -103,32 +150,43 @@
}
else if ( !Chars.isDigit( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else if ( c == '0' )
{
if ( strValue.length() > 1 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
// We must have at least a digit which is not '0'
- if ( !Chars.isDigit( strValue, pos ) )
+ if ( !Chars.isDigit( strValue, pos ) || Strings.isCharASCII( strValue, pos, '0' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( Strings.isCharASCII( strValue, pos, '0' ) )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -141,15 +199,18 @@
pos++;
}
- boolean result = ( pos == strValue.length() );
+ boolean result = pos == strValue.length();
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaByteSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaByteSyntaxChecker.java
index b5d9dc9..f18ebec 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaByteSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaByteSyntaxChecker.java
@@ -20,21 +20,21 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a valid Java primitive short or
* the Short wrapper. Essentially this constrains the min and max values of
* the Integer.
- *
+ * <p>
* From RFC 4517 :
*
+ * <pre>
* Integer = ( HYPHEN LDIGIT *DIGIT ) | number
*
* From RFC 4512 :
@@ -42,36 +42,79 @@
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* HYPHEN = %x2D ; hyphen ("-")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class JavaByteSyntaxChecker extends SyntaxChecker
+public final class JavaByteSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( JavaByteSyntaxChecker.class );
+ /**
+ * A static instance of JavaByteSyntaxChecker
+ */
+ public static final JavaByteSyntaxChecker INSTANCE = new JavaByteSyntaxChecker( SchemaConstants.JAVA_BYTE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<JavaByteSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.JAVA_BYTE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of JavaByteSyntaxChecker
+ * @return A new instance of JavaByteSyntaxChecker
+ */
+ @Override
+ public JavaByteSyntaxChecker build()
+ {
+ return new JavaByteSyntaxChecker( oid );
+ }
+ }
/**
* Creates a new instance of JavaByteSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public JavaByteSyntaxChecker()
+ private JavaByteSyntaxChecker( String oid )
{
- super( SchemaConstants.JAVA_BYTE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -90,7 +133,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,32 +152,40 @@
}
else if ( !Chars.isDigit( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else if ( c == '0' )
{
- if ( strValue.length() > 1 )
+ boolean result = strValue.length() <= 1;
+
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ if ( result )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
}
- else
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
+
+ return result;
}
// We must have at least a digit which is not '0'
- if ( !Chars.isDigit( strValue, pos ) )
+ if ( !Chars.isDigit( strValue, pos ) || Strings.isCharASCII( strValue, pos, '0' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( Strings.isCharASCII( strValue, pos, '0' ) )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -145,7 +200,11 @@
if ( pos != strValue.length() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -153,12 +212,21 @@
try
{
Byte.valueOf( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( NumberFormatException e )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaIntegerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaIntegerSyntaxChecker.java
index 72b8bdd..1144b4c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaIntegerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaIntegerSyntaxChecker.java
@@ -20,21 +20,20 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a valid Java primitive int or
* the Integer wrapper. Essentially this constrains the min and max values of
* the Integer.
- *
+ * <p>
* From RFC 4517 :
- *
+ * <pre>
* Integer = ( HYPHEN LDIGIT *DIGIT ) | number
*
* From RFC 4512 :
@@ -42,36 +41,80 @@
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* HYPHEN = %x2D ; hyphen ("-")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class JavaIntegerSyntaxChecker extends SyntaxChecker
+public final class JavaIntegerSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( JavaIntegerSyntaxChecker.class );
+ /**
+ * A static instance of JavaIntegerSyntaxChecker
+ */
+ public static final JavaIntegerSyntaxChecker INSTANCE =
+ new JavaIntegerSyntaxChecker( SchemaConstants.JAVA_INT_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<JavaIntegerSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.JAVA_INT_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of JavaIntegerSyntaxChecker
+ * @return A new instance of JavaIntegerSyntaxChecker
+ */
+ @Override
+ public JavaIntegerSyntaxChecker build()
+ {
+ return new JavaIntegerSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of JavaIntegerSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public JavaIntegerSyntaxChecker()
+ private JavaIntegerSyntaxChecker( String oid )
{
- super( SchemaConstants.JAVA_INT_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -90,7 +133,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,34 +152,40 @@
}
else if ( !Chars.isDigit( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else if ( c == '0' )
{
boolean result = strValue.length() <= 1;
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
}
// We must have at least a digit which is not '0'
- if ( !Chars.isDigit( strValue, pos ) )
+ if ( !Chars.isDigit( strValue, pos ) || Strings.isCharASCII( strValue, pos, '0' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( Strings.isCharASCII( strValue, pos, '0' ) )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -147,19 +200,32 @@
if ( pos != strValue.length() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
try
{
Integer.valueOf( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( NumberFormatException e )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaLongSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaLongSyntaxChecker.java
index 06e4075..4a782ce 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaLongSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaLongSyntaxChecker.java
@@ -20,21 +20,20 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a valid Java primitive long or
* the Long wrapper. Essentially this constrains the min and max values of
* the Integer.
- *
+ * <p>
* From RFC 4517 :
- *
+ * <pre>
* Integer = ( HYPHEN LDIGIT *DIGIT ) | number
*
* From RFC 4512 :
@@ -42,36 +41,79 @@
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* HYPHEN = %x2D ; hyphen ("-")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class JavaLongSyntaxChecker extends SyntaxChecker
+public final class JavaLongSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( JavaLongSyntaxChecker.class );
+ /**
+ * A static instance of JavaLongSyntaxChecker
+ */
+ public static final JavaLongSyntaxChecker INSTANCE = new JavaLongSyntaxChecker( SchemaConstants.JAVA_LONG_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<JavaLongSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.JAVA_LONG_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of JavaLongSyntaxChecker
+ * @return A new instance of JavaLongSyntaxChecker
+ */
+ @Override
+ public JavaLongSyntaxChecker build()
+ {
+ return new JavaLongSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of JavaLongSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public JavaLongSyntaxChecker()
+ private JavaLongSyntaxChecker( String oid )
{
- super( SchemaConstants.JAVA_LONG_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -90,7 +132,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,32 +151,40 @@
}
else if ( !Chars.isDigit( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else if ( c == '0' )
{
- if ( strValue.length() > 1 )
+ boolean result = strValue.length() <= 1;
+
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ if ( result )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
}
- else
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
+
+ return result;
}
// We must have at least a digit which is not '0'
- if ( !Chars.isDigit( strValue, pos ) )
+ if ( !Chars.isDigit( strValue, pos ) || Strings.isCharASCII( strValue, pos, '0' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( Strings.isCharASCII( strValue, pos, '0' ) )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -145,7 +199,11 @@
if ( pos != strValue.length() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -153,12 +211,21 @@
try
{
Long.valueOf( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( NumberFormatException e )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaShortSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaShortSyntaxChecker.java
index 700d668..dd7e369 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaShortSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JavaShortSyntaxChecker.java
@@ -20,21 +20,20 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a valid Java primitive Short or
* the Short wrapper. Essentially this constrains the min and max values of
* the Short.
- *
+ * <p>
* From RFC 4517 :
- *
+ * <pre>
* Integer = ( HYPHEN LDIGIT *DIGIT ) | number
*
* From RFC 4512 :
@@ -42,36 +41,79 @@
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* HYPHEN = %x2D ; hyphen ("-")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class JavaShortSyntaxChecker extends SyntaxChecker
+public final class JavaShortSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( JavaShortSyntaxChecker.class );
+ /**
+ * A static instance of JavaShortSyntaxChecker
+ */
+ public static final JavaShortSyntaxChecker INSTANCE = new JavaShortSyntaxChecker( SchemaConstants.JAVA_SHORT_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<JavaShortSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.JAVA_SHORT_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of JavaShortSyntaxChecker
+ * @return A new instance of JavaShortSyntaxChecker
+ */
+ @Override
+ public JavaShortSyntaxChecker build()
+ {
+ return new JavaShortSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of JavaShortSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public JavaShortSyntaxChecker()
+ private JavaShortSyntaxChecker( String oid )
{
- super( SchemaConstants.JAVA_SHORT_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -90,7 +132,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,32 +151,42 @@
}
else if ( !Chars.isDigit( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else if ( c == '0' )
{
- if ( strValue.length() > 1 )
+ boolean result = strValue.length() <= 1;
+
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ if ( result )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ return false;
+ }
+ else
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ return true;
+ }
}
- else
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
+
+ return result;
}
// We must have at least a digit which is not '0'
- if ( !Chars.isDigit( strValue, pos ) )
+ if ( !Chars.isDigit( strValue, pos ) || Strings.isCharASCII( strValue, pos, '0' ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
- else if ( Strings.isCharASCII( strValue, pos, '0' ) )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -145,7 +201,11 @@
if ( pos != strValue.length() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -153,12 +213,21 @@
try
{
Short.valueOf( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( NumberFormatException e )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JpegSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JpegSyntaxChecker.java
index dfe6e88..50f3bc8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JpegSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/JpegSyntaxChecker.java
@@ -20,58 +20,106 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Jpeg according to RFC 4517.
- *
+ * <p>
* The JFIF (Jpeg File Interchange Format) specify that a jpeg image starts with
* the following bytes :
+ * <pre>
* 0xFF 0xD8 (SOI, Start Of Image)
* 0xFF 0xE0 (App0 for JFIF) or 0xDD 0xE1 (App1 for Exif)
* 0xNN 0xNN (Header length)
* "JFIF\0" (JFIF string with an ending \0)
* some other bytes which are related to the image.
+ * <pre>
*
* We will check for those 11 bytes, except the length.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class JpegSyntaxChecker extends SyntaxChecker
+public final class JpegSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( JpegSyntaxChecker.class );
+ /**
+ * A static instance of JpegSyntaxChecker
+ */
+ public static final JpegSyntaxChecker INSTANCE = new JpegSyntaxChecker( SchemaConstants.JPEG_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<JpegSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.JPEG_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of JpegSyntaxChecker
+ * @return A new instance of JpegSyntaxChecker
+ */
+ @Override
+ public JpegSyntaxChecker build()
+ {
+ return new JpegSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of JpegSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public JpegSyntaxChecker()
+ private JpegSyntaxChecker( String oid )
{
- super( SchemaConstants.JPEG_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
// The value must be a byte array
if ( !( value instanceof byte[] ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -80,7 +128,11 @@
// The header must be at least 11 bytes long
if ( bytes.length < 11 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -97,7 +149,11 @@
&& ( bytes[9] == 'F' )
&& ( bytes[10] == 0x00 ) )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
// EXIF Format
@@ -108,12 +164,20 @@
&& ( bytes[9] == 'f' )
&& ( bytes[10] == 0x00 ) )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/LdapSyntaxDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/LdapSyntaxDescriptionSyntaxChecker.java
index 35da9c3..7dc164e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/LdapSyntaxDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/LdapSyntaxDescriptionSyntaxChecker.java
@@ -22,17 +22,16 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.LdapSyntaxDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value follows the
- * LDAP syntax descripton syntax according to RFC 4512, par 4.2.2:
+ * LDAP syntax description syntax according to RFC 4512, par 4.2.2:
*
* <pre>
* SyntaxDescription = LPAREN WSP
@@ -44,36 +43,78 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class LdapSyntaxDescriptionSyntaxChecker extends SyntaxChecker
+public final class LdapSyntaxDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( LdapSyntaxDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the LdapSyntax description Syntax */
- private LdapSyntaxDescriptionSchemaParser schemaParser = new LdapSyntaxDescriptionSchemaParser();
-
-
+ private transient LdapSyntaxDescriptionSchemaParser schemaParser = new LdapSyntaxDescriptionSchemaParser();
+
/**
- *
+ * A static instance of LdapSyntaxDescriptionSyntaxChecker
+ */
+ public static final LdapSyntaxDescriptionSyntaxChecker INSTANCE =
+ new LdapSyntaxDescriptionSyntaxChecker( SchemaConstants.LDAP_SYNTAX_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<LdapSyntaxDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.LDAP_SYNTAX_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of LdapSyntaxDescriptionSyntaxChecker
+ * @return A new instance of LdapSyntaxDescriptionSyntaxChecker
+ */
+ @Override
+ public LdapSyntaxDescriptionSyntaxChecker build()
+ {
+ return new LdapSyntaxDescriptionSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of LdapSyntaxDescriptionSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public LdapSyntaxDescriptionSyntaxChecker()
+ private LdapSyntaxDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.LDAP_SYNTAX_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -93,13 +134,21 @@
try
{
schemaParser.parseLdapSyntaxDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MailPreferenceSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MailPreferenceSyntaxChecker.java
index 7c61b49..3f93381 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MailPreferenceSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MailPreferenceSyntaxChecker.java
@@ -20,11 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -38,21 +37,40 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class MailPreferenceSyntaxChecker extends SyntaxChecker
+public final class MailPreferenceSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( MailPreferenceSyntaxChecker.class );
-
-
/**
- * Creates a new instance of MailPreferenceSyntaxChecker.
+ * A static instance of MailPreferenceSyntaxChecker
*/
- public MailPreferenceSyntaxChecker()
+ public static final MailPreferenceSyntaxChecker INSTANCE =
+ new MailPreferenceSyntaxChecker( SchemaConstants.MAIL_PREFERENCE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<MailPreferenceSyntaxChecker>
{
- super( SchemaConstants.MAIL_PREFERENCE_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.MAIL_PREFERENCE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of MailPreferenceSyntaxChecker
+ * @return A new instance of MailPreferenceSyntaxChecker
+ */
+ @Override
+ public MailPreferenceSyntaxChecker build()
+ {
+ return new MailPreferenceSyntaxChecker( oid );
+ }
}
-
+
/**
*
* Creates a new instance of MailPreferenceSyntaxChecker.
@@ -60,22 +78,36 @@
* @param oid the oid to associate with this new SyntaxChecker
*
*/
- protected MailPreferenceSyntaxChecker( String oid )
+ private MailPreferenceSyntaxChecker( String oid )
{
super( oid );
}
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -94,20 +126,27 @@
if ( ( strValue.length() < 8 ) || ( strValue.length() > 18 ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- boolean result = ( ( "NO-LISTS".equals( strValue ) ) || ( "ANY-LIST".equals( strValue ) )
- || ( "PROFESSIONAL-LISTS".equals( strValue ) ) );
+ boolean result = ( "NO-LISTS".equals( strValue ) ) || ( "ANY-LIST".equals( strValue ) )
+ || ( "PROFESSIONAL-LISTS".equals( strValue ) );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MasterAndShadowAccessPointSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MasterAndShadowAccessPointSyntaxChecker.java
index d4e2ba9..b267ac8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MasterAndShadowAccessPointSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MasterAndShadowAccessPointSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -33,27 +31,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class MasterAndShadowAccessPointSyntaxChecker extends SyntaxChecker
+public final class MasterAndShadowAccessPointSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( MasterAndShadowAccessPointSyntaxChecker.class );
-
-
/**
- * Create a new instance of MasterAndShadowAccessPointSyntaxChecker
+ * A static instance of MasterAndShadowAccessPointSyntaxChecker
*/
- public MasterAndShadowAccessPointSyntaxChecker()
+ public static final MasterAndShadowAccessPointSyntaxChecker INSTANCE =
+ new MasterAndShadowAccessPointSyntaxChecker( SchemaConstants.MASTER_AND_SHADOW_ACCESS_POINTS_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<MasterAndShadowAccessPointSyntaxChecker>
{
- super( SchemaConstants.MASTER_AND_SHADOW_ACCESS_POINTS_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.MASTER_AND_SHADOW_ACCESS_POINTS_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of MasterAndShadowAccessPointSyntaxChecker
+ * @return A new instance of MasterAndShadowAccessPointSyntaxChecker
+ */
+ @Override
+ public MasterAndShadowAccessPointSyntaxChecker build()
+ {
+ return new MasterAndShadowAccessPointSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Create a new instance of MasterAndShadowAccessPointSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private MasterAndShadowAccessPointSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleDescriptionSyntaxChecker.java
index 80ff668..ef6d798 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleDescriptionSyntaxChecker.java
@@ -22,19 +22,18 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.MatchingRuleDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value follows the
- * matching rule descripton syntax according to RFC 4512, par 4.2.3:
+ * matching rule description syntax according to RFC 4512, par 4.2.3:
*
- * <pre>
+ * <pre>
* MatchingRuleDescription = LPAREN WSP
* numericoid ; object identifier
* [ SP "NAME" SP qdescrs ] ; short names (descriptors)
@@ -45,42 +44,83 @@
*
* extensions = *( SP xstring SP qdstrings )
* xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE )
- *
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class MatchingRuleDescriptionSyntaxChecker extends SyntaxChecker
+public final class MatchingRuleDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the MatchingRuleDescription Syntax */
- private MatchingRuleDescriptionSchemaParser schemaParser = new MatchingRuleDescriptionSchemaParser();
-
-
+ private transient MatchingRuleDescriptionSchemaParser schemaParser = new MatchingRuleDescriptionSchemaParser();
+
/**
- *
+ * A static instance of MatchingRuleDescriptionSyntaxChecker
+ */
+ public static final MatchingRuleDescriptionSyntaxChecker INSTANCE =
+ new MatchingRuleDescriptionSyntaxChecker( SchemaConstants.MATCHING_RULE_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<MatchingRuleDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.MATCHING_RULE_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of MatchingRuleDescriptionSyntaxChecker
+ * @return A new instance of MatchingRuleDescriptionSyntaxChecker
+ */
+ @Override
+ public MatchingRuleDescriptionSyntaxChecker build()
+ {
+ return new MatchingRuleDescriptionSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of MatchingRuleDescriptionSchemaParser.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public MatchingRuleDescriptionSyntaxChecker()
+ private MatchingRuleDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.MATCHING_RULE_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -100,15 +140,22 @@
try
{
schemaParser.parseMatchingRuleDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
-
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleUseDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleUseDescriptionSyntaxChecker.java
index a1020ec..d224131 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleUseDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MatchingRuleUseDescriptionSyntaxChecker.java
@@ -22,19 +22,18 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.MatchingRuleUseDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value follows the
* matching rule use descripton syntax according to RFC 4512, par 4.2.4:
*
- * <pre>
+ * <pre>
* MatchingRuleUseDescription = LPAREN WSP
* numericoid ; object identifier
* [ SP "NAME" SP qdescrs ] ; short names (descriptors)
@@ -42,42 +41,83 @@
* [ SP "OBSOLETE" ] ; not active
* SP "APPLIES" SP oids ; attribute types
* extensions WSP RPAREN ; extensions
- *
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class MatchingRuleUseDescriptionSyntaxChecker extends SyntaxChecker
+public final class MatchingRuleUseDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleUseDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the MatchingRuleUseDescription Syntax */
- private MatchingRuleUseDescriptionSchemaParser schemaParser = new MatchingRuleUseDescriptionSchemaParser();
-
-
+ private transient MatchingRuleUseDescriptionSchemaParser schemaParser = new MatchingRuleUseDescriptionSchemaParser();
+
/**
- *
+ * A static instance of MatchingRuleUseDescriptionSyntaxChecker
+ */
+ public static final MatchingRuleUseDescriptionSyntaxChecker INSTANCE =
+ new MatchingRuleUseDescriptionSyntaxChecker( SchemaConstants.MATCHING_RULE_USE_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<MatchingRuleUseDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.MATCHING_RULE_USE_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of MatchingRuleUseDescriptionSyntaxChecker
+ * @return A new instance of MatchingRuleUseDescriptionSyntaxChecker
+ */
+ @Override
+ public MatchingRuleUseDescriptionSyntaxChecker build()
+ {
+ return new MatchingRuleUseDescriptionSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of MatchingRuleUseDescriptionSchemaParser.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public MatchingRuleUseDescriptionSyntaxChecker()
+ private MatchingRuleUseDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.MATCHING_RULE_USE_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -97,15 +137,22 @@
try
{
schemaParser.parseMatchingRuleUseDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
-
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MhsOrAddressSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MhsOrAddressSyntaxChecker.java
index 8bf769b..a763076 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MhsOrAddressSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/MhsOrAddressSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -33,27 +31,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class MhsOrAddressSyntaxChecker extends SyntaxChecker
+public final class MhsOrAddressSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( MhsOrAddressSyntaxChecker.class );
-
-
/**
- * Creates a new instance of MHSORAddressSyntaxChecker.
+ * A static instance of MhsOrAddressSyntaxChecker
*/
- public MhsOrAddressSyntaxChecker()
+ public static final MhsOrAddressSyntaxChecker INSTANCE =
+ new MhsOrAddressSyntaxChecker( SchemaConstants.MHS_OR_ADDRESS_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<MhsOrAddressSyntaxChecker>
{
- super( SchemaConstants.MHS_OR_ADDRESS_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.MHS_OR_ADDRESS_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of MhsOrAddressSyntaxChecker
+ * @return A new instance of MhsOrAddressSyntaxChecker
+ */
+ @Override
+ public MhsOrAddressSyntaxChecker build()
+ {
+ return new MhsOrAddressSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of MHSORAddressSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private MhsOrAddressSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameAndOptionalUIDSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameAndOptionalUIDSyntaxChecker.java
index 53490c2..577b872 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameAndOptionalUIDSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameAndOptionalUIDSyntaxChecker.java
@@ -20,54 +20,98 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a valid Name and Optional UID.
- *
- * This element is a composition of two parts : a Dn and an optional UID :
+ * <p>
+ * This element is a composition of two parts, a {@link Dn} and an optional UID :
+ * <pre>
* NameAndOptionalUID = distinguishedName [ SHARP BitString ]
- *
+ * </pre>
* Both part already have their syntax checkers, so we will just call them
* after having split the element in two ( if necessary)
- *
- * We just check that the Dn is valid, we don't need to verify each of the Rdn
+ * <p>
+ * We just check that the {@link Dn} is valid, we don't need to verify each of the {@link Rdn}
* syntax.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NameAndOptionalUIDSyntaxChecker extends SyntaxChecker
+public final class NameAndOptionalUIDSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( NameAndOptionalUIDSyntaxChecker.class );
+ /**
+ * A static instance of NameAndOptionalUIDSyntaxChecker
+ */
+ public static final NameAndOptionalUIDSyntaxChecker INSTANCE =
+ new NameAndOptionalUIDSyntaxChecker( SchemaConstants.NAME_AND_OPTIONAL_UID_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NameAndOptionalUIDSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NAME_AND_OPTIONAL_UID_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NameAndOptionalUIDSyntaxChecker
+ * @return A new instance of NameAndOptionalUIDSyntaxChecker
+ */
+ @Override
+ public NameAndOptionalUIDSyntaxChecker build()
+ {
+ return new NameAndOptionalUIDSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of NameAndOptionalUIDSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public NameAndOptionalUIDSyntaxChecker()
+ private NameAndOptionalUIDSyntaxChecker( String oid )
{
- super( SchemaConstants.NAME_AND_OPTIONAL_UID_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -86,7 +130,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -100,7 +148,11 @@
{
// Yes, we have one : this is not allowed, it should have been
// escaped.
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -116,13 +168,16 @@
{
boolean result = Dn.isValid( strValue.substring( 0, sharpPos ) );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
@@ -131,14 +186,22 @@
else
{
// The Dn must not be null ?
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
else
{
// We have found a '#' but no UID part.
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
@@ -148,13 +211,16 @@
// Check that the value is a valid Dn
boolean result = Dn.isValid( strValue );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameFormDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameFormDescriptionSyntaxChecker.java
index b8773ec..5f185cd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameFormDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NameFormDescriptionSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.NameFormDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -49,36 +48,78 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NameFormDescriptionSyntaxChecker extends SyntaxChecker
+public final class NameFormDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( NameFormDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the DITContentRuleDescription Syntax */
- private NameFormDescriptionSchemaParser schemaParser = new NameFormDescriptionSchemaParser();
-
-
+ private transient NameFormDescriptionSchemaParser schemaParser = new NameFormDescriptionSchemaParser();
+
/**
- *
+ * A static instance of NameFormDescriptionSyntaxChecker
+ */
+ public static final NameFormDescriptionSyntaxChecker INSTANCE =
+ new NameFormDescriptionSyntaxChecker( SchemaConstants.NAME_FORM_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NameFormDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NAME_FORM_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NameFormDescriptionSyntaxChecker
+ * @return A new instance of NameFormDescriptionSyntaxChecker
+ */
+ @Override
+ public NameFormDescriptionSyntaxChecker build()
+ {
+ return new NameFormDescriptionSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of DITContentRuleDescriptionSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public NameFormDescriptionSyntaxChecker()
+ private NameFormDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.NAME_FORM_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -98,11 +139,16 @@
try
{
schemaParser.parseNameFormDescription( strValue );
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NormalizerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NormalizerSyntaxChecker.java
index 294d782..20a9c23 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NormalizerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NormalizerSyntaxChecker.java
@@ -20,7 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.util.Strings;
/**
@@ -29,14 +32,104 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NormalizerSyntaxChecker extends Ia5StringSyntaxChecker
+public final class NormalizerSyntaxChecker extends SyntaxChecker
{
/**
- * Creates a new instance of NormalizerSyntaxChecker.
+ * A static instance of NormalizerSyntaxChecker
*/
- public NormalizerSyntaxChecker()
+ public static final NormalizerSyntaxChecker INSTANCE = new NormalizerSyntaxChecker( SchemaConstants.NORMALIZER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NormalizerSyntaxChecker>
{
- super();
- setOid( SchemaConstants.NORMALIZER_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NORMALIZER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NormalizerSyntaxChecker
+ * @return A new instance of NormalizerSyntaxChecker
+ */
+ @Override
+ public NormalizerSyntaxChecker build()
+ {
+ return new NormalizerSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of NormalizerSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private NormalizerSyntaxChecker( String oid )
+ {
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValidSyntax( Object value )
+ {
+ String strValue;
+
+ if ( value == null )
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
+ return true;
+ }
+
+ if ( value instanceof String )
+ {
+ strValue = ( String ) value;
+ }
+ else if ( value instanceof byte[] )
+ {
+ strValue = Strings.utf8ToString( ( byte[] ) value );
+ }
+ else
+ {
+ strValue = value.toString();
+ }
+
+ boolean result = Strings.isIA5String( strValue );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ }
+
+ return result;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumberSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumberSyntaxChecker.java
index 65806ab..2b72c59 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumberSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumberSyntaxChecker.java
@@ -20,50 +20,93 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Number according to RFC 4512.
- *
+ * <p>
* From RFC 4512 :
+ * <pre>
* number = DIGIT | ( LDIGIT 1*DIGIT )
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NumberSyntaxChecker extends SyntaxChecker
+public final class NumberSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( NumberSyntaxChecker.class );
+ /**
+ * A static instance of NumberSyntaxChecker
+ */
+ public static final NumberSyntaxChecker INSTANCE = new NumberSyntaxChecker( SchemaConstants.NUMBER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NumberSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NUMBER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NumberSyntaxChecker
+ * @return A new instance of NumberSyntaxChecker
+ */
+ @Override
+ public NumberSyntaxChecker build()
+ {
+ return new NumberSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of NumberSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public NumberSyntaxChecker()
+ private NumberSyntaxChecker( String oid )
{
- super( SchemaConstants.NUMBER_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -83,7 +126,11 @@
// We should have at least one char
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,7 +152,11 @@
continue;
default:
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
@@ -114,11 +165,19 @@
{
// A number can't start with a '0' unless it's the only
// number
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
index 50b9633..c707792 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericOidSyntaxChecker.java
@@ -21,54 +21,97 @@
import org.apache.directory.api.asn1.util.Oid;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a numeric oid
* according to RFC 4512.
- *
+ * <p>
* From RFC 4512 :
- *
+ * <pre>
* numericoid = number 1*( DOT number )
* number = DIGIT | ( LDIGIT 1*DIGIT )
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* DOT = %x2E ; period (".")
-
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NumericOidSyntaxChecker extends SyntaxChecker
+public final class NumericOidSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( NumericOidSyntaxChecker.class );
+ /**
+ * A static instance of NumericOidSyntaxChecker
+ */
+ public static final NumericOidSyntaxChecker INSTANCE =
+ new NumericOidSyntaxChecker( SchemaConstants.NUMERIC_OID_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NumericOidSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NUMERIC_OID_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NumericOidSyntaxChecker
+ * @return A new instance of NumericOidSyntaxChecker
+ */
+ @Override
+ public NumericOidSyntaxChecker build()
+ {
+ return new NumericOidSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of NumericOidSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public NumericOidSyntaxChecker()
+ private NumericOidSyntaxChecker( String oid )
{
- super( SchemaConstants.NUMERIC_OID_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -87,20 +130,27 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Just check that the value is a valid OID
- boolean result = ( Oid.isOid( strValue ) );
+ boolean result = Oid.isOid( strValue );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericStringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericStringSyntaxChecker.java
index 2f6f447..9ddb606 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericStringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/NumericStringSyntaxChecker.java
@@ -20,54 +20,97 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Numeric String according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
- *
+ * <pre>
* NumericString = 1*(DIGIT / SPACE)
*
* From RFC 4512 :
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
* SPACE = %x20 ; space (" ")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class NumericStringSyntaxChecker extends SyntaxChecker
+public final class NumericStringSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( NumericStringSyntaxChecker.class );
+ /**
+ * A static instance of NumericStringSyntaxChecker
+ */
+ public static final NumericStringSyntaxChecker INSTANCE =
+ new NumericStringSyntaxChecker( SchemaConstants.NUMERIC_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<NumericStringSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.NUMERIC_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of NumericStringSyntaxChecker
+ * @return A new instance of NumericStringSyntaxChecker
+ */
+ @Override
+ public NumericStringSyntaxChecker build()
+ {
+ return new NumericStringSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of NumericStringSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public NumericStringSyntaxChecker()
+ private NumericStringSyntaxChecker( String oid )
{
- super( SchemaConstants.NUMERIC_STRING_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -87,7 +130,11 @@
// We should have at least one char
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -110,12 +157,20 @@
continue;
default:
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassDescriptionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassDescriptionSyntaxChecker.java
index 88ec6fe..53e643e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassDescriptionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassDescriptionSyntaxChecker.java
@@ -22,12 +22,11 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.parsers.ObjectClassDescriptionSchemaParser;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -55,34 +54,78 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ObjectClassDescriptionSyntaxChecker extends SyntaxChecker
+public final class ObjectClassDescriptionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( ObjectClassDescriptionSyntaxChecker.class );
-
/** The schema parser used to parse the ObjectClassDescription Syntax */
- private ObjectClassDescriptionSchemaParser schemaParser = new ObjectClassDescriptionSchemaParser();
+ private transient ObjectClassDescriptionSchemaParser schemaParser = new ObjectClassDescriptionSchemaParser();
+
+ /**
+ * A static instance of ObjectClassDescriptionSyntaxChecker
+ */
+ public static final ObjectClassDescriptionSyntaxChecker INSTANCE =
+ new ObjectClassDescriptionSyntaxChecker( SchemaConstants.OBJECT_CLASS_DESCRIPTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ObjectClassDescriptionSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OBJECT_CLASS_DESCRIPTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of ObjectClassDescriptionSyntaxChecker
+ * @return A new instance of ObjectClassDescriptionSyntaxChecker
+ */
+ @Override
+ public ObjectClassDescriptionSyntaxChecker build()
+ {
+ return new ObjectClassDescriptionSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of ObjectClassDescriptionSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public ObjectClassDescriptionSyntaxChecker()
+ private ObjectClassDescriptionSyntaxChecker( String oid )
{
- super( SchemaConstants.OBJECT_CLASS_DESCRIPTION_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -102,12 +145,21 @@
try
{
schemaParser.parseObjectClassDescription( strValue );
- LOG.debug( "Syntax valid for '{}'", value );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassTypeSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassTypeSyntaxChecker.java
index 0bfe7e3..24d18fd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassTypeSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectClassTypeSyntaxChecker.java
@@ -20,45 +20,88 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A syntax checker which checks to see if an objectClass' type is either:
- * AUXILIARY, STRUCTURAL, or ABSTRACT. The case is NOT ignored.
+ * <em>AUXILIARY</em>, <em>STRUCTURAL</em>, or <em>ABSTRACT</em>. The case is NOT ignored.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ObjectClassTypeSyntaxChecker extends SyntaxChecker
+public final class ObjectClassTypeSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( ObjectClassTypeSyntaxChecker.class );
+ /**
+ * A static instance of ObjectClassTypeSyntaxChecker
+ */
+ public static final ObjectClassTypeSyntaxChecker INSTANCE =
+ new ObjectClassTypeSyntaxChecker( SchemaConstants.OBJECT_CLASS_TYPE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ObjectClassTypeSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OBJECT_CLASS_TYPE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of ObjectClassTypeSyntaxChecker
+ * @return A new instance of ObjectClassTypeSyntaxChecker
+ */
+ @Override
+ public ObjectClassTypeSyntaxChecker build()
+ {
+ return new ObjectClassTypeSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of ObjectClassTypeSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public ObjectClassTypeSyntaxChecker()
+ private ObjectClassTypeSyntaxChecker( String oid )
{
- super( SchemaConstants.OBJECT_CLASS_TYPE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -77,40 +120,32 @@
if ( strValue.length() < 8 || strValue.length() > 10 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- char ch = strValue.charAt( 0 );
-
- switch ( ch )
+ switch ( strValue )
{
- case ( 'A' ):
- if ( "AUXILIARY".equals( strValue ) || "ABSTRACT".equals( strValue ) )
+ case "AUXILIARY" :
+ case "ABSTRACT" :
+ case "STRUCTURAL" :
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
}
-
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
-
- case ( 'S' ):
- boolean result = "STRUCTURAL".equals( strValue );
-
- if ( result )
+
+ return true;
+
+ default :
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
}
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
- }
-
- return result;
-
- default:
- LOG.debug( "Syntax invalid for '{}'", value );
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
index 802da1e..91c6559 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ObjectNameSyntaxChecker.java
@@ -20,14 +20,12 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -48,35 +46,79 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ObjectNameSyntaxChecker extends SyntaxChecker
+public final class ObjectNameSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( ObjectNameSyntaxChecker.class );
-
private static final String REGEXP = "^([a-zA-Z][a-zA-Z0-9-;]*)$";
private static final Pattern PATTERN = Pattern.compile( REGEXP );
+
+ /**
+ * A static instance of ObjectNameSyntaxChecker
+ */
+ public static final ObjectNameSyntaxChecker INSTANCE =
+ new ObjectNameSyntaxChecker( SchemaConstants.OBJECT_NAME_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ObjectNameSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OBJECT_NAME_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of ObjectNameSyntaxChecker
+ * @return A new instance of ObjectNameSyntaxChecker
+ */
+ @Override
+ public ObjectNameSyntaxChecker build()
+ {
+ return new ObjectNameSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of ObjectNameSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public ObjectNameSyntaxChecker()
+ private ObjectNameSyntaxChecker( String oid )
{
- super( SchemaConstants.OBJECT_NAME_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -95,22 +137,27 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Search for the '$' separator
- Matcher match = PATTERN.matcher( strValue );
+ boolean result = PATTERN.matcher( strValue ).matches();
- boolean result = match.matches();
-
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OctetStringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OctetStringSyntaxChecker.java
index c48bb60..f884a9e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OctetStringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OctetStringSyntaxChecker.java
@@ -26,44 +26,68 @@
/**
* A SyntaxChecker which verifies that a value is a Octet String according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
+ * <pre>
* OctetString = *OCTET
- *
+ * </pre>
* From RFC 4512 :
+ * <pre>
* OCTET = %x00-FF ; Any octet (8-bit data unit)
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class OctetStringSyntaxChecker extends SyntaxChecker
+public final class OctetStringSyntaxChecker extends SyntaxChecker
{
/**
- * Creates a new instance of OctetStringSyntaxChecker.
+ * A static instance of OctetStringSyntaxChecker
*/
- public OctetStringSyntaxChecker()
+ public static final OctetStringSyntaxChecker INSTANCE =
+ new OctetStringSyntaxChecker( SchemaConstants.OCTET_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<OctetStringSyntaxChecker>
{
- super( SchemaConstants.OCTET_STRING_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OCTET_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of OctetStringSyntaxChecker
+ * @return A new instance of OctetStringSyntaxChecker
+ */
+ @Override
+ public OctetStringSyntaxChecker build()
+ {
+ return new OctetStringSyntaxChecker( oid );
+ }
}
-
+
/**
* Creates a new instance of OctetStringSyntaxChecker, with a specific OID
*
* @param oid The Syntax's OID
*/
- public OctetStringSyntaxChecker( String oid )
+ private OctetStringSyntaxChecker( String oid )
{
super( oid );
}
-
+
/**
- * {@inheritDoc}
+ * @return An instance of the Builder for this class
*/
- public boolean isValidSyntax( Object value )
+ public static Builder builder()
{
- // Always true.
- return true;
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java
index 92f786d..8f6f553 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java
@@ -21,19 +21,18 @@
import org.apache.directory.api.asn1.util.Oid;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a numeric oid and a length
* constraint according to RFC 4512.
- *
+ * <p>
* From RFC 4512 :
- *
+ * <pre>
* noidlen = numericoid [ LCURLY len RCURLY ]
* numericoid = number 1*( DOT number )
* len = number
@@ -43,38 +42,80 @@
* DOT = %x2E ; period (".")
* LCURLY = %x7B ; left curly brace "{"
* RCURLY = %x7D ; right curly brace "}"
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class OidLenSyntaxChecker extends SyntaxChecker
+public final class OidLenSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( OidLenSyntaxChecker.class );
+ /**
+ * A static instance of OidLenSyntaxChecker
+ */
+ public static final OidLenSyntaxChecker INSTANCE =
+ new OidLenSyntaxChecker( SchemaConstants.OID_LEN_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<OidLenSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OID_LEN_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of OidLenSyntaxChecker
+ * @return A new instance of OidLenSyntaxChecker
+ */
+ @Override
+ public OidLenSyntaxChecker build()
+ {
+ return new OidLenSyntaxChecker( oid );
+ }
+ }
-
+
/**
*
* Creates a new instance of OidLenSyntaxChecker.
*
*/
- public OidLenSyntaxChecker()
+ private OidLenSyntaxChecker( String oid )
{
- super( SchemaConstants.OID_LEN_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -93,7 +134,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -105,13 +150,16 @@
// Not found ... but it may still be a valid OID
boolean result = Oid.isOid( strValue );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
@@ -123,17 +171,25 @@
if ( !Oid.isOid( oid ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
String len = strValue.substring( pos );
- // We must have a lnumber and a '}' at the end
+ // We must have a number and a '}' at the end
if ( len.charAt( len.length() - 1 ) != '}' )
{
// No final '}'
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -154,7 +210,11 @@
break;
default:
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
@@ -163,11 +223,19 @@
{
// A number can't start with a '0' unless it's the only
// number
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java
index 590374d..63ced87 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java
@@ -21,19 +21,18 @@
import org.apache.directory.api.asn1.util.Oid;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Chars;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is an oid according to RFC 4512.
- *
+ * <p>
* From RFC 4512 :
- *
+ * <pre>
* oid = descr | numericoid
* descr = keystring
* keystring = leadkeychar *keychar
@@ -46,36 +45,79 @@
* HYPHEN = %x2D ; hyphen ("-")
* numericoid = number 1*( DOT number )
* DOT = %x2E ; period (".")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class OidSyntaxChecker extends SyntaxChecker
+public final class OidSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( OidSyntaxChecker.class );
+ /**
+ * A static instance of OidSyntaxChecker
+ */
+ public static final OidSyntaxChecker INSTANCE = new OidSyntaxChecker( SchemaConstants.OID_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<OidSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OID_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of OidSyntaxChecker
+ * @return A new instance of OidSyntaxChecker
+ */
+ @Override
+ public OidSyntaxChecker build()
+ {
+ return new OidSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of OidSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public OidSyntaxChecker()
+ private OidSyntaxChecker( String oid )
{
- super( SchemaConstants.OID_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -94,7 +136,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -102,16 +148,21 @@
// checked to make sure there are no other chars except '.' and digits.
if ( Chars.isDigit( strValue.charAt( 0 ) ) )
{
- if ( !Oid.isOid( strValue ) )
+ boolean result = Oid.isOid( strValue );
+
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
- else
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
+
+ return result;
}
// here we just need to make sure that we have the right characters in the
@@ -124,17 +175,29 @@
if ( !Chars.isAlphaDigitMinus( c ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
else
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OpenLdapObjectIdentifierMacro.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OpenLdapObjectIdentifierMacro.java
index 32d455a..8f7c3cf 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OpenLdapObjectIdentifierMacro.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OpenLdapObjectIdentifierMacro.java
@@ -36,8 +36,7 @@
private String rawOidOrNameSuffix;
private String resolvedOid;
-
-
+
/**
* Instantiates a new OpenLDAP object identifier macro.
*/
@@ -126,6 +125,7 @@
}
+ @Override
public String toString()
{
if ( isResolved() )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java
index 9f9aad5..bda431d 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java
@@ -20,49 +20,90 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is an OtherMailbox according to
* RFC 4517 :
- *
+ * <pre>
* OtherMailbox = mailbox-type DOLLAR mailbox
* mailbox-type = PrintableString
* mailbox = IA5String
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class OtherMailboxSyntaxChecker extends SyntaxChecker
+public final class OtherMailboxSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( OtherMailboxSyntaxChecker.class );
+ /**
+ * A static instance of OtherMailboxSyntaxChecker
+ */
+ public static final OtherMailboxSyntaxChecker INSTANCE =
+ new OtherMailboxSyntaxChecker( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<OtherMailboxSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of OtherMailboxSyntaxChecker
+ * @return A new instance of OtherMailboxSyntaxChecker
+ */
+ @Override
+ public OtherMailboxSyntaxChecker build()
+ {
+ return new OtherMailboxSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of OtherMailboxSyntaxChecker.
*/
- public OtherMailboxSyntaxChecker()
+ private OtherMailboxSyntaxChecker( String oid )
{
- super( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -81,7 +122,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -91,39 +136,54 @@
if ( dollar == -1 )
{
// No '$' => error
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
String mailboxType = strValue.substring( 0, dollar );
- String mailbox = ( ( dollar < strValue.length() - 1 )
- ? strValue.substring( dollar + 1 ) : "" );
+ String mailbox = ( dollar < strValue.length() - 1 )
+ ? strValue.substring( dollar + 1 ) : "";
// The mailbox should not contains a '$'
if ( mailbox.indexOf( '$' ) != -1 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Check that the mailboxType is a PrintableString
if ( !Strings.isPrintableString( mailboxType ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Check that the mailbox is an IA5String
- boolean result = ( Strings.isIA5String( mailbox ) );
+ boolean result = Strings.isIA5String( mailbox );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java
index eb4885e..cc4f569 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java
@@ -20,11 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -38,31 +37,75 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class PostalAddressSyntaxChecker extends SyntaxChecker
+public final class PostalAddressSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( PostalAddressSyntaxChecker.class );
+ /**
+ * A static instance of PostalAddressSyntaxChecker
+ */
+ public static final PostalAddressSyntaxChecker INSTANCE =
+ new PostalAddressSyntaxChecker( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<PostalAddressSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of PostalAddressSyntaxChecker
+ * @return A new instance of PostalAddressSyntaxChecker
+ */
+ @Override
+ public PostalAddressSyntaxChecker build()
+ {
+ return new PostalAddressSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of PostalAddressSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public PostalAddressSyntaxChecker()
+ private PostalAddressSyntaxChecker( String oid )
{
- super( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -81,7 +124,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -91,7 +138,7 @@
if ( dollar == -1 )
{
// No '$' => only a dstring
- LOG.debug( "Syntax valid for '{}'", value );
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
return true;
}
@@ -103,7 +150,11 @@
if ( Strings.isEmpty( address ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -112,7 +163,11 @@
if ( pos == strValue.length() )
{
// we should not have a '$' at the end
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java
index 3027b4a..1030f67 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java
@@ -21,40 +21,67 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a PresentationAddressSyntax.
- *
+ * <p>
* This syntax is defined in RFC 1278, but it has not been implemented.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class PresentationAddressSyntaxChecker extends BinarySyntaxChecker
+public final class PresentationAddressSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( PresentationAddressSyntaxChecker.class );
-
-
/**
- * Creates an instance of PresentationAddressSyntaxChecker
+ * A static instance of PresentationAddressSyntaxChecker
*/
- public PresentationAddressSyntaxChecker()
+ public static final PresentationAddressSyntaxChecker INSTANCE =
+ new PresentationAddressSyntaxChecker( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<PresentationAddressSyntaxChecker>
{
- super();
- setOid( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of PresentationAddressSyntaxChecker
+ * @return A new instance of PresentationAddressSyntaxChecker
+ */
+ @Override
+ public PresentationAddressSyntaxChecker build()
+ {
+ return new PresentationAddressSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates an instance of PresentationAddressSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private PresentationAddressSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java
index 272c8be..dd4471f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java
@@ -20,18 +20,17 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Printable String according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
- *
+ * <pre>
* PrintableString = 1*PrintableCharacter
* PrintableCharacter = ALPHA | DIGIT | SQUOTE | LPAREN | RPAREN |
* PLUS | COMMA | HYPHEN | DOT | EQUALS |
@@ -40,8 +39,9 @@
* SLASH = %x2F ; forward slash ("/")
* COLON = %x3A ; colon (":")
* QUESTION= %x3F ; question mark ("?")
- *
+ * </pre>
* From RFC 4512 :
+ * <pre>
* ALPHA = %x41-5A | %x61-7A ; "A"-"Z" / "a"-"z"
* DIGIT = %x30 | LDIGIT ; "0"-"9"
* LDIGIT = %x31-39 ; "1"-"9"
@@ -54,35 +54,80 @@
* DOT = %x2E ; period (".")
* EQUALS = %x3D ; equals sign ("=")
* SPACE = %x20 ; space (" ")
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class PrintableStringSyntaxChecker extends SyntaxChecker
+public final class PrintableStringSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( PrintableStringSyntaxChecker.class );
+ /**
+ * A static instance of PrintableStringSyntaxChecker
+ */
+ public static final PrintableStringSyntaxChecker INSTANCE =
+ new PrintableStringSyntaxChecker( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<PrintableStringSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of PrintableStringSyntaxChecker
+ * @return A new instance of PrintableStringSyntaxChecker
+ */
+ @Override
+ public PrintableStringSyntaxChecker build()
+ {
+ return new PrintableStringSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of PrintableStringSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public PrintableStringSyntaxChecker()
+ private PrintableStringSyntaxChecker( String oid )
{
- super( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -101,26 +146,37 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// We must have at least one char
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
boolean result = Strings.isPrintableString( strValue );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java
index 75c5a55..08b19f3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -33,27 +31,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class ProtocolInformationSyntaxChecker extends SyntaxChecker
+public final class ProtocolInformationSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( ProtocolInformationSyntaxChecker.class );
-
-
/**
- * Creates a new instance of ProtocolInformationSyntaxChecker.
+ * A static instance of ProtocolInformationSyntaxChecker
*/
- public ProtocolInformationSyntaxChecker()
+ public static final ProtocolInformationSyntaxChecker INSTANCE =
+ new ProtocolInformationSyntaxChecker( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<ProtocolInformationSyntaxChecker>
{
- super( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of ProtocolInformationSyntaxChecker
+ * @return A new instance of ProtocolInformationSyntaxChecker
+ */
+ @Override
+ public ProtocolInformationSyntaxChecker build()
+ {
+ return new ProtocolInformationSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of ProtocolInformationSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private ProtocolInformationSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java
index aa1480c..fcd3e76 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java
@@ -20,12 +20,9 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.util.Strings;
/**
@@ -35,65 +32,87 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class RegexSyntaxChecker extends SyntaxChecker
+public final class RegexSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( RegexSyntaxChecker.class );
-
/** the set of regular expressions */
- private List<String> expressions;
+ private String[] expressions;
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<RegexSyntaxChecker>
+ {
+ /** the set of regular expressions */
+ private String[] expressions;
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( null );
+ }
+ /**
+ * Add a list of regexp to be applied by this SyntaxChecker
+ *
+ * @param expressions The regexp list to add
+ */
+ public Builder setExpressions( String[] expressions )
+ {
+ if ( ( expressions != null ) && ( expressions.length > 0 ) )
+ {
+ this.expressions = new String[expressions.length];
+ System.arraycopy( expressions, 0, this.expressions, 0, expressions.length );
+ }
+
+ return this;
+ }
+
+
+ /**
+ * Create a new instance of RegexSyntaxChecker
+ * @return A new instance of RegexSyntaxChecker
+ */
+ public RegexSyntaxChecker build()
+ {
+ return new RegexSyntaxChecker( oid, expressions );
+ }
+ }
+
+
/**
* Creates a Syntax validator for a specific Syntax using Perl5 matching
* rules for validation.
*
- * @param oid
- * the oid of the Syntax values checked
- * @param matchExprArray
- * the array of matching expressions
+ * @param oid the oid of the Syntax values checked
+ * @param matchExprArray the array of matching expressions
*/
- public RegexSyntaxChecker( String oid, String[] matchExprArray )
+ private RegexSyntaxChecker( String oid, String[] matchExprArray )
{
super( oid );
- if ( ( matchExprArray != null ) && ( matchExprArray.length != 0 ) )
- {
- expressions = new ArrayList<String>( matchExprArray.length );
-
- for ( String regexp : matchExprArray )
- {
- expressions.add( regexp );
- }
- }
- else
- {
- expressions = new ArrayList<String>();
- }
+ this.expressions = matchExprArray;
}
-
+
/**
- *
- * Creates a new instance of RegexSyntaxChecker.
- *
- * @param oid the oid to associate with this new SyntaxChecker
- *
+ * @return An instance of the Builder for this class
*/
- public RegexSyntaxChecker( String oid )
+ public static Builder builder()
{
- super( oid );
- expressions = new ArrayList<String>();
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String str = null;
- boolean match = true;
+ String str;
if ( value instanceof String )
{
@@ -101,25 +120,24 @@
for ( String regexp : expressions )
{
- match = match && str.matches( regexp );
-
- if ( !match )
+ if ( !str.matches( regexp ) )
{
- break;
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
+ return false;
}
}
}
- if ( match )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
}
- return match;
+ return true;
}
@@ -130,21 +148,14 @@
*/
public String[] getExpressions()
{
- String[] exprs = new String[expressions.size()];
- return expressions.toArray( exprs );
- }
-
-
- /**
- * Add a list of regexp to be applied by this SyntaxChecker
- *
- * @param expressions The regexp list to add
- */
- public void setExpressions( String[] expressions )
- {
- for ( String regexp : expressions )
+ if ( expressions == null )
{
- this.expressions.add( regexp );
+ return Strings.EMPTY_STRING_ARRAY;
}
+
+ String[] exprs = new String[expressions.length];
+ System.arraycopy( expressions, 0, exprs, 0, expressions.length );
+
+ return exprs;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
index 8940eb2..092cefd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
@@ -20,11 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -40,31 +39,75 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SearchScopeSyntaxChecker extends SyntaxChecker
+public final class SearchScopeSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SearchScopeSyntaxChecker.class );
+ /**
+ * A static instance of SearchScopeSyntaxChecker
+ */
+ public static final SearchScopeSyntaxChecker INSTANCE =
+ new SearchScopeSyntaxChecker( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SearchScopeSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SearchScopeSyntaxChecker
+ * @return A new instance of SearchScopeSyntaxChecker
+ */
+ @Override
+ public SearchScopeSyntaxChecker build()
+ {
+ return new SearchScopeSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of SearchScopeSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public SearchScopeSyntaxChecker()
+ private SearchScopeSyntaxChecker( String oid )
{
- super( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -83,6 +126,6 @@
strValue = Strings.trim( Strings.toLowerCaseAscii( strValue ) );
- return ( "base".equals( strValue ) || "one".equals( strValue ) || "sub".equals( strValue ) );
+ return "base".equals( strValue ) || "one".equals( strValue ) || "sub".equals( strValue );
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java
index 4a8ba6e..2df3728 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java
@@ -21,41 +21,68 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a SubstringAssertion
* according to RFC 4517.
- *
+ * <p>
* Implemented as binary right now ...
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SubstringAssertionSyntaxChecker extends BinarySyntaxChecker
+public final class SubstringAssertionSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SubstringAssertionSyntaxChecker.class );
-
-
/**
- * Creates an instance of SubstringAssertionSyntaxChecker
+ * A static instance of SubstringAssertionSyntaxChecker
*/
- public SubstringAssertionSyntaxChecker()
+ public static final SubstringAssertionSyntaxChecker INSTANCE =
+ new SubstringAssertionSyntaxChecker( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SubstringAssertionSyntaxChecker>
{
- super();
- setOid( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SubstringAssertionSyntaxChecker
+ * @return A new instance of SubstringAssertionSyntaxChecker
+ */
+ @Override
+ public SubstringAssertionSyntaxChecker build()
+ {
+ return new SubstringAssertionSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates an instance of SubstringAssertionSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private SubstringAssertionSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
index f2cf706..bf8be3f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
@@ -22,51 +22,105 @@
import java.text.ParseException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.subtree.SubtreeSpecificationChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a subtree specification.
- *
+ * <p>
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SubtreeSpecificationSyntaxChecker extends SyntaxChecker
+public final class SubtreeSpecificationSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SubtreeSpecificationSyntaxChecker.class );
-
/** The associated checker */
- private SubtreeSpecificationChecker subtreeSpecificationChecker;
-
-
+ private transient SubtreeSpecificationChecker subtreeSpecificationChecker;
+
+ /**
+ * A static instance of SubtreeSpecificationSyntaxChecker
+ */
+ public static final SubtreeSpecificationSyntaxChecker INSTANCE =
+ new SubtreeSpecificationSyntaxChecker( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX, null );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SubtreeSpecificationSyntaxChecker>
+ {
+ /** The schemaManager */
+ private SchemaManager schemaManager;
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX );
+ }
+
+
+ public Builder setSchemaManager( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+
+ return this;
+ }
+
+
+ /**
+ * Create a new instance of SubtreeSpecificationSyntaxChecker
+ * @return A new instance of SubtreeSpecificationSyntaxChecker
+ */
+ @Override
+ public SubtreeSpecificationSyntaxChecker build()
+ {
+ return new SubtreeSpecificationSyntaxChecker( oid, schemaManager );
+ }
+ }
+
/**
* Creates an instance of SubtreeSpecificationSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public SubtreeSpecificationSyntaxChecker()
+ private SubtreeSpecificationSyntaxChecker( String oid, SchemaManager schemaManager )
{
- super( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX );
+ super( oid );
+ subtreeSpecificationChecker = new SubtreeSpecificationChecker( schemaManager );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -85,7 +139,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -96,22 +154,21 @@
subtreeSpecificationChecker.parse( strValue );
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
catch ( ParseException pe )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
-
-
- /**
- * {@inheritDoc}
- */
- public void setSchemaManager( SchemaManager schemaManager )
- {
- subtreeSpecificationChecker = new SubtreeSpecificationChecker( schemaManager );
- }
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java
index cf2f39f..070c061 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java
@@ -22,37 +22,64 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * A SyntaxChecker which verifies that a value is a supplier and consummer according to RFC 2252.
+ * A SyntaxChecker which verifies that a value is a supplier and consumer according to RFC 2252.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SupplierAndConsumerSyntaxChecker extends SyntaxChecker
+public final class SupplierAndConsumerSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SupplierAndConsumerSyntaxChecker.class );
-
-
/**
- * Creates an instance of SupplierAndConsumerSyntaxChecker
+ * A static instance of SupplierAndConsumerSyntaxChecker
*/
- public SupplierAndConsumerSyntaxChecker()
+ public static final SupplierAndConsumerSyntaxChecker INSTANCE =
+ new SupplierAndConsumerSyntaxChecker( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SupplierAndConsumerSyntaxChecker>
{
- super( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SupplierAndConsumerSyntaxChecker
+ * @return A new instance of SupplierAndConsumerSyntaxChecker
+ */
+ @Override
+ public SupplierAndConsumerSyntaxChecker build()
+ {
+ return new SupplierAndConsumerSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates an instance of SupplierAndConsumerSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private SupplierAndConsumerSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java
index 1d7bef8..f66a664 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SupplierInformationSyntaxChecker extends SyntaxChecker
+public final class SupplierInformationSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SupplierInformationSyntaxChecker.class );
-
-
/**
- * Creates an instance of SupplierInformationSyntaxChecker
+ * A static instance of SupplierInformationSyntaxChecker
*/
- public SupplierInformationSyntaxChecker()
+ public static final SupplierInformationSyntaxChecker INSTANCE =
+ new SupplierInformationSyntaxChecker( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SupplierInformationSyntaxChecker>
{
- super( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SupplierInformationSyntaxChecker
+ * @return A new instance of SupplierInformationSyntaxChecker
+ */
+ @Override
+ public SupplierInformationSyntaxChecker build()
+ {
+ return new SupplierInformationSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates an instance of SupplierInformationSyntaxChecker
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private SupplierInformationSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java
index a523483..276c944 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java
@@ -22,8 +22,6 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -32,27 +30,56 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SupplierOrConsumerSyntaxChecker extends SyntaxChecker
+public final class SupplierOrConsumerSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SupplierOrConsumerSyntaxChecker.class );
-
-
/**
- * Creates a new instance of SupplierOrConsumerSyntaxChecker.
+ * A static instance of SupplierOrConsumerSyntaxChecker
*/
- public SupplierOrConsumerSyntaxChecker()
+ public static final SupplierOrConsumerSyntaxChecker INSTANCE =
+ new SupplierOrConsumerSyntaxChecker( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SupplierOrConsumerSyntaxChecker>
{
- super( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SupplierOrConsumerSyntaxChecker
+ * @return A new instance of SupplierOrConsumerSyntaxChecker
+ */
+ @Override
+ public SupplierOrConsumerSyntaxChecker build()
+ {
+ return new SupplierOrConsumerSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of SupplierOrConsumerSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private SupplierOrConsumerSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java
index f8fe218..a72f695 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java
@@ -21,40 +21,67 @@
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
/**
* A SyntaxChecker which verifies that a value is a SupportedAlgorithm according to RFC 2252.
- *
+ * <p>
* It has been removed in RFC 4517
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SupportedAlgorithmSyntaxChecker extends BinarySyntaxChecker
+public final class SupportedAlgorithmSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( SupportedAlgorithmSyntaxChecker.class );
-
-
/**
- * Creates a new instance of SupportedAlgorithmSyntaxChecker.
+ * A static instance of SupportedAlgorithmSyntaxChecker
*/
- public SupportedAlgorithmSyntaxChecker()
+ public static final SupportedAlgorithmSyntaxChecker INSTANCE =
+ new SupportedAlgorithmSyntaxChecker( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SupportedAlgorithmSyntaxChecker>
{
- super();
- setOid( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SupportedAlgorithmSyntaxChecker
+ * @return A new instance of SupportedAlgorithmSyntaxChecker
+ */
+ @Override
+ public SupportedAlgorithmSyntaxChecker build()
+ {
+ return new SupportedAlgorithmSyntaxChecker( oid );
+ }
}
-
+
/**
- * {@inheritDoc}
+ * Creates a new instance of SupportedAlgorithmSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public boolean isValidSyntax( Object value )
+ private SupportedAlgorithmSyntaxChecker( String oid )
{
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java
index ce2fd5c..3ee32f8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java
@@ -20,7 +20,10 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.util.Strings;
/**
@@ -29,14 +32,104 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class SyntaxCheckerSyntaxChecker extends Ia5StringSyntaxChecker
+public final class SyntaxCheckerSyntaxChecker extends SyntaxChecker
{
/**
- * Creates a new instance of SyntaxCheckerSyntaxChecker.
+ * A static instance of SyntaxCheckerSyntaxChecker
*/
- public SyntaxCheckerSyntaxChecker()
+ public static final SyntaxCheckerSyntaxChecker INSTANCE =
+ new SyntaxCheckerSyntaxChecker( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<SyntaxCheckerSyntaxChecker>
{
- super();
- setOid( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of SyntaxCheckerSyntaxChecker
+ * @return A new instance of SyntaxCheckerSyntaxChecker
+ */
+ @Override
+ public SyntaxCheckerSyntaxChecker build()
+ {
+ return new SyntaxCheckerSyntaxChecker( oid );
+ }
+ }
+
+ /**
+ * Creates a new instance of SyntaxCheckerSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
+ */
+ private SyntaxCheckerSyntaxChecker( String oid )
+ {
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValidSyntax( Object value )
+ {
+ String strValue;
+
+ if ( value == null )
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
+ return true;
+ }
+
+ if ( value instanceof String )
+ {
+ strValue = ( String ) value;
+ }
+ else if ( value instanceof byte[] )
+ {
+ strValue = Strings.utf8ToString( ( byte[] ) value );
+ }
+ else
+ {
+ strValue = value.toString();
+ }
+
+ boolean result = Strings.isIA5String( strValue );
+
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+ }
+
+ return result;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
index 6b6927f..68727a3 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
@@ -20,25 +20,24 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
-import java.util.ArrayList;
-import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a TelephoneNumber according to ITU
* recommendation E.123 (which is quite vague ...).
- *
+ * <p>
* A valid Telephone number respects more or less this syntax :
*
+ * <pre>
* " *[+]? *((\([0-9- ,;/#*]+\))|[0-9- ,;/#*]+)+"
+ * </pre>
*
* If needed, and to allow more syntaxes, a list of regexps has been added
* which can be initialized to other values
@@ -46,99 +45,141 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class TelephoneNumberSyntaxChecker extends SyntaxChecker
+public final class TelephoneNumberSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( TelephoneNumberSyntaxChecker.class );
-
- /** Other regexps to extend the initial one */
- private List<String> regexps;
-
- /** Other regexp to extend the initial one, compiled */
- private List<Pattern> compiledREs;
-
/** The default pattern used to check a TelephoneNumber */
private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;/#*]+\\))|[0-9- ,;/#*]+)+$";
+
+ /** The default pattern */
+ private final String defaultRegexp;
/** The compiled default pattern */
- private Pattern defaultPattern = Pattern.compile( DEFAULT_REGEXP );
-
- /** A flag set when only the default regexp should be tested */
- protected boolean defaultMandatory = false;
-
+ private final Pattern defaultPattern;
/**
- * Creates a new instance of TelephoneNumberSyntaxChecker.
+ * A static instance of TelephoneNumberSyntaxChecker
*/
- public TelephoneNumberSyntaxChecker()
- {
- super( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
- }
-
-
+ public static final TelephoneNumberSyntaxChecker INSTANCE =
+ new TelephoneNumberSyntaxChecker( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
+
/**
- * Add a new valid regexp for a Telephone number
- * @param regexp The new regexp to check
+ * A static Builder for this class
*/
- public void addRegexp( String regexp )
+ public static final class Builder extends SCBuilder<TelephoneNumberSyntaxChecker>
{
- if ( defaultMandatory )
+ /** The default pattern */
+ private String defaultRegexp;
+
+ /** The compiled default pattern */
+ private Pattern defaultPattern;
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
{
- return;
+ super( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
+ setDefaultRegexp( DEFAULT_REGEXP );
+ }
+
+
+ /**
+ * Create a new instance of TelephoneNumberSyntaxChecker
+ * @return A new instance of TelephoneNumberSyntaxChecker
+ */
+ @Override
+ public TelephoneNumberSyntaxChecker build()
+ {
+ return new TelephoneNumberSyntaxChecker( oid, defaultRegexp, defaultPattern );
}
- try
- {
- Pattern compiledRE = Pattern.compile( regexp );
- if ( regexps == null )
+ /**
+ * Set the default regular expression for the Telephone number
+ *
+ * @param regexp the default regular expression.
+ */
+ public Builder setDefaultRegexp( String regexp )
+ {
+ defaultRegexp = regexp;
+
+ try
{
- regexps = new ArrayList<String>();
- compiledREs = new ArrayList<Pattern>();
+ defaultPattern = Pattern.compile( regexp );
+ }
+ catch ( PatternSyntaxException pse )
+ {
+ // Roll back to the default pattern
+ defaultPattern = Pattern.compile( DEFAULT_REGEXP );
}
- regexps.add( regexp );
- compiledREs.add( compiledRE );
+ return this;
}
- catch ( PatternSyntaxException pse )
- {
- return;
- }
+ }
+
+
+ /**
+ * Creates a new instance of a child of this class, with an OID.
+ *
+ * @param oid the child's OID
+ */
+ private TelephoneNumberSyntaxChecker( String oid )
+ {
+ this( oid, DEFAULT_REGEXP, Pattern.compile( DEFAULT_REGEXP ) );
+ }
+
+
+ /**
+ * Creates a new instance of a child of this class, with an OID.
+ *
+ * @param oid the child's OID
+ * @param defaultRegexp The regexp to use
+ * @param defaultPattern The compiled version of the regexp
+ */
+ private TelephoneNumberSyntaxChecker( String oid, String defaultRegexp, Pattern defaultPattern )
+ {
+ super( oid );
+
+ this.defaultPattern = defaultPattern;
+ this.defaultRegexp = defaultRegexp;
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
- * Set the defaut regular expression for the Telephone number
+ * Get the default regexp (either the original one, or the one that has been set)
*
- * @param regexp the default regular expression.
+ * @return The default regexp
*/
- public void setDefaultRegexp( String regexp )
+ public String getRegexp()
{
- try
- {
- defaultPattern = Pattern.compile( regexp );
-
- defaultMandatory = true;
- regexps = null;
- compiledREs = null;
- }
- catch ( PatternSyntaxException pse )
- {
- return;
- }
+ return defaultRegexp;
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -157,56 +198,35 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// We will use a regexp to check the TelephoneNumber.
- if ( defaultMandatory )
+ boolean result;
+
+ // Not sure this is 100% necessary...
+ synchronized ( defaultPattern )
{
- // We have a unique regexp to check, the default one
- boolean result = defaultPattern.matcher( strValue ).matches();
+ result = defaultPattern.matcher( strValue ).matches();
+ }
+ if ( LOG.isDebugEnabled() )
+ {
if ( result )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
}
else
{
- LOG.debug( "Syntax invalid for '{}'", value );
- }
-
- return result;
- }
- else
- {
- if ( defaultPattern.matcher( strValue ).matches() )
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
- else
- {
- if ( compiledREs == null )
- {
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
- }
-
- // The default is not enough, let's try
- // the other regexps
- for ( Pattern pattern : compiledREs )
- {
- if ( pattern.matcher( strValue ).matches() )
- {
- LOG.debug( "Syntax valid for '{}'", value );
- return true;
- }
- }
-
- LOG.debug( "Syntax invalid for '{}'", value );
- return false;
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
}
}
+
+ return result;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java
index 3399a3f..b12eff2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java
@@ -20,17 +20,16 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a TeletexTerminalIdentifier according to
* RFC 4517 :
- *
+ * <pre>
* teletex-id = ttx-term *(DOLLAR ttx-param)
* ttx-term = PrintableString ; terminal identifier
* ttx-param = ttx-key COLON ttx-value ; parameter
@@ -38,35 +37,79 @@
* ttx-value = *ttx-value-octet
*
* ttx-value-octet = %x00-23 | (%x5C "24") | %x25-5B | (%x5C "5C") | %x5D-FF
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class TeletexTerminalIdentifierSyntaxChecker extends SyntaxChecker
+public final class TeletexTerminalIdentifierSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( TeletexTerminalIdentifierSyntaxChecker.class );
+ /**
+ * A static instance of TeletexTerminalIdentifierSyntaxChecker
+ */
+ public static final TeletexTerminalIdentifierSyntaxChecker INSTANCE =
+ new TeletexTerminalIdentifierSyntaxChecker( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<TeletexTerminalIdentifierSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of TeletexTerminalIdentifierSyntaxChecker
+ * @return A new instance of TeletexTerminalIdentifierSyntaxChecker
+ */
+ @Override
+ public TeletexTerminalIdentifierSyntaxChecker build()
+ {
+ return new TeletexTerminalIdentifierSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of TeletexTerminalIdentifier.
+ *
+ * @param oid the child's OID
*/
- public TeletexTerminalIdentifierSyntaxChecker()
+ private TeletexTerminalIdentifierSyntaxChecker( String oid )
{
- super( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -85,42 +128,62 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Search for the first '$' separator
int dollar = strValue.indexOf( '$' );
- String terminalIdentifier = ( ( dollar == -1 ) ? strValue : strValue.substring( 0, dollar ) );
+ String terminalIdentifier = ( dollar == -1 ) ? strValue : strValue.substring( 0, dollar );
if ( terminalIdentifier.length() == 0 )
{
// It should not be null
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
if ( !Strings.isPrintableString( terminalIdentifier ) )
{
// It's not a valid PrintableString
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
if ( dollar == -1 )
{
// No ttx-param : let's get out
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
- // Ok, now let's deal withh optional ttx-params
+ // Ok, now let's deal with optional ttx-params
String[] ttxParams = strValue.substring( dollar + 1 ).split( "\\$" );
if ( ttxParams.length == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -131,7 +194,11 @@
if ( colon == -1 )
{
// we must have a ':' separator
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -145,7 +212,11 @@
{
if ( colon + 1 == ttxParam.length() )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -157,14 +228,22 @@
{
case 0x24:
// '$' is not accepted
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
case 0x5c:
if ( hasEsc )
{
// two following \ are not accepted
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
else
@@ -204,12 +283,20 @@
}
else
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
}
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+
return true;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
index 6566a1c..c666f1f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
@@ -20,50 +20,93 @@
package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a Telex Number according to
* RFC 4517 :
- *
+ * <pre>
* telex-number = actual-number DOLLAR country-code DOLLAR answerback
* actual-number = PrintableString
* country-code = PrintableString
* answerback = PrintableString
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class TelexNumberSyntaxChecker extends SyntaxChecker
+public final class TelexNumberSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( TelexNumberSyntaxChecker.class );
+ /**
+ * A static instance of TelexNumberSyntaxChecker
+ */
+ public static final TelexNumberSyntaxChecker INSTANCE =
+ new TelexNumberSyntaxChecker( SchemaConstants.TELEX_NUMBER_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<TelexNumberSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.TELEX_NUMBER_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of TelexNumberSyntaxChecker
+ * @return A new instance of TelexNumberSyntaxChecker
+ */
+ @Override
+ public TelexNumberSyntaxChecker build()
+ {
+ return new TelexNumberSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of TelexNumberSyntaxChecker.
+ *
+ * @param oid the child's OID
*/
- public TelexNumberSyntaxChecker()
+ private TelexNumberSyntaxChecker( String oid )
{
- super( SchemaConstants.TELEX_NUMBER_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -82,7 +125,11 @@
if ( strValue.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -93,7 +140,11 @@
if ( dollar <= 0 )
{
// No '$' => error
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -102,14 +153,22 @@
// The actualNumber must not be empty
if ( actualNumber.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// The actual number should be a PrintableString
if ( !Strings.isPrintableString( actualNumber ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -120,7 +179,11 @@
if ( dollar2 == -1 )
{
// No '$' => error
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -129,14 +192,22 @@
// The countryCode must not be empty
if ( countryCode.length() == 0 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// The country Code should be a PrintableString
if ( !Strings.isPrintableString( countryCode ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -144,7 +215,11 @@
if ( dollar2 + 1 == strValue.length() )
{
// The last string should not be null
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
@@ -153,20 +228,27 @@
// The answerBack should be a PrintableString
if ( !Strings.isPrintableString( answerBack ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Check that the mailboxType is a PrintableString
boolean result = Strings.isPrintableString( answerBack );
- if ( result )
+ if ( LOG.isDebugEnabled() )
{
- LOG.debug( "Syntax valid for '{}'", value );
- }
- else
- {
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( result )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
+ else
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
return result;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
index 7126dc7..c600bf8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
@@ -22,18 +22,18 @@
import java.util.regex.Pattern;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A SyntaxChecker which verifies that a value is a UTC time
* according to RFC 4517.
- *
+ * <p>
* From RFC 4517 :
+ * <pre>
* UTCTime = year month day hour minute [ second ] [ u-time-zone ]
* u-time-zone = %x5A ; "Z" | u-differential
* u-differential = ( MINUS | PLUS ) hour minute
@@ -57,16 +57,13 @@
*
* From RFC 4512 :
* PLUS = %x2B ; plus sign ("+")
- *
+ * </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class UtcTimeSyntaxChecker extends SyntaxChecker
+public final class UtcTimeSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( UtcTimeSyntaxChecker.class );
-
/** The GeneralizedDate pattern matching */
private static final String UTC_TIME_PATTERN =
// year : 00 to 99
@@ -88,29 +85,73 @@
// The regexp pattern, java.util.regex.Pattern is immutable so only one instance is needed.
private static final Pattern DATE_PATTERN = Pattern.compile( UTC_TIME_PATTERN );
-
-
+
/**
- *
+ * A static instance of UtcTimeSyntaxChecker
+ */
+ public static final UtcTimeSyntaxChecker INSTANCE = new UtcTimeSyntaxChecker( SchemaConstants.UTC_TIME_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<UtcTimeSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.UTC_TIME_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of UtcTimeSyntaxChecker
+ * @return A new instance of UtcTimeSyntaxChecker
+ */
+ @Override
+ public UtcTimeSyntaxChecker build()
+ {
+ return new UtcTimeSyntaxChecker( oid );
+ }
+ }
+
+
+ /**
* Creates a new instance of UtcTimeSyntaxChecker.
*
+ * @param oid The OID to use for this SyntaxChecker
*/
- public UtcTimeSyntaxChecker()
+ private UtcTimeSyntaxChecker( String oid )
{
- super( SchemaConstants.UTC_TIME_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
- String strValue = null;
+ String strValue;
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -130,21 +171,37 @@
// A generalized time must have a minimal length of 11
if ( strValue.length() < 11 )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
// Start the date parsing
- boolean result = DATE_PATTERN.matcher( strValue ).find();
+ boolean result;
+
+ synchronized ( DATE_PATTERN )
+ {
+ result = DATE_PATTERN.matcher( strValue ).find();
+ }
if ( result )
{
- LOG.debug( "Syntax valid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+ }
}
else
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
}
+
return result;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
index f99ee8c..f933e83 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
@@ -22,44 +22,86 @@
import java.util.UUID;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* An UUID syntax checker.
- *
+ * <pre>
* UUID ::= OCTET STRING (SIZE(16)) -- constrained to an UUID [RFC4122]
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@SuppressWarnings("serial")
-public class UuidSyntaxChecker extends SyntaxChecker
+public final class UuidSyntaxChecker extends SyntaxChecker
{
- /** A logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( UuidSyntaxChecker.class );
+ /**
+ * A static instance of UuidSyntaxChecker
+ */
+ public static final UuidSyntaxChecker INSTANCE = new UuidSyntaxChecker( SchemaConstants.UUID_SYNTAX );
+
+ /**
+ * A static Builder for this class
+ */
+ public static final class Builder extends SCBuilder<UuidSyntaxChecker>
+ {
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.UUID_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of UuidSyntaxChecker
+ * @return A new instance of UuidSyntaxChecker
+ */
+ @Override
+ public UuidSyntaxChecker build()
+ {
+ return new UuidSyntaxChecker( oid );
+ }
+ }
-
+
/**
* Creates a new instance of UUIDSyntaxChecker.
+ *
+ * @param oid The OID to use for this SyntaxChecker
*/
- public UuidSyntaxChecker()
+ private UuidSyntaxChecker( String oid )
{
- super( SchemaConstants.UUID_SYNTAX );
+ super( oid );
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValidSyntax( Object value )
{
if ( value == null )
{
- LOG.debug( "Syntax invalid for 'null'" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+ }
+
return false;
}
@@ -70,7 +112,11 @@
if ( !( value instanceof String ) )
{
- LOG.debug( "Syntax invalid for '{}'", value );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+ }
+
return false;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AdministrativeRole.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AdministrativeRole.java
index e67d8e7..84b3d48 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AdministrativeRole.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AdministrativeRole.java
@@ -61,7 +61,7 @@
/**
* Creates an instance of AdministrativeRole
*/
- private AdministrativeRole( String role )
+ AdministrativeRole( String role )
{
this.role = Strings.toLowerCaseAscii( Strings.trim( role ) );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AndRefinement.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AndRefinement.java
index c8109c1..2fc8d59 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AndRefinement.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/AndRefinement.java
@@ -33,7 +33,7 @@
public class AndRefinement implements Refinement
{
/** The set of refinements */
- private List<Refinement> refinements = new ArrayList<Refinement>();
+ private List<Refinement> refinements = new ArrayList<>();
/**
@@ -59,6 +59,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java
index 33f8598..05d1d62 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/BaseSubtreeSpecification.java
@@ -177,6 +177,7 @@
/**
* @return The base
*/
+ @Override
public Dn getBase()
{
return this.base;
@@ -186,6 +187,7 @@
/**
* @return The set of ChopBefore exclusions
*/
+ @Override
public Set<Dn> getChopBeforeExclusions()
{
return this.chopBefore;
@@ -195,6 +197,7 @@
/**
* @return The set of ChopAfter exclusions
*/
+ @Override
public Set<Dn> getChopAfterExclusions()
{
return this.chopAfter;
@@ -204,6 +207,7 @@
/**
* @return The mimimum distance from the base
*/
+ @Override
public int getMinBaseDistance()
{
return this.minBaseDistance;
@@ -213,6 +217,7 @@
/**
* @return The maximum distance from the base
*/
+ @Override
public int getMaxBaseDistance()
{
return this.maxBaseDistance;
@@ -222,6 +227,7 @@
/**
* @return The refinement
*/
+ @Override
public ExprNode getRefinement()
{
return this.refinement;
@@ -234,6 +240,7 @@
*
* @param buffer the string buffer
*/
+ @Override
public void toString( StringBuilder buffer )
{
buffer.append( toString() );
@@ -243,6 +250,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder buffer = new StringBuilder();
@@ -354,7 +362,6 @@
{
if ( isFirst )
{
- isFirst = false;
buffer.append( " " );
}
else
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ItemRefinement.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ItemRefinement.java
index 06fba4e..924571f 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ItemRefinement.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ItemRefinement.java
@@ -67,6 +67,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/NotRefinement.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/NotRefinement.java
index a69669a..05266b2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/NotRefinement.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/NotRefinement.java
@@ -32,6 +32,11 @@
private Refinement refinement;
+ /**
+ * Creates a new NotRefinement instance
+ *
+ * @param refinement The filter
+ */
public NotRefinement( Refinement refinement )
{
this.refinement = refinement;
@@ -50,6 +55,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/OrRefinement.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/OrRefinement.java
index a0f7633..3b2943c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/OrRefinement.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/OrRefinement.java
@@ -33,7 +33,7 @@
public class OrRefinement implements Refinement
{
/** The set of refinements */
- private List<Refinement> refinements = new ArrayList<Refinement>();
+ private List<Refinement> refinements = new ArrayList<>();
/**
@@ -59,6 +59,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationChecker.java
index d803476..9ca02cc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationChecker.java
@@ -41,7 +41,7 @@
/**
* Creates a ReusableAntlrSubtreeSpecificationParser instance.
*/
- public ReusableAntlrSubtreeSpecificationChecker( TokenStream lexer )
+ ReusableAntlrSubtreeSpecificationChecker( TokenStream lexer )
{
super( lexer );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationParser.java
index 715022e..21e07d1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/ReusableAntlrSubtreeSpecificationParser.java
@@ -41,7 +41,7 @@
/**
* Creates a ReusableAntlrSubtreeSpecificationParser instance.
*/
- public ReusableAntlrSubtreeSpecificationParser( TokenStream lexer )
+ ReusableAntlrSubtreeSpecificationParser( TokenStream lexer )
{
super( lexer );
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java
index c19cc0c..588aa8e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/Subentry.java
@@ -130,6 +130,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "Subentry[" + administrativeRoles + ", " + ss + "]";
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java
index eeb64b1..310067e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationChecker.java
@@ -90,7 +90,7 @@
*/
public synchronized void parse( String spec ) throws ParseException
{
- if ( spec == null || spec.trim().equals( "" ) )
+ if ( ( spec == null ) || ( spec.trim().length() == 0 ) )
{
return;
}
@@ -102,17 +102,7 @@
{
this.parser.wrapperEntryPoint();
}
- catch ( TokenStreamException e )
- {
- String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
- throw new ParseException( msg, 0 );
- }
- catch ( RecognitionException e )
- {
- String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
- throw new ParseException( msg, e.getColumn() );
- }
- catch ( Exception e )
+ catch ( TokenStreamException | RecognitionException e )
{
String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
throw new ParseException( msg, 0 );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java
index c176465..00efc83 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationModifier.java
@@ -160,8 +160,6 @@
* Sets a filter using only assertions on objectClass attributes for subtree
* refinement.
*
- * TODO: there is a setFilter() method, remove this method?
- *
* @param refinement a filter using only assertions on objectClass attributes for
* subtree refinement
*/
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java
index 9ebc0d3..619a240 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/subtree/SubtreeSpecificationParser.java
@@ -115,9 +115,9 @@
*/
public synchronized SubtreeSpecification parse( String spec ) throws ParseException
{
- SubtreeSpecification ss = null;
+ SubtreeSpecification ss;
- if ( spec == null || spec.trim().equals( "" ) )
+ if ( ( spec == null ) || ( spec.trim().length() == 0 ) )
{
return null;
}
@@ -129,17 +129,7 @@
{
ss = this.parser.wrapperEntryPoint();
}
- catch ( TokenStreamException e )
- {
- String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
- throw new ParseException( msg, 0 );
- }
- catch ( RecognitionException e )
- {
- String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
- throw new ParseException( msg, e.getColumn() );
- }
- catch ( Exception e )
+ catch ( TokenStreamException | RecognitionException e )
{
String msg = I18n.err( I18n.ERR_04329, spec, e.getLocalizedMessage() );
throw new ParseException( msg, 0 );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/HostTypeEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/HostTypeEnum.java
index 801458c..702bec2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/HostTypeEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/HostTypeEnum.java
@@ -34,8 +34,15 @@
*/
public enum HostTypeEnum
{
+ /** IP V4 host */
IPV4,
+
+ /** IP V6 host */
IPV6,
+
+ /** IP V(future) host */
IPV_FUTURE,
+
+ /** Regular name host */
REGULAR_NAME
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
index 185567e..f42c61b 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java
@@ -156,10 +156,29 @@
host = null;
port = -1;
dn = null;
- attributes = new ArrayList<String>();
+ attributes = new ArrayList<>();
scope = SearchScope.OBJECT;
filter = null;
- extensionList = new ArrayList<Extension>( 2 );
+ extensionList = new ArrayList<>( 2 );
+ }
+
+
+ /**
+ * Create a new LdapUrl from a String after having parsed it.
+ *
+ * @param string TheString that contains the LdapUrl
+ * @throws LdapURLEncodingException If the String does not comply with RFC 2255
+ */
+ public LdapUrl( String string ) throws LdapURLEncodingException
+ {
+ if ( string == null )
+ {
+ throw new LdapURLEncodingException( I18n.err( I18n.ERR_04408 ) );
+ }
+
+ bytes = Strings.getBytesUtf8( string );
+ this.string = string;
+ parse( string.toCharArray() );
}
@@ -175,10 +194,10 @@
host = null;
port = -1;
dn = null;
- attributes = new ArrayList<String>();
+ attributes = new ArrayList<>();
scope = SearchScope.OBJECT;
filter = null;
- extensionList = new ArrayList<Extension>( 2 );
+ extensionList = new ArrayList<>( 2 );
if ( ( chars == null ) || ( chars.length == 0 ) )
{
@@ -194,6 +213,7 @@
// The scheme
pos = Strings.areEquals( chars, 0, LDAP_SCHEME );
+
if ( pos == StringConstants.NOT_EQUAL )
{
pos = Strings.areEquals( chars, 0, LDAPS_SCHEME );
@@ -329,25 +349,6 @@
/**
- * Create a new LdapUrl from a String after having parsed it.
- *
- * @param string TheString that contains the LdapUrl
- * @throws LdapURLEncodingException If the String does not comply with RFC 2255
- */
- public LdapUrl( String string ) throws LdapURLEncodingException
- {
- if ( string == null )
- {
- throw new LdapURLEncodingException( I18n.err( I18n.ERR_04408 ) );
- }
-
- bytes = Strings.getBytesUtf8( string );
- this.string = string;
- parse( string.toCharArray() );
- }
-
-
- /**
* Parse this rule : <br>
* <pre>
* host = IP-literal / IPv4address / reg-name
@@ -517,7 +518,7 @@
if ( containsCompressedZeroes )
{
- List<String> octetList = new ArrayList<String>( Arrays.asList( octets ) );
+ List<String> octetList = new ArrayList<>( Arrays.asList( octets ) );
if ( inet6Address.endsWith( "::" ) )
{
@@ -542,7 +543,7 @@
for ( int index = 0; index < octets.length; index++ )
{
- String octet = ( String ) octets[index];
+ String octet = octets[index];
if ( octet.length() == 0 )
{
@@ -879,22 +880,37 @@
{
int ipElemValue = 0;
boolean ipElemSeen = false;
- boolean hasTailingZeroes = false;
+ boolean hasHeadingZeroes = false;
while ( Chars.isDigit( chars, pos ) )
{
ipElemSeen = true;
- ipElemValue = ( ipElemValue * 10 ) + ( chars[pos] - '0' );
-
- if ( ( chars[pos] == '0' ) && hasTailingZeroes && ( ipElemValue > 0 ) )
+
+ if ( chars[pos] == '0' )
{
- // Two 0 at the beginning : not allowed
- return -1;
+ if ( hasHeadingZeroes )
+ {
+ // Two 0 at the beginning : not allowed
+ return -1;
+ }
+
+ if ( ipElemValue > 0 )
+ {
+ ipElemValue = ipElemValue * 10;
+ }
+ else
+ {
+ hasHeadingZeroes = true;
+ }
+ }
+ else
+ {
+ hasHeadingZeroes = false;
+ ipElemValue = ( ipElemValue * 10 ) + ( chars[pos] - '0' );
}
if ( ipElemValue > 255 )
{
- // We don't allow IPV4 address with values > 255
return -1;
}
@@ -904,7 +920,7 @@
if ( ipElemSeen )
{
ipElem[octetNb] = ipElemValue;
-
+
return pos;
}
else
@@ -1034,7 +1050,7 @@
{
if ( bytes == null )
{
- return StringConstants.EMPTY_BYTES;
+ return Strings.EMPTY_BYTES;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@@ -1117,11 +1133,7 @@
String dnStr = new String( chars, pos, end - pos );
dn = new Dn( decode( dnStr ) );
}
- catch ( LdapUriException ue )
- {
- return -1;
- }
- catch ( LdapInvalidDnException de )
+ catch ( LdapUriException | LdapInvalidDnException e )
{
return -1;
}
@@ -1166,7 +1178,7 @@
{
int start = pos;
int end = pos;
- Set<String> hAttributes = new HashSet<String>();
+ Set<String> hAttributes = new HashSet<>();
boolean hadComma = false;
try
@@ -1300,11 +1312,7 @@
filter = decode( new String( chars, pos, end - pos ) );
FilterParser.parse( null, filter );
}
- catch ( LdapUriException ue )
- {
- return -1;
- }
- catch ( ParseException pe )
+ catch ( LdapUriException | ParseException e )
{
return -1;
}
@@ -1422,7 +1430,7 @@
try
{
- for ( int i = pos; ( i < chars.length ); i++ )
+ for ( int i = pos; i < chars.length; i++ )
{
if ( Chars.isCharASCII( chars, i, ',' ) )
{
@@ -1713,7 +1721,6 @@
* Get a string representation of a LdapUrl.
*
* @return A LdapUrl string
- * @see LdapUrl#forceScopeRendering
*/
@Override
public String toString()
@@ -1750,8 +1757,8 @@
{
sb.append( '/' ).append( urlEncode( dn.getName(), false ) );
- if ( ( attributes.size() != 0 ) || forceScopeRendering
- || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || ( extensionList.size() != 0 ) ) )
+ if ( !attributes.isEmpty() || forceScopeRendering
+ || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) )
{
sb.append( '?' );
@@ -1780,7 +1787,7 @@
}
else
{
- if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || ( extensionList.size() != 0 ) )
+ if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() )
{
sb.append( '?' );
@@ -1795,7 +1802,7 @@
break;
}
- if ( ( filter != null ) || ( ( extensionList.size() != 0 ) ) )
+ if ( ( filter != null ) || !extensionList.isEmpty() )
{
sb.append( "?" );
@@ -1804,13 +1811,13 @@
sb.append( urlEncode( filter, false ) );
}
- if ( ( extensionList.size() != 0 ) )
+ if ( !extensionList.isEmpty() )
{
sb.append( '?' );
boolean isFirst = true;
- if ( extensionList.size() != 0 )
+ if ( !extensionList.isEmpty() )
{
for ( Extension extension : extensionList )
{
@@ -1972,7 +1979,7 @@
*/
public int getNbBytes()
{
- return ( bytes != null ? bytes.length : 0 );
+ return bytes != null ? bytes.length : 0;
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/AttributeTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/AttributeTest.java
index f3b9738..e2a8b13 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/AttributeTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/AttributeTest.java
@@ -38,7 +38,6 @@
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -155,7 +154,7 @@
/**
- * @throws java.lang.Exception
+ * @throws Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception
@@ -641,10 +640,10 @@
Attribute attr2 = new DefaultAttribute( "test" );
- nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
+ nbAdded = attr2.add( Strings.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, attr2.getBytes() ) );
assertEquals( 1, attr2.size() );
Attribute attr3 = new DefaultAttribute( "test" );
@@ -1179,10 +1178,10 @@
Attribute attr2 = new DefaultAttribute( "test" );
- nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
+ nbAdded = attr2.add( Strings.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, attr2.getBytes() ) );
Attribute attr3 = new DefaultAttribute( "test" );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueAttributeTypeTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueAttributeTypeTest.java
index a84ecfb..51078ab 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueAttributeTypeTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueAttributeTypeTest.java
@@ -43,7 +43,6 @@
import org.apache.directory.api.ldap.model.schema.Normalizer;
import org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.Before;
import org.junit.Test;
@@ -87,7 +86,7 @@
public void initAT()
{
s = EntryUtils.syntaxFactory( "1.1.1.1", false );
- s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ s.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
mr.setSyntax( s );
@@ -252,9 +251,9 @@
{
AttributeType attribute = EntryUtils.getBytesAttributeType();
- BinaryValue value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
+ BinaryValue value = new BinaryValue( attribute, Strings.EMPTY_BYTES );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, value.getReference() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getReference() ) );
assertFalse( value.isNull() );
}
@@ -306,10 +305,10 @@
assertEquals( bv, bv1 );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertNotSame( bv, bv1 );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) );
bv = new BinaryValue( BYTES2 );
bv1 = bv.clone();
@@ -370,8 +369,8 @@
BinaryValue value = new BinaryValue( attribute, null );
assertNull( value.getNormValue() );
- value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, value.getNormValue() ) );
+ value = new BinaryValue( attribute, Strings.EMPTY_BYTES );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getNormValue() ) );
value = new BinaryValue( attribute, BYTES2 );
assertTrue( Arrays.equals( BYTES1, value.getNormValue() ) );
@@ -389,8 +388,8 @@
BinaryValue value = new BinaryValue( attribute, null );
assertNull( value.getNormValue() );
- value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, value.getNormValue() ) );
+ value = new BinaryValue( attribute, Strings.EMPTY_BYTES );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getNormValue() ) );
value = new BinaryValue( attribute, BYTES2 );
assertTrue( Arrays.equals( BYTES1, value.getNormValue() ) );
@@ -408,8 +407,8 @@
BinaryValue value = new BinaryValue( attribute, null );
assertNull( value.getNormReference() );
- value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, value.getNormReference() ) );
+ value = new BinaryValue( attribute, Strings.EMPTY_BYTES );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getNormReference() ) );
value = new BinaryValue( attribute, BYTES2 );
assertTrue( Arrays.equals( BYTES1, value.getNormReference() ) );
@@ -440,7 +439,7 @@
AttributeType attribute = EntryUtils.getBytesAttributeType();
new BinaryValue( attribute, null );
- new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
+ new BinaryValue( attribute, Strings.EMPTY_BYTES );
new BinaryValue( attribute, new byte[]
{ 0x01, 0x02 } );
@@ -515,9 +514,9 @@
bv.apply( at );
assertEquals( null, bv.getNormValue() );
- bv = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( attribute, Strings.EMPTY_BYTES );
bv.apply( at );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getNormValue() ) );
bv = new BinaryValue( attribute, BYTES2 );
bv.apply( at );
@@ -639,13 +638,13 @@
public void testEmptyBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
- BinaryValue sbv = new BinaryValue( at, StringConstants.EMPTY_BYTES );
+ BinaryValue sbv = new BinaryValue( at, Strings.EMPTY_BYTES );
sbv.apply( at );
byte[] normalized = sbv.getNormReference();
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, normalized ) );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, sbv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, normalized ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, sbv.getBytes() ) );
BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java
index 1356ed0..63be25d 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java
@@ -42,7 +42,6 @@
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
import org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.Before;
import org.junit.Test;
@@ -83,7 +82,7 @@
public void initAT()
{
s = EntryUtils.syntaxFactory( "1.1.1.1", false );
- s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ s.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
mr.setSyntax( s );
@@ -226,8 +225,8 @@
BinaryValue bv = new BinaryValue( ( byte[] ) null );
assertEquals( 0, bv.hashCode() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
- int h = Arrays.hashCode( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
+ int h = Arrays.hashCode( Strings.EMPTY_BYTES );
assertEquals( h, bv.hashCode() );
h = Arrays.hashCode( BYTES1 );
@@ -252,17 +251,17 @@
@Test
public void testBinaryValueEmpty() throws LdapException
{
- BinaryValue cbv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ BinaryValue cbv = new BinaryValue( Strings.EMPTY_BYTES );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getBytes() ) );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getValue() ) );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getReference() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, cbv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, cbv.getValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, cbv.getReference() ) );
assertFalse( cbv.isSchemaAware() );
assertTrue( cbv.isValid( BINARY_CHECKER ) );
assertFalse( cbv.isNull() );
assertNotNull( cbv.getNormValue() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormValue() ) );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormReference() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, cbv.getNormValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, cbv.getNormReference() ) );
}
@@ -331,11 +330,11 @@
assertTrue( bv.isSchemaAware() );
assertEquals( null, bv.getNormValue() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
bv.apply( at );
assertTrue( bv.isSchemaAware() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getNormValue() ) );
bv = new BinaryValue( BYTES1 );
bv.apply( at );
@@ -423,9 +422,9 @@
assertNull( bv.getValue() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertNotNull( bv.getValue() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getValue() ) );
bv = new BinaryValue( BYTES1 );
byte[] copy = bv.getValue();
@@ -476,7 +475,7 @@
assertEquals( "null", bv.toString() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertEquals( "", bv.toString() );
bv = new BinaryValue( BYTES1 );
@@ -491,9 +490,9 @@
assertNull( bv.getReference() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertNotNull( bv.getReference() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getReference() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getReference() ) );
bv = new BinaryValue( BYTES1 );
byte[] reference = bv.getReference();
@@ -513,9 +512,9 @@
assertNull( bv.getValue() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertNotNull( bv.getValue() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) );
bv = new BinaryValue( BYTES1 );
byte[] get = bv.getBytes();
@@ -577,7 +576,7 @@
assertTrue( bv.isNull() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertFalse( bv.isNull() );
bv = new BinaryValue( BYTES1 );
@@ -592,7 +591,7 @@
assertTrue( bv.isValid( BINARY_CHECKER ) );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertTrue( bv.isValid( BINARY_CHECKER ) );
bv = new BinaryValue( BYTES1 );
@@ -612,7 +611,7 @@
assertTrue( bv.isValid( BINARY_CHECKER ) );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertTrue( bv.isValid( BINARY_CHECKER ) );
bv = new BinaryValue( BYTES1 );
@@ -632,10 +631,10 @@
assertTrue( bv.isSchemaAware() );
assertEquals( null, bv.getNormValue() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
bv.apply( at );
assertTrue( bv.isSchemaAware() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getNormValue() ) );
bv = new BinaryValue( BYTES2 );
bv.apply( at );
@@ -655,9 +654,9 @@
assertTrue( bv.isValid( BINARY_CHECKER ) );
assertTrue( bv.isNull() );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
assertNotNull( bv.getValue() );
- assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
+ assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) );
assertFalse( bv.isSchemaAware() );
assertTrue( bv.isValid( BINARY_CHECKER ) );
assertFalse( bv.isNull() );
@@ -794,7 +793,7 @@
public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
{
BinaryValue bv = new BinaryValue( ( byte[] ) null );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
bv.isValid( BINARY_CHECKER );
bv.apply( at );
@@ -813,7 +812,7 @@
public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
{
BinaryValue bv = new BinaryValue( ( byte[] ) null );
- bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+ bv = new BinaryValue( Strings.EMPTY_BYTES );
bv.isValid( BINARY_CHECKER );
BinaryValue cbvSer = deserializeValue( null, serializeValue( bv ) );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java
index 89a24cf..47182fb 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java
@@ -84,7 +84,7 @@
public void initAT()
{
s = new EntryUtils.S( "1.1.1.1", true );
- s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ s.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mr = new EntryUtils.MR( "1.1.2.1" );
mr.setSyntax( s );
mr.setLdapComparator( new StringComparator( "1.1.2.1" ) );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java
index 304f633..2d8e5d7 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java
@@ -70,7 +70,7 @@
public static void initAT()
{
s = new EntryUtils.S( "1.1.1.1", true );
- s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ s.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mr = new EntryUtils.MR( "1.1.2.1" );
mr.setSyntax( s );
mr.setLdapComparator( new StringComparator( "1.1.2.1" ) );
@@ -215,7 +215,7 @@
assertNull( csv.getValue() );
assertFalse( csv.isSchemaAware() );
- assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( csv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertTrue( csv.isNull() );
assertNull( csv.getNormValue() );
}
@@ -232,7 +232,7 @@
assertNotNull( csv.getValue() );
assertEquals( "", csv.getString() );
assertFalse( csv.isSchemaAware() );
- assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( csv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertFalse( csv.isNull() );
assertNotNull( csv.getNormValue() );
assertEquals( "", csv.getNormValue() );
@@ -249,7 +249,7 @@
assertEquals( "test", csv.getValue() );
assertFalse( csv.isSchemaAware() );
- assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( csv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertFalse( csv.isNull() );
assertNotNull( csv.getNormValue() );
assertEquals( "test", csv.getNormValue() );
@@ -295,21 +295,21 @@
assertNull( sv.getValue() );
assertFalse( sv.isSchemaAware() );
- assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( sv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertTrue( sv.isNull() );
sv = new StringValue( "" );
assertNotNull( sv.getValue() );
assertEquals( "", sv.getValue() );
assertFalse( sv.isSchemaAware() );
- assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( sv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertFalse( sv.isNull() );
sv = new StringValue( "Test" );
assertNotNull( sv.getValue() );
assertEquals( "Test", sv.getValue() );
assertFalse( sv.isSchemaAware() );
- assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( sv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
assertFalse( sv.isNull() );
}
@@ -438,10 +438,10 @@
{
StringValue sv = new StringValue( "Test" );
- assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertTrue( sv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
sv = new StringValue( "é" );
- assertFalse( sv.isValid( new Ia5StringSyntaxChecker() ) );
+ assertFalse( sv.isValid( Ia5StringSyntaxChecker.INSTANCE ) );
}
@@ -530,7 +530,7 @@
{
StringValue csv = new StringValue( "TEST" );
csv.apply( at );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
assertNotSame( csv, csvSer );
@@ -547,7 +547,7 @@
public void testSerializeNotNormalized() throws LdapException, IOException, ClassNotFoundException
{
StringValue csv = new StringValue( "Test" );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
assertNotSame( csv, csvSer );
@@ -564,7 +564,7 @@
public void testSerializeEmptyNormalized() throws LdapException, IOException, ClassNotFoundException
{
StringValue csv = new StringValue( " " );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
csv.apply( at );
StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
@@ -582,7 +582,7 @@
public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException
{
StringValue csv = new StringValue( ( String ) null );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
csv.apply( at );
StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
@@ -600,7 +600,7 @@
public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
{
StringValue csv = new StringValue( "" );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
csv.apply( at );
StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
@@ -618,7 +618,7 @@
public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
{
StringValue csv = new StringValue( "" );
- csv.isValid( new Ia5StringSyntaxChecker() );
+ csv.isValid( Ia5StringSyntaxChecker.INSTANCE );
StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
assertNotSame( csv, csvSer );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java
index 3ba3240..d3ef879 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java
@@ -35,7 +35,6 @@
import org.apache.directory.api.ldap.model.schema.comparators.StringComparator;
import org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.Before;
import org.junit.Ignore;
@@ -58,10 +57,10 @@
private static byte[] data = new byte[]
{ 0x01, 0x02, 0x03, 0x04 };
BinaryValue bv1 = new BinaryValue( data );
- BinaryValue bv2 = new BinaryValue( StringConstants.EMPTY_BYTES );
+ BinaryValue bv2 = new BinaryValue( Strings.EMPTY_BYTES );
BinaryValue bv3 = new BinaryValue( ( byte[] ) null );
BinaryValue bv1n = new BinaryValue( data );
- BinaryValue bv2n = new BinaryValue( StringConstants.EMPTY_BYTES );
+ BinaryValue bv2n = new BinaryValue( Strings.EMPTY_BYTES );
BinaryValue bv3n = new BinaryValue( ( byte[] ) null );
StringValue sv1 = new StringValue( "test" );
StringValue sv2 = new StringValue( "" );
@@ -87,7 +86,7 @@
public void initAT()
{
sb = new EntryUtils.S( "1.1.1.1", false );
- sb.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ sb.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mrb = new EntryUtils.MR( "1.1.2.1" );
mrb.setSyntax( sb );
@@ -131,7 +130,7 @@
atb.setSyntax( sb );
ss = new EntryUtils.S( "1.1.1.1", true );
- ss.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ ss.setSyntaxChecker( OctetStringSyntaxChecker.INSTANCE );
mrs = new EntryUtils.MR( "1.1.2.1" );
mrs.setSyntax( ss );
mrs.setLdapComparator( new StringComparator( "1.1.2.1" ) );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
index 8174f4f..215d61f 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterParserTest.java
@@ -29,6 +29,7 @@
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.List;
+import java.util.Locale;
import com.mycila.junit.concurrent.Concurrency;
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
@@ -1146,4 +1147,38 @@
String str = "(&(o_u~=people)(a_g_e>=30))";
FilterParser.parse( str, false );
}
+
+
+ @Test
+ public void testRelaxedFilterParse() throws ParseException
+ {
+ String str = " ( cn =*) ";
+ ExprNode node = FilterParser.parse( str, false );
+
+ assertTrue( node instanceof PresenceNode );
+ assertEquals( "cn", ((PresenceNode)node).attribute );
+
+ str = " ( & ( cn =*) ) ";
+ node = FilterParser.parse( str, false );
+
+ assertTrue( node instanceof AndNode );
+ assertEquals( 1, ((AndNode)node).children.size() );
+
+ ExprNode child = ((AndNode)node).children.get( 0 );
+ assertTrue( child instanceof PresenceNode );
+ assertEquals( "cn", ((PresenceNode)child).attribute );
+ }
+
+
+ @Test
+ public void testFilterWithSpecialChars() throws ParseException
+ {
+ String filterStr = String.format( Locale.ROOT, "(%s=%s)", "cn", FilterEncoder.encodeFilterValue( "ACME(tm)" ) );
+
+ assertEquals( "(cn=ACME\\28tm\\29)", filterStr );
+
+ String filterStr2 = new EqualityNode<>( "cn", new StringValue( "ACME(tm)" ) ).toString();
+
+ assertEquals( "(cn=ACME\\28tm\\29)", filterStr2 );
+ }
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifControlSerializationTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifControlSerializationTest.java
index c02196e..03bac6f 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifControlSerializationTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/ldif/LdifControlSerializationTest.java
@@ -31,7 +31,7 @@
import org.apache.directory.api.ldap.model.ldif.LdifControl;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.controls.OpaqueControl;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,7 +71,7 @@
controlCriticalEmptyData = new OpaqueControl( "1.2.3.4.3" );
controlCriticalEmptyData.setCritical( true );
- ( ( OpaqueControl ) controlCriticalEmptyData ).setEncodedValue( StringConstants.EMPTY_BYTES );
+ ( ( OpaqueControl ) controlCriticalEmptyData ).setEncodedValue( Strings.EMPTY_BYTES );
controlNoCriticalWithData = new OpaqueControl( "1.2.3.4.4" );
controlNoCriticalWithData.setCritical( false );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/controls/OpaqueControlTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/controls/OpaqueControlTest.java
index a2ff581..4149c5a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/controls/OpaqueControlTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/controls/OpaqueControlTest.java
@@ -24,7 +24,7 @@
import static org.junit.Assert.assertTrue;
import org.apache.directory.api.ldap.model.message.controls.OpaqueControl;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.junit.Test;
@@ -41,7 +41,7 @@
assertFalse( control.hasEncodedValue() );
- control.setEncodedValue( StringConstants.EMPTY_BYTES );
+ control.setEncodedValue( Strings.EMPTY_BYTES );
assertTrue( control.hasEncodedValue() );
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/password/PasswordUtilTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/password/PasswordUtilTest.java
index 8fafee5..3a8ba78 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/password/PasswordUtilTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/password/PasswordUtilTest.java
@@ -22,6 +22,7 @@
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_CRYPT;
+import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_CRYPT_BCRYPT;
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_CRYPT_MD5;
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_CRYPT_SHA256;
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_CRYPT_SHA512;
@@ -36,6 +37,7 @@
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_SSHA256;
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_SSHA384;
import static org.apache.directory.api.ldap.model.constants.LdapSecurityConstants.HASH_METHOD_SSHA512;
+import static org.apache.directory.api.ldap.model.password.PasswordUtil.CRYPT_BCRYPT_LENGTH;
import static org.apache.directory.api.ldap.model.password.PasswordUtil.CRYPT_LENGTH;
import static org.apache.directory.api.ldap.model.password.PasswordUtil.CRYPT_MD5_LENGTH;
import static org.apache.directory.api.ldap.model.password.PasswordUtil.CRYPT_SHA256_LENGTH;
@@ -348,8 +350,26 @@
}
- private void testPassword( String plainText, String encrypted, LdapSecurityConstants algorithm, int passwordLength,
- int saltLength )
+ @Test
+ public void testPasswordCRYPT2aEncrypted()
+ {
+ testPassword( "secret",
+ "{CRYPT}$2a$06$LH2xIb/TZmajuLJGDNuegeeY.SCwkg6YAVLNXTh8n4Xfb1uwmLXg6",
+ HASH_METHOD_CRYPT_BCRYPT, CRYPT_BCRYPT_LENGTH, 29 );
+ }
+
+
+ @Test
+ public void testPasswordCRYPT2aEncryptedLowercase()
+ {
+ testPassword( "secret",
+ "{crypt}$2a$06$LH2xIb/TZmajuLJGDNuegeeY.SCwkg6YAVLNXTh8n4Xfb1uwmLXg6",
+ HASH_METHOD_CRYPT_BCRYPT, CRYPT_BCRYPT_LENGTH, 29 );
+ }
+
+
+ private void testPassword(String plainText, String encrypted, LdapSecurityConstants algorithm, int passwordLength,
+ int saltLength )
{
// assert findAlgorithm
assertEquals( algorithm, PasswordUtil.findAlgorithm( Strings.getBytesUtf8( encrypted ) ) );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SchemaUtilsTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SchemaUtilsTest.java
index d20adaf..5c87560 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SchemaUtilsTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SchemaUtilsTest.java
@@ -125,36 +125,36 @@
/**
* Tests rendering operations on qdescrs render method. Both overloaded
- * operations {@link org.apache.directory.api.ldap.model.schema.SchemaUtils#render(StringBuffer, String[])} and
+ * operations {@link org.apache.directory.api.ldap.model.schema.SchemaUtils#render(StringBuilder, String[])} and
* {@link org.apache.directory.api.ldap.model.schema.SchemaUtils#render(String[])} are tested here.
*/
@Test
public void testRenderQdescrs()
{
- assertEquals( "", SchemaUtils.renderQDescrs( new StringBuffer(), ( List<String> ) null ).toString() );
- assertEquals( "", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), ( List<String> ) null ).toString() );
+ assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{} ) ).toString() );
- assertEquals( "'name1'", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "'name1'", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1" } ) ).toString() );
- assertEquals( "( 'name1' 'name2' )", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "( 'name1' 'name2' )", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1", "name2" } ) ).toString() );
assertEquals( "( 'name1' 'name2' 'name3' )",
- SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1", "name2", "name3" } ) ).toString() );
- assertEquals( "", SchemaUtils.renderQDescrs( new StringBuffer(), ( List<String> ) null ).toString() );
+ assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), ( List<String> ) null ).toString() );
- assertEquals( "", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{} ) ).toString() );
- assertEquals( "'name1'", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "'name1'", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1" } ) ).toString() );
- assertEquals( "( 'name1' 'name2' )", SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ assertEquals( "( 'name1' 'name2' )", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1", "name2" } ) ).toString() );
assertEquals( "( 'name1' 'name2' 'name3' )",
- SchemaUtils.renderQDescrs( new StringBuffer(), Arrays.asList( new String[]
+ SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[]
{ "name1", "name2", "name3" } ) ).toString() );
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SyntaxCheckerTest.java
index 01aad6c..cdde2b1 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/SyntaxCheckerTest.java
@@ -55,10 +55,10 @@
@Before
public void initNames() throws Exception
{
- objectClassA = new AccessPointSyntaxChecker();
- objectClassACopy = new AccessPointSyntaxChecker();
- objectClassB = new AccessPointSyntaxChecker();
- objectClassC = new CountrySyntaxChecker();
+ objectClassA = AccessPointSyntaxChecker.INSTANCE;
+ objectClassACopy = AccessPointSyntaxChecker.INSTANCE;
+ objectClassB = AccessPointSyntaxChecker.INSTANCE;
+ objectClassC = CountrySyntaxChecker.INSTANCE;
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
index ed23e24..dd91f1e 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
@@ -33,11 +33,38 @@
public class DummySyntaxChecker extends SyntaxChecker
{
/**
- * Creates a new instance of DummySyntaxChecker.
+ * A static Builder for this class
*/
- public DummySyntaxChecker()
+ public static final class Builder extends SCBuilder<DummySyntaxChecker>
{
- super( SchemaConstants.OCTET_STRING_SYNTAX );
+
+ /**
+ * The Builder constructor
+ */
+ private Builder()
+ {
+ super( SchemaConstants.OCTET_STRING_SYNTAX );
+ }
+
+
+ /**
+ * Create a new instance of DummySyntaxChecker
+ * @return A new instance of DummySyntaxChecker
+ */
+ @Override
+ public DummySyntaxChecker build()
+ {
+ return new DummySyntaxChecker( oid );
+ }
+ }
+
+
+ /**
+ * @return An instance of the Builder for this class
+ */
+ public static Builder builder()
+ {
+ return new Builder();
}
@@ -46,7 +73,7 @@
*
* @param oid The Syntax's OID
*/
- public DummySyntaxChecker( String oid )
+ private DummySyntaxChecker( String oid )
{
super( oid );
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AccessPointSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AccessPointSyntaxCheckerTest.java
index 0c053ed..3212539 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AccessPointSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AccessPointSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class AccessPointSyntaxCheckerTest
{
- AccessPointSyntaxChecker checker = new AccessPointSyntaxChecker();
+ AccessPointSyntaxChecker checker = AccessPointSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AttributeTypeDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AttributeTypeDescriptionSyntaxCheckerTest.java
index ab06bc1..73d6213 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AttributeTypeDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AttributeTypeDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class AttributeTypeDescriptionSyntaxCheckerTest
{
- private AttributeTypeDescriptionSyntaxChecker checker = new AttributeTypeDescriptionSyntaxChecker();
+ private AttributeTypeDescriptionSyntaxChecker checker = AttributeTypeDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AudioSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AudioSyntaxCheckerTest.java
index aeb8d5d..0f24da6 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AudioSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/AudioSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class AudioSyntaxCheckerTest
{
- AudioSyntaxChecker checker = new AudioSyntaxChecker();
+ AudioSyntaxChecker checker = AudioSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BinarySyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BinarySyntaxCheckerTest.java
index 6ef3868..9de303a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BinarySyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BinarySyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class BinarySyntaxCheckerTest
{
- BinarySyntaxChecker checker = new BinarySyntaxChecker();
+ BinarySyntaxChecker checker = BinarySyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BitStringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BitStringSyntaxCheckerTest.java
index 163071b..f50e4cb 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BitStringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BitStringSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class BitStringSyntaxCheckerTest
{
- BitStringSyntaxChecker checker = new BitStringSyntaxChecker();
+ BitStringSyntaxChecker checker = BitStringSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
index 202da2c..9cbe1d7 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
@@ -40,12 +40,13 @@
@Concurrency()
public class BooleanSyntaxCheckerTest
{
- BooleanSyntaxChecker checker = new BooleanSyntaxChecker();
+ BooleanSyntaxChecker checker = BooleanSyntaxChecker.INSTANCE;
@Test
public void testNullString()
{
+ BooleanSyntaxChecker checker = BooleanSyntaxChecker.builder().setOid( "1.2.3.4" ).build();
assertFalse( checker.isValidSyntax( null ) );
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateListSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateListSyntaxCheckerTest.java
index 1b35852..4ebc914 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateListSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateListSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CertificateListSyntaxCheckerTest
{
- CertificateListSyntaxChecker checker = new CertificateListSyntaxChecker();
+ CertificateListSyntaxChecker checker = CertificateListSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificatePairSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificatePairSyntaxCheckerTest.java
index d9e14c0..87d5561 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificatePairSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificatePairSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CertificatePairSyntaxCheckerTest
{
- CertificatePairSyntaxChecker checker = new CertificatePairSyntaxChecker();
+ CertificatePairSyntaxChecker checker = CertificatePairSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateSyntaxCheckerTest.java
index 41a2a07..ce1b6ee 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CertificateSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CertificateSyntaxCheckerTest
{
- CertificateSyntaxChecker checker = new CertificateSyntaxChecker();
+ CertificateSyntaxChecker checker = CertificateSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CountrySyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CountrySyntaxCheckerTest.java
index 8386609..69e2ca6 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CountrySyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CountrySyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CountrySyntaxCheckerTest
{
- CountrySyntaxChecker checker = new CountrySyntaxChecker();
+ CountrySyntaxChecker checker = CountrySyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSidSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSidSyntaxCheckerTest.java
index 30217a3..ebb1726 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSidSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSidSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CsnSidSyntaxCheckerTest
{
- CsnSidSyntaxChecker checker = new CsnSidSyntaxChecker();
+ CsnSidSyntaxChecker checker = CsnSidSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSyntaxCheckerTest.java
index f994646..3ccd898 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/CsnSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class CsnSyntaxCheckerTest
{
- CsnSyntaxChecker checker = new CsnSyntaxChecker();
+ CsnSyntaxChecker checker = CsnSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DataQualitySyntaxSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DataQualitySyntaxSyntaxCheckerTest.java
index 70af81e..1270488 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DataQualitySyntaxSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DataQualitySyntaxSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DataQualitySyntaxSyntaxCheckerTest
{
- DataQualitySyntaxSyntaxChecker checker = new DataQualitySyntaxSyntaxChecker();
+ DataQualitySyntaxSyntaxChecker checker = DataQualitySyntaxSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DeliveryMethodSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DeliveryMethodSyntaxCheckerTest.java
index fed5d1b..ec17ef1 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DeliveryMethodSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DeliveryMethodSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DeliveryMethodSyntaxCheckerTest
{
- DeliveryMethodSyntaxChecker checker = new DeliveryMethodSyntaxChecker();
+ DeliveryMethodSyntaxChecker checker = DeliveryMethodSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DirectoryStringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DirectoryStringSyntaxCheckerTest.java
index 1e14277..7259a6b 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DirectoryStringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DirectoryStringSyntaxCheckerTest.java
@@ -41,7 +41,7 @@
@Concurrency()
public class DirectoryStringSyntaxCheckerTest
{
- DirectoryStringSyntaxChecker checker = new DirectoryStringSyntaxChecker();
+ DirectoryStringSyntaxChecker checker = DirectoryStringSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitContentRuleDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitContentRuleDescriptionSyntaxCheckerTest.java
index 3cd5b9f..dba8a87 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitContentRuleDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitContentRuleDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class DitContentRuleDescriptionSyntaxCheckerTest
{
- private DitContentRuleDescriptionSyntaxChecker checker = new DitContentRuleDescriptionSyntaxChecker();
+ private DitContentRuleDescriptionSyntaxChecker checker = DitContentRuleDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitStructureRuleDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitStructureRuleDescriptionSyntaxCheckerTest.java
index bb8bda0..9e1b7d1 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitStructureRuleDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DitStructureRuleDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class DitStructureRuleDescriptionSyntaxCheckerTest
{
- private DitStructureRuleDescriptionSyntaxChecker checker = new DitStructureRuleDescriptionSyntaxChecker();
+ private DitStructureRuleDescriptionSyntaxChecker checker = DitStructureRuleDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DlSubmitPermissionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DlSubmitPermissionSyntaxCheckerTest.java
index b77e6cd..c379f80 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DlSubmitPermissionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DlSubmitPermissionSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DlSubmitPermissionSyntaxCheckerTest
{
- DlSubmitPermissionSyntaxChecker checker = new DlSubmitPermissionSyntaxChecker();
+ DlSubmitPermissionSyntaxChecker checker = DlSubmitPermissionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DnSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DnSyntaxCheckerTest.java
index 09a2a63..b0dd176 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DnSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DnSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DnSyntaxCheckerTest
{
- DnSyntaxChecker checker = new DnSyntaxChecker();
+ DnSyntaxChecker checker = DnSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DsaQualitySyntaxSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DsaQualitySyntaxSyntaxCheckerTest.java
index d881c7e..5d9a5b1 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DsaQualitySyntaxSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DsaQualitySyntaxSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DsaQualitySyntaxSyntaxCheckerTest
{
- DsaQualitySyntaxSyntaxChecker checker = new DsaQualitySyntaxSyntaxChecker();
+ DsaQualitySyntaxSyntaxChecker checker = DsaQualitySyntaxSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DseTypeSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DseTypeSyntaxCheckerTest.java
index f404597..73c8a4a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DseTypeSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/DseTypeSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class DseTypeSyntaxCheckerTest
{
- DseTypeSyntaxChecker checker = new DseTypeSyntaxChecker();
+ DseTypeSyntaxChecker checker = DseTypeSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/EnhancedGuideSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/EnhancedGuideSyntaxCheckerTest.java
index d30f140..ba48554 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/EnhancedGuideSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/EnhancedGuideSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class EnhancedGuideSyntaxCheckerTest
{
- EnhancedGuideSyntaxChecker checker = new EnhancedGuideSyntaxChecker();
+ EnhancedGuideSyntaxChecker checker = EnhancedGuideSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
index a49f3b6..571fc1a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
@@ -27,6 +27,7 @@
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.FacsimileTelephoneNumberSyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.TelephoneNumberSyntaxChecker;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +41,7 @@
@Concurrency()
public class FacsimileTelephoneNumberSyntaxCheckerTest
{
- FacsimileTelephoneNumberSyntaxChecker checker = new FacsimileTelephoneNumberSyntaxChecker();
+ FacsimileTelephoneNumberSyntaxChecker checker = FacsimileTelephoneNumberSyntaxChecker.INSTANCE;
@Test
@@ -89,8 +90,9 @@
public void testWithNewMandatoryRegexp()
{
// Adding french telephone number regexp
- checker.setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" );
-
+ checker = FacsimileTelephoneNumberSyntaxChecker.builder().
+ setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" ).build();
+
assertFalse( checker.isValidSyntax( "+ 123 ( 456 )7891 12345" ) );
assertTrue( checker.isValidSyntax( " 01 02 03 04 05 " ) );
assertTrue( checker.isValidSyntax( " 0102 03 04 05 " ) );
@@ -101,6 +103,14 @@
@Test
+ public void testBuilderSetsDefaultPattern()
+ {
+ checker = FacsimileTelephoneNumberSyntaxChecker.builder().build();
+ assertTrue( checker.isValidSyntax( "1" ) );
+ }
+
+
+ @Test
public void testCorrectTelephoneNumberAndFaxParam()
{
assertTrue( checker.isValidSyntax( "+ 33 1 (456) 7891 12345$twoDimensional" ) );
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FaxSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FaxSyntaxCheckerTest.java
index b952066..6a2630a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FaxSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FaxSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class FaxSyntaxCheckerTest
{
- FaxSyntaxChecker checker = new FaxSyntaxChecker();
+ FaxSyntaxChecker checker = FaxSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GeneralizedTimeSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GeneralizedTimeSyntaxCheckerTest.java
index 841cc5e..1b6da14 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GeneralizedTimeSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GeneralizedTimeSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class GeneralizedTimeSyntaxCheckerTest
{
- GeneralizedTimeSyntaxChecker checker = new GeneralizedTimeSyntaxChecker();
+ GeneralizedTimeSyntaxChecker checker = GeneralizedTimeSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GuideSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GuideSyntaxCheckerTest.java
index a96a0b5..5d6aef1 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GuideSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/GuideSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class GuideSyntaxCheckerTest
{
- GuideSyntaxChecker checker = new GuideSyntaxChecker();
+ GuideSyntaxChecker checker = GuideSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/Ia5StringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/Ia5StringSyntaxCheckerTest.java
index 44cedbc..d75b412 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/Ia5StringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/Ia5StringSyntaxCheckerTest.java
@@ -41,7 +41,7 @@
@Concurrency()
public class Ia5StringSyntaxCheckerTest
{
- Ia5StringSyntaxChecker checker = new Ia5StringSyntaxChecker();
+ Ia5StringSyntaxChecker checker = Ia5StringSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/IntegerSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/IntegerSyntaxCheckerTest.java
index 5687dc8..42c216c 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/IntegerSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/IntegerSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class IntegerSyntaxCheckerTest
{
- IntegerSyntaxChecker checker = new IntegerSyntaxChecker();
+ IntegerSyntaxChecker checker = IntegerSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaByteSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaByteSyntaxCheckerTest.java
index c2422c6..8c86e9e 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaByteSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaByteSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class JavaByteSyntaxCheckerTest
{
- JavaByteSyntaxChecker checker = new JavaByteSyntaxChecker();
+ JavaByteSyntaxChecker checker = JavaByteSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaIntegerSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaIntegerSyntaxCheckerTest.java
index 95dfab3..ceb2a14 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaIntegerSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaIntegerSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class JavaIntegerSyntaxCheckerTest
{
- JavaIntegerSyntaxChecker checker = new JavaIntegerSyntaxChecker();
+ JavaIntegerSyntaxChecker checker = JavaIntegerSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaLongSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaLongSyntaxCheckerTest.java
index ba69eee..cb43b52 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaLongSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaLongSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class JavaLongSyntaxCheckerTest
{
- JavaLongSyntaxChecker checker = new JavaLongSyntaxChecker();
+ JavaLongSyntaxChecker checker = JavaLongSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaShortSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaShortSyntaxCheckerTest.java
index 0182d73..00b8ffc 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaShortSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JavaShortSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class JavaShortSyntaxCheckerTest
{
- JavaShortSyntaxChecker checker = new JavaShortSyntaxChecker();
+ JavaShortSyntaxChecker checker = JavaShortSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JpegSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JpegSyntaxCheckerTest.java
index ada74cf..166ef92 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JpegSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/JpegSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class JpegSyntaxCheckerTest
{
- JpegSyntaxChecker checker = new JpegSyntaxChecker();
+ JpegSyntaxChecker checker = JpegSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/LdapSyntaxDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/LdapSyntaxDescriptionSyntaxCheckerTest.java
index e5c26e5..3900bce 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/LdapSyntaxDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/LdapSyntaxDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class LdapSyntaxDescriptionSyntaxCheckerTest
{
- private LdapSyntaxDescriptionSyntaxChecker checker = new LdapSyntaxDescriptionSyntaxChecker();
+ private LdapSyntaxDescriptionSyntaxChecker checker = LdapSyntaxDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MailPreferenceSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MailPreferenceSyntaxCheckerTest.java
index e31a73a..716a469 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MailPreferenceSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MailPreferenceSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class MailPreferenceSyntaxCheckerTest
{
- MailPreferenceSyntaxChecker checker = new MailPreferenceSyntaxChecker();
+ MailPreferenceSyntaxChecker checker = MailPreferenceSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MasterAndShadowAccessPointSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MasterAndShadowAccessPointSyntaxCheckerTest.java
index 74bc8e0..0e6d5aa 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MasterAndShadowAccessPointSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MasterAndShadowAccessPointSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class MasterAndShadowAccessPointSyntaxCheckerTest
{
- MasterAndShadowAccessPointSyntaxChecker checker = new MasterAndShadowAccessPointSyntaxChecker();
+ MasterAndShadowAccessPointSyntaxChecker checker = MasterAndShadowAccessPointSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleDescriptionSyntaxCheckerTest.java
index 7d70c3e..e09d0a9 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class MatchingRuleDescriptionSyntaxCheckerTest
{
- private MatchingRuleDescriptionSyntaxChecker checker = new MatchingRuleDescriptionSyntaxChecker();
+ private MatchingRuleDescriptionSyntaxChecker checker = MatchingRuleDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleUseDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleUseDescriptionSyntaxCheckerTest.java
index a9562c8..59515eb 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleUseDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MatchingRuleUseDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class MatchingRuleUseDescriptionSyntaxCheckerTest
{
- private MatchingRuleUseDescriptionSyntaxChecker checker = new MatchingRuleUseDescriptionSyntaxChecker();
+ private MatchingRuleUseDescriptionSyntaxChecker checker = MatchingRuleUseDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MhsOrAddressSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MhsOrAddressSyntaxCheckerTest.java
index d408746..ee4e071 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MhsOrAddressSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/MhsOrAddressSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class MhsOrAddressSyntaxCheckerTest
{
- MhsOrAddressSyntaxChecker checker = new MhsOrAddressSyntaxChecker();
+ MhsOrAddressSyntaxChecker checker = MhsOrAddressSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameAndOptionalUIDSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameAndOptionalUIDSyntaxCheckerTest.java
index 5946f7a..c1ca88a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameAndOptionalUIDSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameAndOptionalUIDSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class NameAndOptionalUIDSyntaxCheckerTest
{
- NameAndOptionalUIDSyntaxChecker checker = new NameAndOptionalUIDSyntaxChecker();
+ NameAndOptionalUIDSyntaxChecker checker = NameAndOptionalUIDSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameFormDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameFormDescriptionSyntaxCheckerTest.java
index 70c64b7..19e4e95 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameFormDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameFormDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class NameFormDescriptionSyntaxCheckerTest
{
- private NameFormDescriptionSyntaxChecker checker = new NameFormDescriptionSyntaxChecker();
+ private NameFormDescriptionSyntaxChecker checker = NameFormDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameOrNumericIdSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameOrNumericIdSyntaxCheckerTest.java
index 934cd6d..490a723 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameOrNumericIdSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NameOrNumericIdSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class NameOrNumericIdSyntaxCheckerTest
{
- NumericOidSyntaxChecker checker = new NumericOidSyntaxChecker();
+ NumericOidSyntaxChecker checker = NumericOidSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NumericStringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NumericStringSyntaxCheckerTest.java
index f2c7898..0908bc3 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NumericStringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/NumericStringSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class NumericStringSyntaxCheckerTest
{
- NumericStringSyntaxChecker checker = new NumericStringSyntaxChecker();
+ NumericStringSyntaxChecker checker = NumericStringSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassDescriptionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassDescriptionSyntaxCheckerTest.java
index 075c30e..06bea7a 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassDescriptionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassDescriptionSyntaxCheckerTest.java
@@ -42,7 +42,7 @@
@Concurrency()
public class ObjectClassDescriptionSyntaxCheckerTest
{
- private ObjectClassDescriptionSyntaxChecker checker = new ObjectClassDescriptionSyntaxChecker();
+ private ObjectClassDescriptionSyntaxChecker checker = ObjectClassDescriptionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassTypeSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassTypeSyntaxCheckerTest.java
index 2a3de54..7ee52a3 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassTypeSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectClassTypeSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class ObjectClassTypeSyntaxCheckerTest
{
- ObjectClassTypeSyntaxChecker checker = new ObjectClassTypeSyntaxChecker();
+ ObjectClassTypeSyntaxChecker checker = ObjectClassTypeSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectNameSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectNameSyntaxCheckerTest.java
index f279298..0f12564 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectNameSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ObjectNameSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class ObjectNameSyntaxCheckerTest
{
- ObjectNameSyntaxChecker checker = new ObjectNameSyntaxChecker();
+ ObjectNameSyntaxChecker checker = ObjectNameSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OctetStringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OctetStringSyntaxCheckerTest.java
index dfaec3e..70848a6 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OctetStringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OctetStringSyntaxCheckerTest.java
@@ -26,7 +26,7 @@
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
-import org.apache.directory.api.util.StringConstants;
+import org.apache.directory.api.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +40,7 @@
@Concurrency()
public class OctetStringSyntaxCheckerTest
{
- OctetStringSyntaxChecker checker = new OctetStringSyntaxChecker();
+ OctetStringSyntaxChecker checker = OctetStringSyntaxChecker.INSTANCE;
@Test
@@ -53,7 +53,7 @@
@Test
public void testEmptyOctetString()
{
- assertTrue( checker.isValidSyntax( StringConstants.EMPTY_BYTES ) );
+ assertTrue( checker.isValidSyntax( Strings.EMPTY_BYTES ) );
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OtherMailboxSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OtherMailboxSyntaxCheckerTest.java
index bbcefc9..baf97ee 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OtherMailboxSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/OtherMailboxSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class OtherMailboxSyntaxCheckerTest
{
- OtherMailboxSyntaxChecker checker = new OtherMailboxSyntaxChecker();
+ OtherMailboxSyntaxChecker checker = OtherMailboxSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PostalAddressSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PostalAddressSyntaxCheckerTest.java
index 62a07c9..ac680ae 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PostalAddressSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PostalAddressSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class PostalAddressSyntaxCheckerTest
{
- PostalAddressSyntaxChecker checker = new PostalAddressSyntaxChecker();
+ PostalAddressSyntaxChecker checker = PostalAddressSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PresentationAddressSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PresentationAddressSyntaxCheckerTest.java
index 38c80ad..92ade7f 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PresentationAddressSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PresentationAddressSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class PresentationAddressSyntaxCheckerTest
{
- PresentationAddressSyntaxChecker checker = new PresentationAddressSyntaxChecker();
+ PresentationAddressSyntaxChecker checker = PresentationAddressSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PrintableStringSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PrintableStringSyntaxCheckerTest.java
index ce3cce1..8cf9bfe 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PrintableStringSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/PrintableStringSyntaxCheckerTest.java
@@ -41,7 +41,7 @@
@Concurrency()
public class PrintableStringSyntaxCheckerTest
{
- PrintableStringSyntaxChecker checker = new PrintableStringSyntaxChecker();
+ PrintableStringSyntaxChecker checker = PrintableStringSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ProtocolInformationSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ProtocolInformationSyntaxCheckerTest.java
index 5ca0845..fd289d5 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ProtocolInformationSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ProtocolInformationSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class ProtocolInformationSyntaxCheckerTest
{
- ProtocolInformationSyntaxChecker checker = new ProtocolInformationSyntaxChecker();
+ ProtocolInformationSyntaxChecker checker = ProtocolInformationSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SubstringAssertionSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SubstringAssertionSyntaxCheckerTest.java
index 4b16247..b4a42c3 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SubstringAssertionSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SubstringAssertionSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class SubstringAssertionSyntaxCheckerTest
{
- SubstringAssertionSyntaxChecker checker = new SubstringAssertionSyntaxChecker();
+ SubstringAssertionSyntaxChecker checker = SubstringAssertionSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierAndConsumerSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierAndConsumerSyntaxCheckerTest.java
index e41c6b7..38805b0 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierAndConsumerSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierAndConsumerSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class SupplierAndConsumerSyntaxCheckerTest
{
- SupplierAndConsumerSyntaxChecker checker = new SupplierAndConsumerSyntaxChecker();
+ SupplierAndConsumerSyntaxChecker checker = SupplierAndConsumerSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierInformationSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierInformationSyntaxCheckerTest.java
index 012ea56..2dce7b0 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierInformationSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierInformationSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class SupplierInformationSyntaxCheckerTest
{
- SupplierInformationSyntaxChecker checker = new SupplierInformationSyntaxChecker();
+ SupplierInformationSyntaxChecker checker = SupplierInformationSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierOrConsumerSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierOrConsumerSyntaxCheckerTest.java
index df78247..48ca1b3 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierOrConsumerSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupplierOrConsumerSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class SupplierOrConsumerSyntaxCheckerTest
{
- SupplierOrConsumerSyntaxChecker checker = new SupplierOrConsumerSyntaxChecker();
+ SupplierOrConsumerSyntaxChecker checker = SupplierOrConsumerSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupportedAlgorithmSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupportedAlgorithmSyntaxCheckerTest.java
index ed0b202..7325dac 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupportedAlgorithmSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/SupportedAlgorithmSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class SupportedAlgorithmSyntaxCheckerTest
{
- SupportedAlgorithmSyntaxChecker checker = new SupportedAlgorithmSyntaxChecker();
+ SupportedAlgorithmSyntaxChecker checker = SupportedAlgorithmSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
index f8b66ae..c344b7d 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
@@ -41,7 +41,7 @@
@Concurrency()
public class TelephoneNumberSyntaxCheckerTest
{
- TelephoneNumberSyntaxChecker checker = new TelephoneNumberSyntaxChecker();
+ TelephoneNumberSyntaxChecker checker = TelephoneNumberSyntaxChecker.INSTANCE;
@Test
@@ -98,7 +98,7 @@
public void testWithNewMandatoryRegexp()
{
// Adding french telephone number regexp
- checker.setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" );
+ checker = TelephoneNumberSyntaxChecker.builder().setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" ).build();
assertFalse( checker.isValidSyntax( "+ 123 ( 456 )7891 12345" ) );
assertTrue( checker.isValidSyntax( " 01 02 03 04 05 " ) );
@@ -107,4 +107,13 @@
assertTrue( checker.isValidSyntax( " 01/02/03/04/05 " ) );
assertFalse( checker.isValidSyntax( " 01 / 02 .03 04-- 05 " ) );
}
+
+
+ @Test
+ public void testBuilderSetsDefaultPattern()
+ {
+ checker = TelephoneNumberSyntaxChecker.builder().build();
+ assertTrue( checker.isValidSyntax( "1" ) );
+ }
+
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TeletexTerminalIdentifierSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TeletexTerminalIdentifierSyntaxCheckerTest.java
index 61766ba..c4a8f19 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TeletexTerminalIdentifierSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TeletexTerminalIdentifierSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class TeletexTerminalIdentifierSyntaxCheckerTest
{
- TeletexTerminalIdentifierSyntaxChecker checker = new TeletexTerminalIdentifierSyntaxChecker();
+ TeletexTerminalIdentifierSyntaxChecker checker = TeletexTerminalIdentifierSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelexNumberSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelexNumberSyntaxCheckerTest.java
index 1b7988e..cf84498 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelexNumberSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelexNumberSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class TelexNumberSyntaxCheckerTest
{
- TelexNumberSyntaxChecker checker = new TelexNumberSyntaxChecker();
+ TelexNumberSyntaxChecker checker = TelexNumberSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UtcTimeSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UtcTimeSyntaxCheckerTest.java
index a2a5d64..a4406df 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UtcTimeSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UtcTimeSyntaxCheckerTest.java
@@ -40,7 +40,7 @@
@Concurrency()
public class UtcTimeSyntaxCheckerTest
{
- UtcTimeSyntaxChecker checker = new UtcTimeSyntaxChecker();
+ UtcTimeSyntaxChecker checker = UtcTimeSyntaxChecker.INSTANCE;
@Test
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UuidSyntaxCheckerTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UuidSyntaxCheckerTest.java
index 11fcdba..dd37bca 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UuidSyntaxCheckerTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/UuidSyntaxCheckerTest.java
@@ -27,7 +27,6 @@
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.api.ldap.model.schema.syntaxCheckers.UuidSyntaxChecker;
-import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,7 +41,7 @@
@Concurrency()
public class UuidSyntaxCheckerTest
{
- UuidSyntaxChecker checker = new UuidSyntaxChecker();
+ UuidSyntaxChecker checker = UuidSyntaxChecker.INSTANCE;
@Test
@@ -55,7 +54,7 @@
@Test
public void testEmptyUuid()
{
- assertFalse( checker.isValidSyntax( StringConstants.EMPTY_BYTES ) );
+ assertFalse( checker.isValidSyntax( Strings.EMPTY_BYTES ) );
}
diff --git a/ldap/net/mina/pom.xml b/ldap/net/mina/pom.xml
index 3ebd50b..7db9f4e 100644
--- a/ldap/net/mina/pom.xml
+++ b/ldap/net/mina/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-net-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-net-mina</artifactId>
diff --git a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecActivator.java b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecActivator.java
index d63a844..760b021 100644
--- a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecActivator.java
+++ b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecActivator.java
@@ -45,7 +45,7 @@
private ServiceRegistration<?> registration;
- public LdapApiServiceTracker( BundleContext context )
+ LdapApiServiceTracker( BundleContext context )
{
this.bundleContext = context;
}
@@ -71,8 +71,6 @@
@Override
public void removedService( ServiceReference<LdapApiService> reference, LdapApiService service )
{
- // TODO should we unregister the LdapProtocolCodecFactory at LdapApiService?
- // ldapApiService.unregisterProtocolCodecFactory( factory );
registration.unregister();
}
}
@@ -89,10 +87,11 @@
/**
* {@inheritDoc}
*/
+ @Override
public void start( BundleContext bundleContext ) throws Exception
{
LdapApiServiceTracker ldapApiServiceTracker = new LdapApiServiceTracker( bundleContext );
- serviceTracker = new ServiceTracker<LdapApiService, LdapApiService>( bundleContext, LdapApiService.class,
+ serviceTracker = new ServiceTracker<>( bundleContext, LdapApiService.class,
ldapApiServiceTracker );
serviceTracker.open();
}
@@ -101,6 +100,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void stop( BundleContext bundleContext ) throws Exception
{
serviceTracker.close();
diff --git a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
index a962503..7428462 100644
--- a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
+++ b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
@@ -79,6 +79,7 @@
* @param session the IO session
* @return the decoder
*/
+ @Override
public ProtocolDecoder getDecoder( IoSession session )
{
return ldapDecoder;
@@ -91,6 +92,7 @@
* @param session the IO session
* @return the encoder
*/
+ @Override
public ProtocolEncoder getEncoder( IoSession session )
{
return ldapEncoder;
diff --git a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolDecoder.java b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolDecoder.java
index 3f99ab1..cbdf0b9 100644
--- a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolDecoder.java
+++ b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolDecoder.java
@@ -72,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws Exception
{
@SuppressWarnings("unchecked")
@@ -86,7 +87,7 @@
messageContainer.setMaxPDUSize( maxPDUSize );
}
- List<Message> decodedMessages = new ArrayList<Message>();
+ List<Message> decodedMessages = new ArrayList<>();
ByteBuffer buf = in.buf();
decode( buf, messageContainer, decodedMessages );
@@ -163,7 +164,7 @@
// Transform the DecoderException message to a MessageException
ResponseCarryingMessageException rcme = new ResponseCarryingMessageException( rce.getMessage(), rce );
- rcme.setResponse( ( ( ResponseCarryingException ) rce ).getResponse() );
+ rcme.setResponse( rce.getResponse() );
throw rcme;
}
@@ -182,6 +183,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
{
// Nothing to do
@@ -191,6 +193,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void dispose( IoSession session ) throws Exception
{
// Nothing to do
diff --git a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
index 5caf82f..8c72354 100644
--- a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
+++ b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
@@ -76,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception
{
ByteBuffer buffer = encoder.encodeMessage( ( Message ) message );
@@ -97,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void dispose( IoSession session ) throws Exception
{
// Nothing to do
diff --git a/ldap/net/pom.xml b/ldap/net/pom.xml
index b97b839..97cd65d 100644
--- a/ldap/net/pom.xml
+++ b/ldap/net/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-net-parent</artifactId>
diff --git a/ldap/pom.xml b/ldap/pom.xml
index a7755db..32131d3 100644
--- a/ldap/pom.xml
+++ b/ldap/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-parent</artifactId>
diff --git a/ldap/schema/converter/pom.xml b/ldap/schema/converter/pom.xml
index ea99d9d..ca88b28 100644
--- a/ldap/schema/converter/pom.xml
+++ b/ldap/schema/converter/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-schema-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-schema-converter</artifactId>
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/AttributeTypeHolder.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/AttributeTypeHolder.java
index b0eabf9..9e7f700 100755
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/AttributeTypeHolder.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/AttributeTypeHolder.java
@@ -306,6 +306,7 @@
* @return A ldif formatted string
* @throws org.apache.directory.api.ldap.model.exception.LdapException If something went wrong
*/
+ @Override
public String toLdif( String schemaName ) throws LdapException
{
StringBuilder sb = new StringBuilder();
@@ -385,6 +386,7 @@
/**
* @return a String representing this AttributeType.
*/
+ @Override
public String toString()
{
return getOid();
@@ -397,6 +399,7 @@
* @param schemaName The schema name
* @return the Dn associated with this schema in the DIT
*/
+ @Override
public String dnToLdif( String schemaName ) throws LdapException
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/ObjectClassHolder.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/ObjectClassHolder.java
index badeddc..c638a81 100755
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/ObjectClassHolder.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/ObjectClassHolder.java
@@ -41,13 +41,13 @@
public class ObjectClassHolder extends SchemaElementImpl
{
/** The list of superiors */
- private List<String> superiors = new ArrayList<String>();
+ private List<String> superiors = new ArrayList<>();
/** The list of mandatory attributes */
- private List<String> must = new ArrayList<String>();
+ private List<String> must = new ArrayList<>();
/** The list of optional attributes */
- private List<String> may = new ArrayList<String>();
+ private List<String> may = new ArrayList<>();
/** The ObjectClass type */
private ObjectClassTypeEnum classType = ObjectClassTypeEnum.STRUCTURAL;
@@ -148,6 +148,7 @@
* @return A ldif formatted string
* @throws org.apache.directory.api.ldap.model.exception.LdapException If something went wrong
*/
+ @Override
public String toLdif( String schemaName ) throws LdapException
{
StringBuilder sb = new StringBuilder();
@@ -155,7 +156,7 @@
sb.append( schemaToLdif( schemaName, "metaObjectClass" ) );
// The superiors
- if ( superiors.size() != 0 )
+ if ( !superiors.isEmpty() )
{
for ( String superior : superiors )
{
@@ -170,7 +171,7 @@
}
// The 'must'
- if ( must.size() != 0 )
+ if ( !must.isEmpty() )
{
for ( String attr : must )
{
@@ -179,7 +180,7 @@
}
// The 'may'
- if ( may.size() != 0 )
+ if ( !may.isEmpty() )
{
for ( String attr : may )
{
@@ -188,7 +189,7 @@
}
// The extensions
- if ( extensions.size() != 0 )
+ if ( !extensions.isEmpty() )
{
extensionsToLdif( "m-extensionObjectClass" );
}
@@ -200,6 +201,7 @@
/**
* @return a String representing this ObjectClass.
*/
+ @Override
public String toString()
{
return getOid();
@@ -212,6 +214,7 @@
* @param schemaName The schema name
* @return the Dn associated with this schema in the DIT
*/
+ @Override
public String dnToLdif( String schemaName ) throws LdapException
{
StringBuilder sb = new StringBuilder();
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/Schema.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/Schema.java
index 64b9028..458f902 100644
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/Schema.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/Schema.java
@@ -107,6 +107,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "Schema " + name + ".schema";
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaElementImpl.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaElementImpl.java
index 0773372..7298693 100644
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaElementImpl.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaElementImpl.java
@@ -50,18 +50,19 @@
protected String description;
/** The list of names for this schemaElements */
- protected List<String> names = new ArrayList<String>();
+ protected List<String> names = new ArrayList<>();
/** The obsolete flag */
protected boolean obsolete = false;
/** The optional list of extensions */
- protected Map<String, List<String>> extensions = new HashMap<String, List<String>>();
+ protected Map<String, List<String>> extensions = new HashMap<>();
/**
* {@inheritDoc}
*/
+ @Override
public boolean isObsolete()
{
return obsolete;
@@ -71,6 +72,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setObsolete( boolean obsolete )
{
this.obsolete = obsolete;
@@ -80,6 +82,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOid()
{
return oid;
@@ -89,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getDescription()
{
return description;
@@ -98,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setDescription( String description )
{
this.description = description;
@@ -107,6 +112,7 @@
/**
* @see SchemaElement#getNames()
*/
+ @Override
public List<String> getNames()
{
return names;
@@ -116,6 +122,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setNames( List<String> names )
{
this.names = names;
@@ -125,6 +132,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<String> getExtension( String key )
{
return extensions.get( key );
@@ -134,6 +142,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, List<String>> getExtensions()
{
return extensions;
@@ -143,6 +152,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setExtensions( Map<String, List<String>> extensions )
{
this.extensions = extensions;
@@ -164,7 +174,7 @@
*/
private String nameToLdif() throws LdapException
{
- if ( names.size() == 0 )
+ if ( names.isEmpty() )
{
return "";
}
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
index 5614137..b0badf0 100755
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
@@ -22,11 +22,12 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.text.ParseException;
import java.util.List;
@@ -187,7 +188,7 @@
*/
public synchronized void parse( File schemaFile ) throws IOException, ParseException
{
- schemaIn = new FileInputStream( schemaFile );
+ schemaIn = Files.newInputStream( Paths.get( schemaFile.getPath() ) );
if ( producerThread == null )
{
@@ -208,6 +209,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void run()
{
int count = -1;
diff --git a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaToLdif.java b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaToLdif.java
index eae1a67..6d861aa 100644
--- a/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaToLdif.java
+++ b/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaToLdif.java
@@ -74,7 +74,7 @@
public static void transform( List<Schema> schemas ) throws ParserException
{
// Bypass if no schemas have yet been defined
- if ( ( schemas == null ) || ( schemas.size() == 0 ) )
+ if ( ( schemas == null ) || schemas.isEmpty() )
{
LOG.warn( "No schemas defined!" );
return;
diff --git a/ldap/schema/data/pom.xml b/ldap/schema/data/pom.xml
index 4f7da8d..d8da4f1 100644
--- a/ldap/schema/data/pom.xml
+++ b/ldap/schema/data/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-schema-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-schema-data</artifactId>
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/UniqueResourceException.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/UniqueResourceException.java
index 052bb2d..3e63654 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/UniqueResourceException.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/UniqueResourceException.java
@@ -91,7 +91,7 @@
private static List<URL> toList( URL first, Enumeration<URL> urlEnum )
{
- ArrayList<URL> urls = new ArrayList<URL>();
+ ArrayList<URL> urls = new ArrayList<>();
urls.add( first );
while ( urlEnum.hasMoreElements() )
{
@@ -104,9 +104,11 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getMessage()
{
- StringBuffer buf = new StringBuffer( "Problem locating " ).append( resourceDescription ).append( "\n" );
+ StringBuilder buf = new StringBuilder( "Problem locating " ).append( resourceDescription ).append( "\n" );
+
if ( urls == null )
{
buf.append( "No resources named '" ).append( resourceName ).append( "' located on classpath" );
@@ -115,11 +117,13 @@
{
buf.append( "Multiple copies of resource named '" ).append( resourceName ).append(
"' located on classpath at urls" );
+
for ( URL url : urls )
{
buf.append( "\n " ).append( url );
}
}
+
return buf.toString();
}
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/DefaultSchemaLdifExtractor.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/DefaultSchemaLdifExtractor.java
index 7d5c32c..1a476ac 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/DefaultSchemaLdifExtractor.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/DefaultSchemaLdifExtractor.java
@@ -22,25 +22,27 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidObjectException;
+import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URL;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayDeque;
+import java.util.Deque;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Stack;
import java.util.UUID;
import java.util.regex.Pattern;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.api.ldap.model.ldif.LdapLdifException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.ldif.LdifReader;
import org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor;
@@ -121,6 +123,7 @@
*
* @return true if schema folder has already been extracted.
*/
+ @Override
public boolean isExtracted()
{
return extracted;
@@ -133,6 +136,7 @@
* @param overwrite over write extracted structure if true, false otherwise
* @throws IOException if schema already extracted and on IO errors
*/
+ @Override
public void extractOrCopy( boolean overwrite ) throws IOException
{
if ( !outputDirectory.exists() && !outputDirectory.mkdirs() )
@@ -180,6 +184,7 @@
*
* @throws IOException if schema already extracted and on IO errors
*/
+ @Override
public void extractOrCopy() throws IOException
{
extractOrCopy( false );
@@ -209,7 +214,8 @@
throw new FileNotFoundException( I18n.err( I18n.ERR_08002, source.getAbsolutePath() ) );
}
- try ( Writer out = new OutputStreamWriter( new FileOutputStream( destination ), Charset.defaultCharset() );
+ try ( Writer out = new OutputStreamWriter( Files.newOutputStream( Paths.get( destination.getPath() ) ),
+ Charset.defaultCharset() );
LdifReader ldifReader = new LdifReader( source ) )
{
boolean first = true;
@@ -240,20 +246,23 @@
}
// Add the version at the first line, to avoid a warning
- String ldifString = "version: 1\n" + ldifEntry.toString();
+ String ldifString;
+
+ if ( ldifEntry != null )
+ {
+ ldifString = "version: 1\n" + ldifEntry.toString();
+ }
+ else
+ {
+ ldifString = "version: 1\n";
+ }
out.write( ldifString );
out.flush();
}
- catch ( LdapLdifException ne )
+ catch ( LdapException le )
{
- String msg = I18n.err( I18n.ERR_08004, source, ne.getLocalizedMessage() );
- LOG.error( msg );
- throw new InvalidObjectException( msg );
- }
- catch ( LdapException ne )
- {
- String msg = I18n.err( I18n.ERR_08004, source, ne.getLocalizedMessage() );
+ String msg = I18n.err( I18n.ERR_08004, source, le.getLocalizedMessage() );
LOG.error( msg );
throw new InvalidObjectException( msg );
}
@@ -267,7 +276,7 @@
* @param fileComponentStack stack containing pushed file components
* @return the assembled destination file
*/
- private File assembleDestinationFile( Stack<String> fileComponentStack )
+ private File assembleDestinationFile( Deque<String> fileComponentStack )
{
File destinationFile = outputDirectory.getAbsoluteFile();
@@ -289,12 +298,12 @@
private File getDestinationFile( File resource )
{
File parent = resource.getParentFile();
- Stack<String> fileComponentStack = new Stack<String>();
+ Deque<String> fileComponentStack = new ArrayDeque<>();
fileComponentStack.push( resource.getName() );
while ( parent != null )
{
- if ( parent.getName().equals( "schema" ) )
+ if ( "schema".equals( parent.getName() ) )
{
// All LDIF files besides the schema.ldif are under the
// schema/schema base path. So we need to add one more
@@ -331,8 +340,7 @@
public static InputStream getUniqueResourceAsStream( String resourceName, String resourceDescription )
throws IOException
{
- resourceName = BASE_PATH + resourceName;
- URL result = getUniqueResource( resourceName, resourceDescription );
+ URL result = getUniqueResource( BASE_PATH + resourceName, resourceDescription );
return result.openStream();
}
@@ -391,7 +399,7 @@
.getParentFile().getAbsolutePath() ) );
}
- FileOutputStream out = new FileOutputStream( destination );
+ OutputStream out = Files.newOutputStream( Paths.get( destination.getPath() ) );
try
{
while ( in.available() > 0 )
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
index 8ca092a..30fa268 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
@@ -31,7 +31,6 @@
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import org.slf4j.Logger;
@@ -79,7 +78,7 @@
*/
public static Map<String, Boolean> getResources( Pattern pattern )
{
- HashMap<String, Boolean> retval = new HashMap<String, Boolean>();
+ HashMap<String, Boolean> retval = new HashMap<>();
String schemaResourceLoc = System.getProperty( SCHEMA_RESOURCE_LOCATION, "" );
@@ -140,10 +139,6 @@
{
zf = new ZipFile( file );
}
- catch ( ZipException e )
- {
- throw new Error( e );
- }
catch ( IOException e )
{
throw new Error( e );
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/AttributeClassLoader.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/AttributeClassLoader.java
index c510c04..5992cea 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/AttributeClassLoader.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/AttributeClassLoader.java
@@ -20,12 +20,21 @@
package org.apache.directory.api.ldap.schema.loader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
/**
@@ -35,7 +44,6 @@
*/
public class AttributeClassLoader extends ClassLoader
{
-
/** The attribute. */
private Attribute attribute;
@@ -66,13 +74,71 @@
this.attribute = attribute;
}
+
+ /**
+ * Read data from a jar, and write them into a byte[]
+ */
+ private static byte[] getBytes( InputStream input ) throws IOException
+ {
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+
+ byte[] buf = new byte[2048];
+ int bytesRead = input.read( buf );
+
+ while ( bytesRead != -1 )
+ {
+ result.write( buf, 0, bytesRead );
+ bytesRead = input.read( buf );
+ }
+
+ result.flush();
+ result.close();
+
+ return result.toByteArray();
+ }
+
+
+ private Map<String, Class<?>> loadClasses( byte[] jarBytes ) throws IOException
+ {
+ Map<String, Class<?>> map = new HashMap<>();
+
+ try ( JarInputStream jis = new JarInputStream( new ByteArrayInputStream( jarBytes ) ) )
+ {
+ JarEntry entry;
+ boolean isJar = false;
+
+ while ( ( entry = jis.getNextJarEntry() ) != null )
+ {
+ String fileName = entry.getName();
+ isJar = true;
+
+ // Just consider the files ending with .class
+ if ( fileName.endsWith( ".class" ) )
+ {
+ String className = fileName.substring( 0, fileName.length() - ".class".length() ).replace( '/', '.' );
+ byte[] classBytes = getBytes( jis );
+
+ Class<?> clazz = defineClass( className, classBytes, 0, classBytes.length );
+ map.put( className, clazz );
+ }
+ }
+
+ if ( !isJar )
+ {
+ return null;
+ }
+ }
+
+ return map;
+ }
/**
* {@inheritDoc}
*/
+ @Override
public Class<?> findClass( String name ) throws ClassNotFoundException
{
- byte[] classBytes = null;
+ byte[] classBytes;
Value<?> value = attribute.get();
@@ -83,6 +149,31 @@
classBytes = value.getBytes();
- return defineClass( name, classBytes, 0, classBytes.length );
+ // May be we are dealing with a JAR ?
+ try
+ {
+ Map<String, Class<?>> classes = loadClasses( classBytes );
+
+ if ( classes == null )
+ {
+ // May be a simple class ?
+ return defineClass( name, classBytes, 0, classBytes.length );
+ }
+
+ for ( Map.Entry<String, Class<?>> entry : classes.entrySet() )
+ {
+ if ( entry.getKey().contains( name ) )
+ {
+ return entry.getValue();
+ }
+ }
+ }
+ catch ( IOException ioe )
+ {
+ // Ok, may be a pure class
+ return defineClass( name, classBytes, 0, classBytes.length );
+ }
+
+ return null;
}
}
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/EntityFactory.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/EntityFactory.java
index 0c57de4..572e4e9 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/EntityFactory.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/EntityFactory.java
@@ -37,6 +37,13 @@
import org.apache.directory.api.ldap.model.schema.registries.Schema;
+/**
+ * An interface to be implemented by classes needed to create Schema elements. The factory
+ * will creates schema elements based on an Entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ *
+ */
public interface EntityFactory
{
/**
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/JarLdifSchemaLoader.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/JarLdifSchemaLoader.java
index b982a06..a8562d0 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/JarLdifSchemaLoader.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/JarLdifSchemaLoader.java
@@ -168,9 +168,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> comparatorList = new ArrayList<Entry>();
+ List<Entry> comparatorList = new ArrayList<>();
if ( schemas == null )
{
@@ -204,9 +205,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxCheckerList = new ArrayList<Entry>();
+ List<Entry> syntaxCheckerList = new ArrayList<>();
if ( schemas == null )
{
@@ -240,9 +242,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> normalizerList = new ArrayList<Entry>();
+ List<Entry> normalizerList = new ArrayList<>();
if ( schemas == null )
{
@@ -276,9 +279,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleList = new ArrayList<Entry>();
+ List<Entry> matchingRuleList = new ArrayList<>();
if ( schemas == null )
{
@@ -312,9 +316,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxList = new ArrayList<Entry>();
+ List<Entry> syntaxList = new ArrayList<>();
if ( schemas == null )
{
@@ -348,9 +353,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> attributeTypeList = new ArrayList<Entry>();
+ List<Entry> attributeTypeList = new ArrayList<>();
if ( schemas == null )
{
@@ -386,9 +392,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleUseList = new ArrayList<Entry>();
+ List<Entry> matchingRuleUseList = new ArrayList<>();
if ( schemas == null )
{
@@ -422,9 +429,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> nameFormList = new ArrayList<Entry>();
+ List<Entry> nameFormList = new ArrayList<>();
if ( schemas == null )
{
@@ -458,9 +466,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditContentRulesList = new ArrayList<Entry>();
+ List<Entry> ditContentRulesList = new ArrayList<>();
if ( schemas == null )
{
@@ -494,9 +503,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditStructureRuleList = new ArrayList<Entry>();
+ List<Entry> ditStructureRuleList = new ArrayList<>();
if ( schemas == null )
{
@@ -530,9 +540,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> objectClassList = new ArrayList<Entry>();
+ List<Entry> objectClassList = new ArrayList<>();
if ( schemas == null )
{
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/LdifSchemaLoader.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/LdifSchemaLoader.java
index f6887b9..2d0f149 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/LdifSchemaLoader.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/LdifSchemaLoader.java
@@ -68,6 +68,7 @@
/** a filter for listing all the LDIF files within a directory */
private final FilenameFilter ldifFilter = new FilenameFilter()
{
+ @Override
public boolean accept( File file, String name )
{
return name.endsWith( LDIF_EXT );
@@ -136,11 +137,9 @@
{
File file = new File( schemaDirectory, ldifFile );
- try
+ try ( LdifReader reader = new LdifReader( file ) )
{
- LdifReader reader = new LdifReader( file );
LdifEntry entry = reader.next();
- reader.close();
Schema schema = getSchema( entry.getEntry() );
if ( schema == null )
@@ -182,9 +181,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> comparatorList = new ArrayList<Entry>();
+ List<Entry> comparatorList = new ArrayList<>();
if ( schemas == null )
{
@@ -222,9 +222,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxCheckerList = new ArrayList<Entry>();
+ List<Entry> syntaxCheckerList = new ArrayList<>();
if ( schemas == null )
{
@@ -262,9 +263,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> normalizerList = new ArrayList<Entry>();
+ List<Entry> normalizerList = new ArrayList<>();
if ( schemas == null )
{
@@ -302,9 +304,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleList = new ArrayList<Entry>();
+ List<Entry> matchingRuleList = new ArrayList<>();
if ( schemas == null )
{
@@ -342,9 +345,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> syntaxList = new ArrayList<Entry>();
+ List<Entry> syntaxList = new ArrayList<>();
if ( schemas == null )
{
@@ -382,9 +386,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> attributeTypeList = new ArrayList<Entry>();
+ List<Entry> attributeTypeList = new ArrayList<>();
if ( schemas == null )
{
@@ -424,9 +429,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> matchingRuleUseList = new ArrayList<Entry>();
+ List<Entry> matchingRuleUseList = new ArrayList<>();
if ( schemas == null )
{
@@ -465,9 +471,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> nameFormList = new ArrayList<Entry>();
+ List<Entry> nameFormList = new ArrayList<>();
if ( schemas == null )
{
@@ -505,9 +512,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditContentRuleList = new ArrayList<Entry>();
+ List<Entry> ditContentRuleList = new ArrayList<>();
if ( schemas == null )
{
@@ -546,9 +554,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> ditStructureRuleList = new ArrayList<Entry>();
+ List<Entry> ditStructureRuleList = new ArrayList<>();
if ( schemas == null )
{
@@ -587,9 +596,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
- List<Entry> objectClassList = new ArrayList<Entry>();
+ List<Entry> objectClassList = new ArrayList<>();
if ( schemas == null )
{
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
index ffdec39..cb7624c 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
@@ -22,6 +22,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -57,6 +58,7 @@
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.SchemaObject;
import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker.SCBuilder;
import org.apache.directory.api.ldap.model.schema.UsageEnum;
import org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription;
import org.apache.directory.api.ldap.model.schema.parsers.NormalizerDescription;
@@ -82,7 +84,7 @@
private static final Logger LOG = LoggerFactory.getLogger( SchemaEntityFactory.class );
/** The empty string list. */
- private static final List<String> EMPTY_LIST = new ArrayList<String>();
+ private static final List<String> EMPTY_LIST = new ArrayList<>();
/** The empty string array. */
private static final String[] EMPTY_ARRAY = new String[]
@@ -99,6 +101,7 @@
{
this.classLoader = AccessController.doPrivileged( new PrivilegedAction<AttributeClassLoader>()
{
+ @Override
public AttributeClassLoader run()
{
return new AttributeClassLoader();
@@ -217,6 +220,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Schema getSchema( Entry entry ) throws LdapException
{
String name;
@@ -247,12 +251,12 @@
{
String value = entry.get( MetaSchemaConstants.M_DISABLED_AT ).getString();
value = Strings.upperCase( value );
- isDisabled = value.equals( "TRUE" );
+ isDisabled = "TRUE".equalsIgnoreCase( value );
}
if ( entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT ) != null )
{
- Set<String> depsSet = new HashSet<String>();
+ Set<String> depsSet = new HashSet<>();
Attribute depsAttr = entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT );
for ( Value<?> value : depsAttr )
@@ -274,8 +278,8 @@
Attribute byteCode ) throws LdapException
{
// Try to class load the syntaxChecker
- Class<?> clazz = null;
- SyntaxChecker syntaxChecker = null;
+ Class<?> clazz;
+ SyntaxChecker syntaxChecker;
String byteCodeStr = StringConstants.EMPTY;
if ( byteCode == null )
@@ -303,6 +307,7 @@
LOG.error( "Cannot load the syntax checker class constructor for class {}", className );
throw new LdapSchemaException( "Cannot load the syntax checker class " + cnfe.getMessage() );
}
+
byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
}
@@ -310,12 +315,18 @@
// Create the syntaxChecker instance
try
{
- syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
+ Method builder = clazz.getMethod( "builder", null );
+ syntaxChecker = ( SyntaxChecker ) ( ( SCBuilder ) builder.invoke( null, null ) ).setOid( oid ).build();
}
- catch ( InstantiationException ie )
+ catch ( NoSuchMethodException nsme )
{
LOG.error( "Cannot instantiate the syntax checker class constructor for class {}", className );
- throw new LdapSchemaException( "Cannot instantiate the syntax checker class " + ie.getMessage() );
+ throw new LdapSchemaException( "Cannot instantiate the syntax checker class " + nsme.getMessage() );
+ }
+ catch ( InvocationTargetException ite )
+ {
+ LOG.error( "Cannot instantiate the syntax checker class constructor for class {}", className );
+ throw new LdapSchemaException( "Cannot instantiate the syntax checker class " + ite.getMessage() );
}
catch ( IllegalAccessException iae )
{
@@ -327,9 +338,6 @@
syntaxChecker.setBytecode( byteCodeStr );
syntaxChecker.setFqcn( className );
- // Inject the new OID, as the loaded syntaxChecker might have its own
- syntaxChecker.setOid( oid );
-
// Inject the SchemaManager for the comparator who needs it
syntaxChecker.setSchemaManager( schemaManager );
@@ -340,6 +348,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapException
{
@@ -394,6 +403,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker getSyntaxChecker( SchemaManager schemaManager,
SyntaxCheckerDescription syntaxCheckerDescription, Registries targetRegistries, String schemaName )
throws LdapException
@@ -437,8 +447,8 @@
Attribute byteCode ) throws LdapException
{
// Try to class load the comparator
- LdapComparator<?> comparator = null;
- Class<?> clazz = null;
+ LdapComparator<?> comparator;
+ Class<?> clazz;
String byteCodeStr = StringConstants.EMPTY;
if ( byteCode == null )
@@ -549,6 +559,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> getLdapComparator( SchemaManager schemaManager,
LdapComparatorDescription comparatorDescription, Registries targetRegistries, String schemaName )
throws LdapException
@@ -588,6 +599,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> getLdapComparator( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapException
{
@@ -646,8 +658,8 @@
Attribute byteCode ) throws LdapException
{
// Try to class load the normalizer
- Class<?> clazz = null;
- Normalizer normalizer = null;
+ Class<?> clazz;
+ Normalizer normalizer;
String byteCodeStr = StringConstants.EMPTY;
if ( byteCode == null )
@@ -712,6 +724,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer getNormalizer( SchemaManager schemaManager, NormalizerDescription normalizerDescription,
Registries targetRegistries, String schemaName ) throws LdapException
{
@@ -750,6 +763,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer getNormalizer( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapException
{
@@ -806,6 +820,7 @@
* @throws LdapInvalidAttributeValueException If the Syntax does not exist
* @throws LdapUnwillingToPerformException If the schema is not loaded
*/
+ @Override
public LdapSyntax getSyntax( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapInvalidAttributeValueException, LdapUnwillingToPerformException
{
@@ -848,6 +863,7 @@
* @throws LdapInvalidAttributeValueException If the MatchingRule does not exist
* @throws LdapUnwillingToPerformException If the schema is not loaded
*/
+ @Override
public MatchingRule getMatchingRule( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapUnwillingToPerformException, LdapInvalidAttributeValueException
{
@@ -905,7 +921,7 @@
return EMPTY_LIST;
}
- List<String> strings = new ArrayList<String>( attr.size() );
+ List<String> strings = new ArrayList<>( attr.size() );
for ( Value<?> value : attr )
{
@@ -919,6 +935,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass getObjectClass( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapException
{
@@ -994,6 +1011,7 @@
* @throws LdapInvalidAttributeValueException If the AttributeType does not exist
* @throws LdapUnwillingToPerformException If the schema is not loaded
*/
+ @Override
public AttributeType getAttributeType( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
String schemaName ) throws LdapInvalidAttributeValueException, LdapUnwillingToPerformException
{
@@ -1083,7 +1101,7 @@
if ( mCollective != null )
{
String val = mCollective.getString();
- attributeType.setCollective( val.equalsIgnoreCase( "TRUE" ) );
+ attributeType.setCollective( "TRUE".equalsIgnoreCase( val ) );
}
// isSingleValued
@@ -1092,7 +1110,7 @@
if ( mSingleValued != null )
{
String val = mSingleValued.getString();
- attributeType.setSingleValued( val.equalsIgnoreCase( "TRUE" ) );
+ attributeType.setSingleValued( "TRUE".equalsIgnoreCase( val ) );
}
// isReadOnly
@@ -1101,7 +1119,7 @@
if ( mNoUserModification != null )
{
String val = mNoUserModification.getString();
- attributeType.setUserModifiable( !val.equalsIgnoreCase( "TRUE" ) );
+ attributeType.setUserModifiable( !"TRUE".equalsIgnoreCase( val ) );
}
// Usage
@@ -1173,9 +1191,8 @@
}
byte[] bytecode = Base64.decode( byteCodeString.toCharArray() );
- Attribute attr = new DefaultAttribute( MetaSchemaConstants.M_BYTECODE_AT, bytecode );
-
- return attr;
+
+ return new DefaultAttribute( MetaSchemaConstants.M_BYTECODE_AT, bytecode );
}
@@ -1219,7 +1236,7 @@
if ( mObsolete != null )
{
String val = mObsolete.getString();
- schemaObject.setObsolete( val.equalsIgnoreCase( "TRUE" ) );
+ schemaObject.setObsolete( "TRUE".equalsIgnoreCase( val ) );
}
// The description field
@@ -1235,7 +1252,7 @@
if ( names != null )
{
- List<String> values = new ArrayList<String>();
+ List<String> values = new ArrayList<>();
for ( Value<?> name : names )
{
@@ -1253,7 +1270,7 @@
if ( mDisabled != null )
{
String val = mDisabled.getString();
- schemaObject.setEnabled( !val.equalsIgnoreCase( "TRUE" ) );
+ schemaObject.setEnabled( !"TRUE".equalsIgnoreCase( val ) );
}
else
{
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SingleLdifSchemaLoader.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SingleLdifSchemaLoader.java
index e30cd9e..3408b92 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SingleLdifSchemaLoader.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SingleLdifSchemaLoader.java
@@ -21,10 +21,11 @@
package org.apache.directory.api.ldap.schema.loader;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -89,11 +90,7 @@
initializeSchemas( in );
}
- catch ( LdapException e )
- {
- throw new RuntimeException( e );
- }
- catch ( IOException e )
+ catch ( LdapException | IOException e )
{
throw new RuntimeException( e );
}
@@ -114,15 +111,11 @@
scObjEntryMap.put( s, new HashMap<String, List<Entry>>() );
}
- InputStream in = new FileInputStream( schemaFile );
+ InputStream in = Files.newInputStream( Paths.get( schemaFile ) );
initializeSchemas( in );
}
- catch ( LdapException e )
- {
- throw new RuntimeException( e );
- }
- catch ( IOException e )
+ catch ( LdapException | IOException e )
{
throw new RuntimeException( e );
}
@@ -147,11 +140,7 @@
initializeSchemas( in );
}
- catch ( LdapException e )
- {
- throw new RuntimeException( e );
- }
- catch ( IOException e )
+ catch ( LdapException | IOException e )
{
throw new RuntimeException( e );
}
@@ -163,28 +152,27 @@
*/
private void initializeSchemas( InputStream in ) throws LdapException, IOException
{
- LdifReader ldifReader = new LdifReader( in );
-
- Schema currentSchema = null;
-
- while ( ldifReader.hasNext() )
+ try ( LdifReader ldifReader = new LdifReader( in ) )
{
- LdifEntry ldifEntry = ldifReader.next();
- String dn = ldifEntry.getDn().getName();
-
- if ( SCHEMA_START_PATTERN.matcher( dn ).matches() )
+ Schema currentSchema = null;
+
+ while ( ldifReader.hasNext() )
{
- Schema schema = getSchema( ldifEntry.getEntry() );
- schemaMap.put( schema.getSchemaName(), schema );
- currentSchema = schema;
- }
- else
- {
- loadSchemaObject( currentSchema.getSchemaName(), ldifEntry );
+ LdifEntry ldifEntry = ldifReader.next();
+ String dn = ldifEntry.getDn().getName();
+
+ if ( SCHEMA_START_PATTERN.matcher( dn ).matches() )
+ {
+ Schema schema = getSchema( ldifEntry.getEntry() );
+ schemaMap.put( schema.getSchemaName(), schema );
+ currentSchema = schema;
+ }
+ else
+ {
+ loadSchemaObject( currentSchema.getSchemaName(), ldifEntry );
+ }
}
}
-
- ldifReader.close();
}
@@ -352,7 +340,7 @@
private int end;
- public SchemaMarker( int start )
+ SchemaMarker( int start )
{
this.start = start;
}
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
index 9ffe1d5..cff164d 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
@@ -112,7 +112,7 @@
private final EntityFactory factory;
/** A Map containing all the schema being dependent from a schema */
- private Map<String, Set<String>> schemaDependencies = new HashMap<String, Set<String>>();
+ private Map<String, Set<String>> schemaDependencies = new HashMap<>();
/**
* A map of all available schema names to schema objects. This map is
@@ -131,7 +131,7 @@
{
// Default to the the root (one schemaManager for all the entries
namingContext = Dn.ROOT_DSE;
- errors = new ArrayList<Throwable>();
+ errors = new ArrayList<>();
registries = new Registries();
factory = new SchemaEntityFactory();
isRelaxed = STRICT;
@@ -175,8 +175,7 @@
schemaMap.put( schema.getSchemaName(), schema );
}
- //this.schemaLoader = new JarLdifSchemaLoader();
- errors = new ArrayList<Throwable>();
+ errors = new ArrayList<>();
registries = new Registries();
factory = new SchemaEntityFactory();
isRelaxed = STRICT;
@@ -198,8 +197,7 @@
schemaMap.put( schema.getSchemaName(), schema );
}
- //this.schemaLoader = new JarLdifSchemaLoader();
- errors = new ArrayList<Throwable>();
+ errors = new ArrayList<>();
registries = new Registries();
factory = new SchemaEntityFactory();
isRelaxed = STRICT;
@@ -222,8 +220,7 @@
schemaMap.put( schema.getSchemaName(), schema );
}
- //this.schemaLoader = new JarLdifSchemaLoader();
- errors = new ArrayList<Throwable>();
+ errors = new ArrayList<>();
registries = new Registries();
factory = new SchemaEntityFactory();
isRelaxed = relaxed;
@@ -242,7 +239,7 @@
try
{
// Relax the controls at first
- errors = new ArrayList<Throwable>();
+ errors = new ArrayList<>();
// Clone the Registries
Registries clonedRegistries = registries.clone();
@@ -326,7 +323,7 @@
Map<String, Set<SchemaObjectWrapper>> schemaObjects = registries.getObjectBySchemaName();
Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCaseAscii( schema.getSchemaName() ) );
- List<SchemaObject> toBeDeleted = new ArrayList<SchemaObject>();
+ List<SchemaObject> toBeDeleted = new ArrayList<>();
if ( content != null )
{
@@ -350,6 +347,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean disable( Schema... schemas ) throws LdapException
{
boolean disabled = false;
@@ -407,6 +405,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean disable( String... schemaNames ) throws LdapException
{
Schema[] schemas = toArray( schemaNames );
@@ -418,9 +417,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean disabledRelaxed( Schema... schemas )
{
- // TODO Auto-generated method stub
return false;
}
@@ -428,9 +427,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean disabledRelaxed( String... schemas )
{
- // TODO Auto-generated method stub
return false;
}
@@ -438,9 +437,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Schema> getDisabled()
{
- List<Schema> disabled = new ArrayList<Schema>();
+ List<Schema> disabled = new ArrayList<>();
for ( Schema schema : registries.getLoadedSchemas().values() )
{
@@ -457,6 +457,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean enable( Schema... schemas ) throws LdapException
{
boolean enabled = false;
@@ -471,7 +472,7 @@
Registries clonedRegistries = cloneRegistries();
clonedRegistries.setRelaxed();
- Set<Schema> disabledSchemas = new HashSet<Schema>();
+ Set<Schema> disabledSchemas = new HashSet<>();
for ( Schema schema : schemas )
{
@@ -539,6 +540,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean enable( String... schemaNames ) throws LdapException
{
Schema[] schemas = toArray( schemaNames );
@@ -549,9 +551,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean enableRelaxed( Schema... schemas )
{
- // TODO Auto-generated method stub
return false;
}
@@ -559,9 +561,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean enableRelaxed( String... schemas )
{
- // TODO Auto-generated method stub
return false;
}
@@ -569,9 +571,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Schema> getEnabled()
{
- List<Schema> enabled = new ArrayList<Schema>();
+ List<Schema> enabled = new ArrayList<>();
for ( Schema schema : registries.getLoadedSchemas().values() )
{
@@ -588,9 +591,10 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<Schema> getAllSchemas()
{
- List<Schema> schemas = new ArrayList<Schema>();
+ List<Schema> schemas = new ArrayList<>();
for ( Schema schema : schemaMap.values() )
{
@@ -616,6 +620,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Registries getRegistries()
{
return registries;
@@ -623,11 +628,12 @@
/**
- * {@inheritDoc}
+ * Currently not implemented.
+ *
+ * @return Always FALSE
*/
public boolean isDisabledAccepted()
{
- // TODO Auto-generated method stub
return false;
}
@@ -635,6 +641,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean load( Schema... schemas ) throws LdapException
{
if ( schemas.length == 0 )
@@ -693,7 +700,7 @@
if ( deps == null )
{
- deps = new HashSet<String>();
+ deps = new HashSet<>();
deps.add( schema.getSchemaName() );
}
@@ -724,6 +731,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean load( String... schemaNames ) throws LdapException
{
if ( schemaNames.length == 0 )
@@ -1077,6 +1085,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadAllEnabled() throws LdapException
{
Schema[] schemas = new Schema[schemaMap.size()];
@@ -1100,6 +1109,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadAllEnabledRelaxed() throws LdapException
{
Schema[] enabledSchemas = new Schema[schemaMap.size()];
@@ -1120,6 +1130,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadDisabled( Schema... schemas ) throws LdapException
{
// Work on a cloned and relaxed registries
@@ -1139,7 +1150,7 @@
clonedRegistries.clear();
// Apply the change to the correct registries if no errors
- if ( errors.size() == 0 )
+ if ( errors.isEmpty() )
{
// No error, we can enable the schema in the real registries
for ( Schema schema : schemas )
@@ -1164,6 +1175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadDisabled( String... schemaNames ) throws LdapException
{
Schema[] schemas = toArray( schemaNames );
@@ -1175,9 +1187,9 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadRelaxed( Schema... schemas ) throws LdapException
{
- // TODO Auto-generated method stub
return false;
}
@@ -1185,6 +1197,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadRelaxed( String... schemaNames ) throws LdapException
{
Schema[] schemas = toArray( schemaNames );
@@ -1195,6 +1208,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadWithDeps( Schema... schemas ) throws LdapException
{
boolean loaded = false;
@@ -1251,6 +1265,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadWithDeps( String... schemas ) throws LdapException
{
return loadWithDeps( toArray( schemas ) );
@@ -1327,6 +1342,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadWithDepsRelaxed( Schema... schemas ) throws LdapException
{
registries.setRelaxed();
@@ -1350,6 +1366,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean loadWithDepsRelaxed( String... schemas ) throws LdapException
{
return loadWithDepsRelaxed( toArray( schemas ) );
@@ -1425,16 +1442,17 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRegistries( Registries registries )
{
- // TODO Auto-generated method stub
-
+ this.registries = registries;
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean unload( Schema... schemas ) throws LdapException
{
boolean unloaded = false;
@@ -1505,6 +1523,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean unload( String... schemaNames ) throws LdapException
{
Schema[] schemas = toArray( schemaNames );
@@ -1516,6 +1535,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean verify( Schema... schemas ) throws LdapException
{
// Work on a cloned registries
@@ -1539,7 +1559,7 @@
// Now, check the registries
List<Throwable> errorList = clonedRegistries.checkRefInteg();
- if ( errorList.size() != 0 )
+ if ( !errorList.isEmpty() )
{
// We got an error : exit
clonedRegistries.clear();
@@ -1564,6 +1584,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean verify( String... schemas ) throws LdapException
{
return verify( toArray( schemas ) );
@@ -1573,6 +1594,7 @@
/**
* @return the namingContext
*/
+ @Override
public Dn getNamingContext()
{
return namingContext;
@@ -1584,6 +1606,7 @@
*
* @throws LdapException If the initialization fails
*/
+ @Override
public void initialize() throws LdapException
{
}
@@ -1595,6 +1618,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeTypeRegistry getAttributeTypeRegistry()
{
return new ImmutableAttributeTypeRegistry( registries.getAttributeTypeRegistry() );
@@ -1604,6 +1628,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ComparatorRegistry getComparatorRegistry()
{
return new ImmutableComparatorRegistry( registries.getComparatorRegistry() );
@@ -1613,6 +1638,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitContentRuleRegistry getDITContentRuleRegistry()
{
return new ImmutableDitContentRuleRegistry( registries.getDitContentRuleRegistry() );
@@ -1622,6 +1648,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DitStructureRuleRegistry getDITStructureRuleRegistry()
{
return new ImmutableDitStructureRuleRegistry( registries.getDitStructureRuleRegistry() );
@@ -1631,6 +1658,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleRegistry getMatchingRuleRegistry()
{
return new ImmutableMatchingRuleRegistry( registries.getMatchingRuleRegistry() );
@@ -1640,6 +1668,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRuleUseRegistry getMatchingRuleUseRegistry()
{
return new ImmutableMatchingRuleUseRegistry( registries.getMatchingRuleUseRegistry() );
@@ -1649,6 +1678,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NameFormRegistry getNameFormRegistry()
{
return new ImmutableNameFormRegistry( registries.getNameFormRegistry() );
@@ -1658,6 +1688,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public NormalizerRegistry getNormalizerRegistry()
{
return new ImmutableNormalizerRegistry( registries.getNormalizerRegistry() );
@@ -1667,6 +1698,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClassRegistry getObjectClassRegistry()
{
return new ImmutableObjectClassRegistry( registries.getObjectClassRegistry() );
@@ -1676,6 +1708,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntaxRegistry getLdapSyntaxRegistry()
{
return new ImmutableLdapSyntaxRegistry( registries.getLdapSyntaxRegistry() );
@@ -1685,6 +1718,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxCheckerRegistry getSyntaxCheckerRegistry()
{
return new ImmutableSyntaxCheckerRegistry( registries.getSyntaxCheckerRegistry() );
@@ -1693,8 +1727,8 @@
/**
* Get rid of AT's options (everything after the ';'
- * @param oid
- * @return
+ * @param oid The AT's OID
+ * @return The AT without its options
*/
private String stripOptions( String oid )
{
@@ -1714,6 +1748,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType lookupAttributeTypeRegistry( String oid ) throws LdapException
{
String oidTrimmed = Strings.toLowerCaseAscii( oid ).trim();
@@ -1725,6 +1760,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType getAttributeType( String oid )
{
try
@@ -1743,6 +1779,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapComparator<?> lookupComparatorRegistry( String oid ) throws LdapException
{
return registries.getComparatorRegistry().lookup( oid );
@@ -1752,6 +1789,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchingRule lookupMatchingRuleRegistry( String oid ) throws LdapException
{
return registries.getMatchingRuleRegistry().lookup( Strings.toLowerCaseAscii( oid ).trim() );
@@ -1761,6 +1799,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Normalizer lookupNormalizerRegistry( String oid ) throws LdapException
{
return registries.getNormalizerRegistry().lookup( oid );
@@ -1770,6 +1809,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ObjectClass lookupObjectClassRegistry( String oid ) throws LdapException
{
return registries.getObjectClassRegistry().lookup( Strings.toLowerCaseAscii( oid ).trim() );
@@ -1779,6 +1819,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public LdapSyntax lookupLdapSyntaxRegistry( String oid ) throws LdapException
{
return registries.getLdapSyntaxRegistry().lookup( Strings.toLowerCaseAscii( oid ).trim() );
@@ -1788,6 +1829,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SyntaxChecker lookupSyntaxCheckerRegistry( String oid ) throws LdapException
{
return registries.getSyntaxCheckerRegistry().lookup( oid );
@@ -1896,6 +1938,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean add( SchemaObject schemaObject ) throws LdapException
{
// First, clear the errors
@@ -2021,6 +2064,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean delete( SchemaObject schemaObject ) throws LdapException
{
// First, clear the errors
@@ -2131,6 +2175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Map<String, OidNormalizer> getNormalizerMapping()
{
return registries.getAttributeTypeRegistry().getNormalizerMapping();
@@ -2140,6 +2185,7 @@
/**
* {@inheritDoc}
*/
+ @Override
@SuppressWarnings("rawtypes")
public OidRegistry getGlobalOidRegistry()
{
@@ -2150,6 +2196,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Schema getLoadedSchema( String schemaName )
{
return schemaMap.get( schemaName );
@@ -2159,6 +2206,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSchemaLoaded( String schemaName )
{
try
@@ -2177,6 +2225,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterAttributeType( String attributeTypeOid ) throws LdapException
{
return registries.getAttributeTypeRegistry().unregister( attributeTypeOid );
@@ -2186,6 +2235,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterComparator( String comparatorOid ) throws LdapException
{
return registries.getComparatorRegistry().unregister( comparatorOid );
@@ -2195,6 +2245,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterDitControlRule( String ditControlRuleOid ) throws LdapException
{
return registries.getDitContentRuleRegistry().unregister( ditControlRuleOid );
@@ -2204,6 +2255,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterDitStructureRule( String ditStructureRuleOid ) throws LdapException
{
return registries.getDitStructureRuleRegistry().unregister( ditStructureRuleOid );
@@ -2213,6 +2265,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterLdapSyntax( String ldapSyntaxOid ) throws LdapException
{
return registries.getLdapSyntaxRegistry().unregister( ldapSyntaxOid );
@@ -2222,6 +2275,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterMatchingRule( String matchingRuleOid ) throws LdapException
{
return registries.getMatchingRuleRegistry().unregister( matchingRuleOid );
@@ -2231,6 +2285,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterMatchingRuleUse( String matchingRuleUseOid ) throws LdapException
{
return registries.getMatchingRuleUseRegistry().unregister( matchingRuleUseOid );
@@ -2240,6 +2295,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterNameForm( String nameFormOid ) throws LdapException
{
return registries.getNameFormRegistry().unregister( nameFormOid );
@@ -2249,6 +2305,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterNormalizer( String normalizerOid ) throws LdapException
{
return registries.getNormalizerRegistry().unregister( normalizerOid );
@@ -2258,6 +2315,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterObjectClass( String objectClassOid ) throws LdapException
{
return registries.getObjectClassRegistry().unregister( objectClassOid );
@@ -2267,6 +2325,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SchemaObject unregisterSyntaxChecker( String syntaxCheckerOid ) throws LdapException
{
return registries.getSyntaxCheckerRegistry().unregister( syntaxCheckerOid );
@@ -2279,6 +2338,7 @@
*
* @return True if SchemaObjects can be added even if they break the consistency
*/
+ @Override
public boolean isRelaxed()
{
return isRelaxed;
@@ -2290,6 +2350,7 @@
*
* @return True if SchemaObjects cannot be added if they break the consistency
*/
+ @Override
public boolean isStrict()
{
return !isRelaxed;
@@ -2299,6 +2360,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> listDependentSchemaNames( String schemaName )
{
return schemaDependencies.get( schemaName );
@@ -2309,6 +2371,7 @@
* Change the SchemaManager to a relaxed mode, where invalid SchemaObjects
* can be registered.
*/
+ @Override
public void setRelaxed()
{
isRelaxed = RELAXED;
@@ -2319,6 +2382,7 @@
* Change the SchemaManager to a strict mode, where invalid SchemaObjects
* cannot be registered.
*/
+ @Override
public void setStrict()
{
isRelaxed = STRICT;
@@ -2328,6 +2392,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDisabled( String schemaName )
{
Schema schema = registries.getLoadedSchema( schemaName );
@@ -2339,6 +2404,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDisabled( Schema schema )
{
return ( schema != null ) && schema.isDisabled();
@@ -2348,6 +2414,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEnabled( String schemaName )
{
Schema schema = registries.getLoadedSchema( schemaName );
@@ -2359,6 +2426,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isEnabled( Schema schema )
{
return ( schema != null ) && schema.isEnabled();
diff --git a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
index df71c3b..505468a 100644
--- a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
+++ b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
@@ -1924,7 +1924,7 @@
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
- SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+ SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
assertTrue( schemaManager.add( syntaxChecker ) );
@@ -1949,7 +1949,7 @@
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
- SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+ SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
assertTrue( schemaManager.add( syntaxChecker ) );
@@ -1963,7 +1963,7 @@
assertEquals( nrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() );
assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
- SyntaxChecker syntaxChecker2 = new RegexSyntaxChecker( oid );
+ SyntaxChecker syntaxChecker2 = RegexSyntaxChecker.builder().setOid( oid ).build();
assertFalse( schemaManager.add( syntaxChecker2 ) );
@@ -1991,7 +1991,7 @@
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
- SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+ SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
// using java.sql.ResultSet cause it is very unlikely to get loaded
// in ADS, as the FQCN is not the one expected
diff --git a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
index f6e120d..a820c74 100644
--- a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
+++ b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
@@ -1018,8 +1018,7 @@
int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
- SyntaxChecker sc = new BooleanSyntaxChecker();
- sc.setOid( "0.1.1" );
+ SyntaxChecker sc = BooleanSyntaxChecker.builder().setOid( "0.1.1" ).build();
assertTrue( schemaManager.add( sc ) );
assertEquals( scrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() );
@@ -1051,8 +1050,7 @@
int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
- SyntaxChecker sc = new BooleanSyntaxChecker();
- sc.setOid( "0.0" );
+ SyntaxChecker sc = BooleanSyntaxChecker.builder().setOid( "0.0" ).build();
assertFalse( schemaManager.delete( sc ) );
List<Throwable> errors = schemaManager.getErrors();
diff --git a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
new file mode 100644
index 0000000..deaefb1
--- /dev/null
+++ b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.api.ldap.schema.manager.impl;
+
+
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.junit.Test;
+
+
+/**
+ * Tests the DefaultSchemaManager.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DefaultSchemaManagerTest
+{
+
+ /**
+ * Verifies that all syntax checkers are properly initialized
+ * when loading the default schema.
+ */
+ @Test
+ public void testSyntaxCheckersDoNotThrowException() throws Exception
+ {
+ DefaultSchemaManager schemaManager = new DefaultSchemaManager();
+ schemaManager.loadAllEnabled();
+
+ for ( SyntaxChecker sc : schemaManager.getSyntaxCheckerRegistry() )
+ {
+ sc.isValidSyntax( "foo" );
+ }
+ }
+
+}
diff --git a/ldap/schema/pom.xml b/ldap/schema/pom.xml
index 10e1d4f..f71c903 100644
--- a/ldap/schema/pom.xml
+++ b/ldap/schema/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-ldap-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-ldap-schema-parent</artifactId>
diff --git a/pom.xml b/pom.xml
index 48a6992..acc7ef8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.project</groupId>
<artifactId>project</artifactId>
- <version>36</version>
+ <version>40</version>
<relativePath />
</parent>
@@ -30,7 +30,7 @@
<artifactId>api-parent</artifactId>
<name>Apache Directory LDAP API</name>
<packaging>pom</packaging>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
@@ -40,7 +40,7 @@
<maven.compiler.target>1.7</maven.compiler.target>
<!-- Set versions for depending projects -->
- <skin.version>1.0.2</skin.version>
+ <skin.version>1.0.3</skin.version>
<org.apache.directory.junit.junit-addons.version>0.1</org.apache.directory.junit.junit-addons.version>
<org.apache.directory.checkstyle-configuration.version>0.3</org.apache.directory.checkstyle-configuration.version>
@@ -52,17 +52,18 @@
<commons.pool.version>1.6</commons.pool.version>
<dom4j.version>1.6.1</dom4j.version>
<findbugs.annotations.version>1.0.0</findbugs.annotations.version>
+ <forbiddenapis.version>2.2</forbiddenapis.version>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
- <logback.version>1.1.7</logback.version>
+ <logback.version>1.2.3</logback.version>
<mina.core.version>2.0.16</mina.core.version>
<org.osgi.core.version>6.0.0</org.osgi.core.version>
- <org.apache.felix.version>5.6.1</org.apache.felix.version>
- <pax-exam.version>4.9.2</pax-exam.version>
- <pax-url.version>2.5.1</pax-url.version>
- <slf4j.api.version>1.7.21</slf4j.api.version>
+ <org.apache.felix.version>5.6.4</org.apache.felix.version>
+ <pax-exam.version>4.11.0</pax-exam.version>
+ <pax-url.version>2.5.2</pax-url.version>
+ <slf4j.api.version>1.7.25</slf4j.api.version>
<slf4j.api.bundleversion>"$«range;[==,=+)»"</slf4j.api.bundleversion>
- <slf4j.log4j12.version>1.7.21</slf4j.log4j12.version>
+ <slf4j.log4j12.version>1.7.25</slf4j.log4j12.version>
<xml.apis.version>2.0.2</xml.apis.version>
<xpp3.version>1.1.4c</xpp3.version>
</properties>
@@ -88,6 +89,7 @@
<module>dsml</module>
<module>integ</module>
<module>integ-osgi</module>
+ <module>integ-osgi2</module>
<module>distribution</module>
</modules>
@@ -96,6 +98,18 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency><!-- downgrade Velocity to 1.5 until skin is updated to Velocity 1.7 -->
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.5</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
@@ -109,7 +123,7 @@
<aggregate>true</aggregate>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
- <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
+ <argLine>-Xmx2048m -XX:MaxPermSize=512</argLine>
</configuration>
</plugin>
@@ -117,7 +131,7 @@
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
- <excludeSubProjects>false</excludeSubProjects>
+ <excludeSubProjects>true</excludeSubProjects>
<excludes>
<!-- MAVEN_DEFAULT_EXCLUDES -->
<exclude>**/target/**/*</exclude>
@@ -146,6 +160,8 @@
<exclude>data/src/main/resources/schema-all.ldif</exclude>
<exclude>src/main/resources/schema/**</exclude>
<exclude>src/main/resources/schema-all.ldif</exclude>
+ <!-- Exlude the imported external java code -->
+ <exclude>**/src/main/java/org/apache/directory/api/ldap/model/password/BCrypt.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -273,216 +289,29 @@
<artifactId>wagon-ssh-external</artifactId>
<version>2.1</version>
</dependency>
+ <!-- Needed for mvn site to work.-->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.5</version>
+ </dependency>
</dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
<configuration>
- <reportPlugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <configuration>
- <aggregate>true</aggregate>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <configuration>
- <aggregate>true</aggregate>
- <forkCount>3</forkCount>
- <reuseForks>true</reuseForks>
- <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
- </configuration>
- </plugin>
-
- <!-- plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <linkXref>true</linkXref>
- <sourceEncoding>utf-8</sourceEncoding>
- <minimumTokens>100</minimumTokens>
- <targetJdk>1.7</targetJdk>
- <aggregate>true</aggregate>
- </configuration>
- </plugin -->
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>taglist-maven-plugin</artifactId>
- <configuration>
- <tags>
- <tag>TODO</tag>
- <tag>@todo</tag>
- <tag>@deprecated</tag>
- <tag>FIXME</tag>
- </tags>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <sourcepath>${project.basedir}/src/main/java</sourcepath>
- <minmemory>512m</minmemory>
- <maxmemory>1g</maxmemory>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>todo</name>
- <!-- todo tag for all places -->
- <placement>a</placement>
- <head>To do:</head>
- </tag>
- </tags>
- <source>1.7</source>
- <excludePackageNames>org.apache.directory.api.ldap.model.schema.syntaxes</excludePackageNames>
- </configuration>
- <reportSets>
- <reportSet>
- <reports>
- <report>aggregate</report>
- <report>test-aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
-
-<!-- Disabled because of Hudson problems, see http://jira.codehaus.org/browse/MFINDBUGS-126
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <configuration>
- <xrefLocation>${project.reporting.outputDirectory}/../xref</xrefLocation>
- <xrefTestLocation>${project.reporting.outputDirectory}/../xref-test</xrefTestLocation>
- <! - - required by dashboard plugin and hudson - - >
- <xmlOutput>true</xmlOutput>
- <effort>Max</effort>
- <findbugsXmlOutput>true</findbugsXmlOutput>
- <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
- </configuration>
- </plugin>
--->
-
-<!-- Disabled because of Hudson problems
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <configuration>
- <instrumentation>
- <excludes>
- <exclude>org/apache/directory/api/**/*Constants.class</exclude>
- </excludes>
- </instrumentation>
- </configuration>
- </plugin>
--->
-
- <!-- plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <configLocation>directory-checks.xml</configLocation>
- <suppressionsLocation>${basedir}/src/checkstyle/suppressions.xml</suppressionsLocation>
- <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
- <xrefLocation>${project.reporting.outputDirectory}/../xref</xrefLocation>
- </configuration>
- </plugin -->
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>versions-maven-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>dependency-updates-report</report>
- <report>plugin-updates-report</report>
- <report>property-updates-report</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
-
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <!-- must add configuration here too, it isn't inherited from <pluginConfiguration> :-( -->
- <configuration>
- <excludeSubProjects>false</excludeSubProjects>
- <excludes>
- <!-- MAVEN_DEFAULT_EXCLUDES -->
- <exclude>**/target/**/*</exclude>
- <exclude>**/cobertura.ser</exclude>
- <!-- ECLIPSE_DEFAULT_EXCLUDES -->
- <exclude>**/.classpath</exclude>
- <exclude>**/.project</exclude>
- <exclude>**/.settings/**/*</exclude>
- <!-- IDEA_DEFAULT_EXCLUDES -->
- <exclude>**/*.iml</exclude>
- <exclude>**/*.ipr</exclude>
- <exclude>**/*.iws</exclude>
- <!-- MANIFEST_MF_EXCLUDES -->
- <exclude>**/MANIFEST.MF</exclude>
- <!-- 3RD_PARTY_LICENSES -->
- <exclude>distribution/src/main/release/licenses/*</exclude>
- <exclude>src/main/release/licenses/*</exclude>
- <!-- Missing license header in dependency reduced pom, see http://jira.codehaus.org/browse/MSHADE-48 -->
- <exclude>**/dependency-reduced-pom.xml</exclude>
- <!-- Generated ldif files -->
- <exclude>**/src/main/resources/schema/**/*.ldif</exclude>
- <exclude>**/src/main/resources/schema-all.ldif</exclude>
- <exclude>**/src/main/resources/schema/**/*.ldif</exclude>
- <exclude>**/src/main/resources/schema-all.ldif</exclude>
- <!-- Files having a Bouncy Castle license -->
- <exclude>ldap/src/main/java/org/apache/directory/api/asn1/der/*.java</exclude>
- <exclude>src/main/java/org/apache/directory/api/asn1/der/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javancss-maven-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jdepend-maven-plugin</artifactId>
- </plugin>
-
-<!--
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <configuration>
- <onlyCurrentVersion>true</onlyCurrentVersion>
- <resolutionIds>Fixed</resolutionIds>
- <statusIds>Resolved,Closed</statusIds>
- <columnNames>Type,Key,Summary,Status,Resolution,Fix Version</columnNames>
- </configuration>
- <reportSets>
- <reportSet>
- <reports>
- <report>jira-report</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
--->
- </reportPlugins>
+ <show>private</show>
+ <nohelp>true</nohelp>
</configuration>
</plugin>
+
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
- <version>2.0</version>
+ <version>${forbiddenapis.version}</version>
<configuration>
<internalRuntimeForbidden>false</internalRuntimeForbidden>
<failOnUnsupportedJava>true</failOnUnsupportedJava>
@@ -770,7 +599,7 @@
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
-
+
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
@@ -779,14 +608,82 @@
</dependencies>
</dependencyManagement>
- <dependencies />
-
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/directory/shared/tags/1.0.0-RC2</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/shared/tags/1.0.0-RC2</developerConnection>
- <url>http://svn.apache.org/viewvc/directory/shared/tags/1.0.0-RC2</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/directory/shared/tags/1.0.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/shared/tags/1.0.0</developerConnection>
+ <url>http://svn.apache.org/viewvc/directory/shared/tags/1.0.0</url>
</scm>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <configuration>
+ <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+ <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+ </configuration>
+
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>dependencies</report>
+ <report>scm</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <inherited>false</inherited>
+ <configuration>
+ <aggregate>true</aggregate>
+ <inputEncoding>UTF-8</inputEncoding>
+ <outputEncoding>UTF-8</outputEncoding>
+ <windowTitle>Apache LDAP API ${project.version} Cross Reference</windowTitle>
+ <docTitle>Apache LDAP API ${project.version} Cross Reference</docTitle>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <windowtitle>Apache LDAP API ${project.version} API Documentation</windowtitle>
+ <doctitle>Apache LDAP API ${project.version} API Documentation</doctitle>
+ <minmemory>512m</minmemory>
+ <maxmemory>1g</maxmemory>
+ <linksource>true</linksource>
+ <tags>
+ <tag>
+ <name>todo</name>
+ <!-- todo tag for all places -->
+ <placement>a</placement>
+ <head>To do:</head>
+ </tag>
+ </tags>
+ <source>1.7</source>
+ <excludePackageNames>org.apache.directory.api.ldap.model.schema.syntaxes</excludePackageNames>
+ <show>public</show>
+ </configuration>
+
+ <reportSets>
+ <reportSet>
+ <id>apidocs</id>
+ <inherited>false</inherited>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+
+ </plugin>
+ </plugins>
+ </reporting>
+
<profiles>
<profile>
<id>apache-release</id>
diff --git a/util/pom.xml b/util/pom.xml
index 94697cc..b0539d0 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-parent</artifactId>
- <version>1.0.0-RC2</version>
+ <version>1.0.0</version>
</parent>
<artifactId>api-util</artifactId>
@@ -80,6 +80,16 @@
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>de.thetaphi</groupId>
+ <artifactId>forbiddenapis</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/MultiExceptionTest.class</exclude>
+ <exclude>**/RuntimeMultiExceptionTest.class</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/util/src/main/java/org/apache/directory/api/util/AbstractSimpleComponentsMonitor.java b/util/src/main/java/org/apache/directory/api/util/AbstractSimpleComponentsMonitor.java
index d02df86..acac02c 100644
--- a/util/src/main/java/org/apache/directory/api/util/AbstractSimpleComponentsMonitor.java
+++ b/util/src/main/java/org/apache/directory/api/util/AbstractSimpleComponentsMonitor.java
@@ -56,7 +56,7 @@
/**
* {@inheritDoc}
*/
- public ComponentsMonitor useComponent( String component ) throws IllegalArgumentException
+ public ComponentsMonitor useComponent( String component )
{
if ( !components.remove( component ) )
{
diff --git a/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java b/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java
index fffd1a0..dfc27af 100644
--- a/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java
+++ b/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java
@@ -42,13 +42,20 @@
/** the bytes of the buffer */
private byte[] buf;
-
+ /**
+ * Create a default ByteBuffer capable of holding 10 bytes
+ */
public ByteBuffer()
{
this( DEFAULT_INITIAL_SIZE );
}
+ /**
+ * Creates a ByteBuffer which has an initialze size
+ *
+ * @param initialSize The initial buffer size
+ */
public ByteBuffer( int initialSize )
{
if ( initialSize <= 0 )
@@ -61,24 +68,42 @@
}
+ /**
+ * Reset the Buffer position to 0. Every new added byte will be put on position 0.
+ * Note that whatever this buffer contained before a call to the clear() method
+ * will not be removed.
+ */
public final void clear()
{
pos = 0;
}
+ /**
+ * @return The current position in the buffer
+ */
public final int position()
{
return pos;
}
+ /**
+ * @return The number of bytes that can be added into this buffer
+ */
public final int capacity()
{
return buf.length;
}
+ /**
+ * Returns the byte at a given position. Note that no control is done
+ * on the position validity.
+ *
+ * @param i The position
+ * @return The byte at the given position in the buffer
+ */
public final byte get( int i )
{
return buf[i];
diff --git a/util/src/main/java/org/apache/directory/api/util/ComponentsMonitor.java b/util/src/main/java/org/apache/directory/api/util/ComponentsMonitor.java
index ef49c4b..573a50b 100644
--- a/util/src/main/java/org/apache/directory/api/util/ComponentsMonitor.java
+++ b/util/src/main/java/org/apache/directory/api/util/ComponentsMonitor.java
@@ -38,7 +38,7 @@
* @return this components monitor
* @throws IllegalArgumentException if the component is already used
*/
- ComponentsMonitor useComponent( String component ) throws IllegalArgumentException;
+ ComponentsMonitor useComponent( String component );
/**
diff --git a/util/src/main/java/org/apache/directory/api/util/DateUtils.java b/util/src/main/java/org/apache/directory/api/util/DateUtils.java
index b57a73a..3e3c869 100644
--- a/util/src/main/java/org/apache/directory/api/util/DateUtils.java
+++ b/util/src/main/java/org/apache/directory/api/util/DateUtils.java
@@ -117,7 +117,7 @@
long offset = 11644473600000L; // offset milliseconds from Jan 1, 1601 to Jan 1, 1970
// convert 100-nanosecond intervals to milliseconds (10000 = 1 000 000ns / 100)
- long javaTime = ( Long.parseLong( intervalDate ) / 10000L - offset );
+ long javaTime = Long.parseLong( intervalDate ) / 10000L - offset;
return new Date( javaTime );
}
diff --git a/util/src/main/java/org/apache/directory/api/util/EmptyEnumeration.java b/util/src/main/java/org/apache/directory/api/util/EmptyEnumeration.java
index c6b2aa7..ed33d91 100644
--- a/util/src/main/java/org/apache/directory/api/util/EmptyEnumeration.java
+++ b/util/src/main/java/org/apache/directory/api/util/EmptyEnumeration.java
@@ -31,11 +31,12 @@
* hasMore/hasMoreElements() always returns false, and next/nextElement() always
* throws a NoSuchElementException.
*
+ * @param <T> The element in the enumeration
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EmptyEnumeration<T> implements NamingEnumeration<T>
{
-
/**
* @see javax.naming.NamingEnumeration#close()
*/
diff --git a/util/src/main/java/org/apache/directory/api/util/FileUtils.java b/util/src/main/java/org/apache/directory/api/util/FileUtils.java
index 3d30f26..1b0a449 100644
--- a/util/src/main/java/org/apache/directory/api/util/FileUtils.java
+++ b/util/src/main/java/org/apache/directory/api/util/FileUtils.java
@@ -30,6 +30,9 @@
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
import java.util.List;
@@ -337,7 +340,7 @@
* @throws IOException if the file cannot be read
* @since 1.3
*/
- public static FileInputStream openInputStream( File file ) throws IOException
+ public static InputStream openInputStream( File file ) throws IOException
{
if ( file.exists() )
{
@@ -356,7 +359,7 @@
throw new FileNotFoundException( "File '" + file + "' does not exist" );
}
- return new FileInputStream( file );
+ return Files.newInputStream( Paths.get( file.getPath() ) );
}
@@ -443,7 +446,7 @@
* @throws IOException if a parent directory needs creating but that fails
* @since 2.1
*/
- public static FileOutputStream openOutputStream( File file, boolean append ) throws IOException
+ public static OutputStream openOutputStream( File file, boolean append ) throws IOException
{
if ( file.exists() )
{
@@ -470,7 +473,14 @@
}
}
- return new FileOutputStream( file, append );
+ if ( append )
+ {
+ return Files.newOutputStream( Paths.get( file.getPath() ), StandardOpenOption.CREATE, StandardOpenOption.APPEND );
+ }
+ else
+ {
+ return Files.newOutputStream( Paths.get( file.getPath() ) );
+ }
}
@@ -582,7 +592,6 @@
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @throws IOException if the output file length is not the same as the input file length after the copy completes
- * @see #doCopyFile(File, File, boolean)
*/
public static void copyFile( File srcFile, File destFile, boolean preserveFileDate ) throws IOException
{
@@ -659,8 +668,8 @@
try
{
- fis = new FileInputStream( srcFile );
- fos = new FileOutputStream( destFile );
+ fis = ( FileInputStream ) Files.newInputStream( Paths.get( srcFile.getPath() ) );
+ fos = ( FileOutputStream ) Files.newOutputStream( Paths.get( destFile.getPath() ) );
input = fis.getChannel();
output = fos.getChannel();
long size = input.size(); // TODO See IO-386
@@ -811,7 +820,7 @@
* @throws IOException if a parent directory needs creating but that fails
* @since 1.3
*/
- public static FileOutputStream openOutputStream( File file ) throws IOException
+ public static OutputStream openOutputStream( File file ) throws IOException
{
return openOutputStream( file, false );
}
diff --git a/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java b/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
index 0690876..3956d63 100644
--- a/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
+++ b/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
@@ -205,22 +205,6 @@
}
- private void setUp( Calendar newCalendar )
- {
- if ( newCalendar == null )
- {
- throw new IllegalArgumentException( I18n.err( I18n.ERR_04358 ) );
- }
-
- this.calendar = newCalendar;
- upGeneralizedTime = null;
- upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION;
- upTimeZoneFormat = TimeZoneFormat.Z;
- upFractionDelimiter = FractionDelimiter.DOT;
- upFractionLength = 3;
- }
-
-
/**
* Creates a new instance of GeneralizedTime, based on the
* given generalized time string.
@@ -368,6 +352,22 @@
}
+ private void setUp( Calendar newCalendar )
+ {
+ if ( newCalendar == null )
+ {
+ throw new IllegalArgumentException( I18n.err( I18n.ERR_04358 ) );
+ }
+
+ this.calendar = newCalendar;
+ upGeneralizedTime = null;
+ upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION;
+ upTimeZoneFormat = TimeZoneFormat.Z;
+ upFractionDelimiter = FractionDelimiter.DOT;
+ upFractionLength = 3;
+ }
+
+
private void parseTimezone( int pos ) throws ParseException
{
if ( upGeneralizedTime.length() < pos + 1 )
@@ -972,6 +972,7 @@
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
+ @Override
public int compareTo( GeneralizedTime other )
{
return calendar.compareTo( other.calendar );
diff --git a/util/src/main/java/org/apache/directory/api/util/Hex.java b/util/src/main/java/org/apache/directory/api/util/Hex.java
index 30ae109..8cba71d 100644
--- a/util/src/main/java/org/apache/directory/api/util/Hex.java
+++ b/util/src/main/java/org/apache/directory/api/util/Hex.java
@@ -80,7 +80,7 @@
return -1;
}
- return ( byte ) ( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] );
+ return ( byte ) ( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] & 0xff );
}
@@ -99,7 +99,7 @@
return -1;
}
- return ( byte ) ( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] );
+ return ( byte ) ( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] & 0xff );
}
@@ -152,7 +152,7 @@
for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ )
{
int ch = ( HEX_VALUE[chars[ii]] << 4 )
- + HEX_VALUE[chars[ii + 1]];
+ + ( HEX_VALUE[chars[ii + 1]] & 0xff );
decoded[jj] = ( byte ) ch;
}
@@ -196,7 +196,7 @@
if ( Chars.isHex( str, i + 1 ) && Chars.isHex( str, i + 2 ) )
{
byte value = ( byte ) ( ( HEX_VALUE[str.charAt( i + 1 )] << 4 )
- + HEX_VALUE[str.charAt( i + 2 )] );
+ + ( HEX_VALUE[str.charAt( i + 2 )] & 0xff ) );
i += 2;
buf[pos++] = value;
diff --git a/util/src/main/java/org/apache/directory/api/util/IOUtils.java b/util/src/main/java/org/apache/directory/api/util/IOUtils.java
index c898a5d..e87b0d3 100644
--- a/util/src/main/java/org/apache/directory/api/util/IOUtils.java
+++ b/util/src/main/java/org/apache/directory/api/util/IOUtils.java
@@ -359,7 +359,7 @@
* This method buffers the input internally, so there is no need to use a
* <code>BufferedReader</code>.
* <p>
- * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
+ * The buffer size is given by DEFAULT_BUFFER_SIZE.
*
* @param input the <code>Reader</code> to read from
* @param output the <code>Writer</code> to write to
@@ -381,7 +381,7 @@
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
* <p>
- * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
+ * The buffer size is given by DEFAULT_BUFFER_SIZE.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>OutputStream</code> to write to
diff --git a/util/src/main/java/org/apache/directory/api/util/MandatoryAndOptionalComponentsMonitor.java b/util/src/main/java/org/apache/directory/api/util/MandatoryAndOptionalComponentsMonitor.java
index 47ed9be..47211b3 100644
--- a/util/src/main/java/org/apache/directory/api/util/MandatoryAndOptionalComponentsMonitor.java
+++ b/util/src/main/java/org/apache/directory/api/util/MandatoryAndOptionalComponentsMonitor.java
@@ -52,7 +52,6 @@
* @throws IllegalArgumentException if the same component is defined as mandatory and optional
*/
public MandatoryAndOptionalComponentsMonitor( String[] mandatoryComponents, String[] optionalComponents )
- throws IllegalArgumentException
{
// check for common elements
for ( int i = 0; i < mandatoryComponents.length; i++ )
diff --git a/util/src/main/java/org/apache/directory/api/util/Network.java b/util/src/main/java/org/apache/directory/api/util/Network.java
index a0adfc6..0ec626b 100644
--- a/util/src/main/java/org/apache/directory/api/util/Network.java
+++ b/util/src/main/java/org/apache/directory/api/util/Network.java
@@ -31,7 +31,6 @@
*/
public final class Network
{
-
/**
* Private constructor.
*/
@@ -39,7 +38,10 @@
{
}
+ /** The loopback address (ie, ::1 or 127.0.0.1 */
public static final InetAddress LOOPBACK = getLoopbackAddress();
+
+ /** The loopback hostname */
public static final String LOOPBACK_HOSTNAME = getLoopbackHostName();
@@ -57,9 +59,14 @@
}
+ /**
+ * Construct a LDAP URL using the loopback address.
+ *
+ * @param port The port
+ * @return The Loopback URL
+ */
public static String ldapLoopbackUrl( int port )
{
return "ldap://" + LOOPBACK_HOSTNAME + ":" + port;
}
-
}
diff --git a/util/src/main/java/org/apache/directory/api/util/NoDuplicateKeysMap.java b/util/src/main/java/org/apache/directory/api/util/NoDuplicateKeysMap.java
index 64a35a6..0ef0e0f 100644
--- a/util/src/main/java/org/apache/directory/api/util/NoDuplicateKeysMap.java
+++ b/util/src/main/java/org/apache/directory/api/util/NoDuplicateKeysMap.java
@@ -42,7 +42,7 @@
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
@SuppressWarnings("unchecked")
- public Object put( Object key, Object value ) throws IllegalArgumentException
+ public Object put( Object key, Object value )
{
if ( containsKey( key ) )
{
diff --git a/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java b/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
index 245ee3a..60372b9 100644
--- a/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
+++ b/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
@@ -190,10 +190,8 @@
*/
public static String getBundleExports( File bundle )
{
- JarFile jar = null;
- try
+ try ( JarFile jar = new JarFile( bundle ) )
{
- jar = new JarFile( bundle );
Manifest manifest = jar.getManifest();
if ( manifest == null )
@@ -216,20 +214,6 @@
LOG.error( "Failed to open jar file or manifest.", e );
throw new RuntimeException( "Failed to open jar file or manifest.", e );
}
- finally
- {
- if ( jar != null )
- {
- try
- {
- jar.close();
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- }
- }
- }
}
diff --git a/util/src/main/java/org/apache/directory/api/util/SequencedHashMap.java b/util/src/main/java/org/apache/directory/api/util/SequencedHashMap.java
index cbde664..871e0d3 100644
--- a/util/src/main/java/org/apache/directory/api/util/SequencedHashMap.java
+++ b/util/src/main/java/org/apache/directory/api/util/SequencedHashMap.java
@@ -65,7 +65,7 @@
* {@link java.util.Map.Entry} that doubles as a node in the linked list of
* sequenced mappings.
*/
- private static class Entry implements Map.Entry, KeyValue
+ private static final class Entry implements Map.Entry, KeyValue
{
// Note: This class cannot easily be made clonable. While the actual
// implementation of a clone would be simple, defining the semantics is
@@ -91,7 +91,7 @@
Entry prev = null;
- public Entry( Object key, Object value )
+ Entry( Object key, Object value )
{
this.key = key;
this.value = value;
@@ -910,7 +910,7 @@
private static final int REMOVED_MASK = 0x80000000;
- private class OrderedIterator implements Iterator
+ private final class OrderedIterator implements Iterator
{
/**
* Holds the type that should be returned from the iterator. The value
@@ -943,7 +943,7 @@
* specified by <code>returnType</code> which must be either KEY,
* VALUE, or ENTRY.
*/
- public OrderedIterator( int returnType )
+ OrderedIterator( int returnType )
{
// Set the "removed" bit so that the iterator starts in a state
// where "next" must be called before "remove" will succeed.
diff --git a/util/src/main/java/org/apache/directory/api/util/Serialize.java b/util/src/main/java/org/apache/directory/api/util/Serialize.java
index 577a484..0a932b8 100644
--- a/util/src/main/java/org/apache/directory/api/util/Serialize.java
+++ b/util/src/main/java/org/apache/directory/api/util/Serialize.java
@@ -26,7 +26,10 @@
*/
public final class Serialize
{
+ /** The serialized value for TRUE */
public static final byte TRUE = 0x01;
+
+ /** The serialized value for FALSE */
public static final byte FALSE = 0x00;
diff --git a/util/src/main/java/org/apache/directory/api/util/SingletonEnumeration.java b/util/src/main/java/org/apache/directory/api/util/SingletonEnumeration.java
index 96a3077..e36ce7d 100644
--- a/util/src/main/java/org/apache/directory/api/util/SingletonEnumeration.java
+++ b/util/src/main/java/org/apache/directory/api/util/SingletonEnumeration.java
@@ -29,6 +29,7 @@
* A NamingEnumeration over a single element.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @param <T> The element in the enumeration
*/
public class SingletonEnumeration<T> implements NamingEnumeration<T>
{
diff --git a/util/src/main/java/org/apache/directory/api/util/StringConstants.java b/util/src/main/java/org/apache/directory/api/util/StringConstants.java
index 6876964..016d268 100644
--- a/util/src/main/java/org/apache/directory/api/util/StringConstants.java
+++ b/util/src/main/java/org/apache/directory/api/util/StringConstants.java
@@ -33,16 +33,14 @@
* @since 2.0
*/
public static final String EMPTY = "";
- /**
- * The empty byte[]
- */
- public static final byte[] EMPTY_BYTES = new byte[]
- {};
+
/**
* The empty String[]
*/
public static final String[] EMPTY_STRINGS = new String[]
{};
+
+ /** A flag used when comparing values */
public static final int NOT_EQUAL = -1;
diff --git a/util/src/main/java/org/apache/directory/api/util/Strings.java b/util/src/main/java/org/apache/directory/api/util/Strings.java
index d1f029b..30c46ac 100644
--- a/util/src/main/java/org/apache/directory/api/util/Strings.java
+++ b/util/src/main/java/org/apache/directory/api/util/Strings.java
@@ -207,12 +207,25 @@
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
+
+ private static final byte[] UTF8 = new byte[]
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
+ 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
+ 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
+ 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F };
/** An empty byte array */
public static final byte[] EMPTY_BYTES = new byte[0];
/** An empty String */
public static final String EMPTY_STRING = "";
+
+ /** An empty String array */
+ public static final String[] EMPTY_STRING_ARRAY = new String[]{};
/**
@@ -236,7 +249,7 @@
return "";
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for ( int i = 0; i < buffer.length; i++ )
{
@@ -288,8 +301,9 @@
}
char[] str = new char[buffer.length << 1];
+ int pos = 0;
- for ( int i = 0, pos = 0; i < buffer.length; i++ )
+ for ( int i = 0; i < buffer.length; i++ )
{
str[pos++] = ( char ) ( HEX_CHAR[( buffer[i] & 0x00F0 ) >> 4] );
str[pos++] = ( char ) ( HEX_CHAR[buffer[i] & 0x000F] );
@@ -306,8 +320,6 @@
* @param toLowerCase how to normalize for case: upper or lower
* @return the deep trimmed string
* @see Strings#deepTrim( String )
- *
- * TODO Replace the toCharArray() by substring manipulations
*/
public static String deepTrim( String str, boolean toLowerCase )
{
@@ -317,15 +329,15 @@
}
char ch;
- char[] buf = str.toCharArray();
- char[] newbuf = new char[buf.length];
+ int length = str.length();
+ char[] newbuf = new char[length];
boolean wsSeen = false;
boolean isStart = true;
int pos = 0;
- for ( int i = 0; i < str.length(); i++ )
+ for ( int i = 0; i < length; i++ )
{
- ch = buf[i];
+ ch = str.charAt( i );
// filter out all uppercase characters
if ( toLowerCase && Character.isUpperCase( ch ) )
@@ -366,7 +378,7 @@
}
}
- return ( pos == 0 ? "" : new String( newbuf, 0, ( wsSeen ? pos - 1 : pos ) ) );
+ return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos );
}
@@ -462,8 +474,6 @@
*/
public static String centerTrunc( String str, int head, int tail )
{
- StringBuffer buf = null;
-
// Return as-is if String is smaller than or equal to the head plus the
// tail plus the number of characters added to the trunc representation
// plus the number of digits in the string length.
@@ -472,7 +482,7 @@
return str;
}
- buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append( '[' ).append( str.length() ).append( "][" );
buf.append( str.substring( 0, head ) ).append( "..." );
buf.append( str.substring( str.length() - tail ) );
@@ -489,7 +499,7 @@
*/
public static String toHexString( byte[] res )
{
- StringBuffer buf = new StringBuffer( res.length << 1 );
+ StringBuilder buf = new StringBuilder( res.length << 1 );
for ( int ii = 0; ii < res.length; ii++ )
{
@@ -543,12 +553,12 @@
public static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote )
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int len = source.length();
- for ( int ii = 0; ii < len; ii++ )
+ for ( int i = 0; i < len; i++ )
{
- char ch = source.charAt( ii );
+ char ch = source.charAt( i );
switch ( ch )
{
@@ -668,7 +678,7 @@
}
else
{
- return ( ( byteArray[index] == car ) ? true : false );
+ return ( byteArray[index] == car ) ? true : false;
}
}
@@ -700,17 +710,6 @@
}
}
- private static final byte[] UTF8 = new byte[]
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
- 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
- 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
- 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
- 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64,
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F };
-
-
/**
* Return an UTF-8 encoded String
*
@@ -988,7 +987,7 @@
*/
public static String trim( String str )
{
- return ( isEmpty( str ) ? "" : str.trim() );
+ return isEmpty( str ) ? "" : str.trim();
}
@@ -1015,7 +1014,7 @@
{
if ( isEmpty( bytes ) )
{
- return StringConstants.EMPTY_BYTES;
+ return EMPTY_BYTES;
}
int start = trimLeft( bytes, 0 );
@@ -1033,7 +1032,7 @@
}
else
{
- return StringConstants.EMPTY_BYTES;
+ return EMPTY_BYTES;
}
}
@@ -1071,7 +1070,7 @@
start++;
}
- return ( start == 0 ? str : str.substring( start ) );
+ return start == 0 ? str : str.substring( start );
}
@@ -1257,7 +1256,7 @@
end--;
}
- return ( end == length ? str : str.substring( 0, end ) );
+ return end == length ? str : str.substring( 0, end );
}
@@ -1300,7 +1299,7 @@
end--;
}
- return ( end == length ? str : str.substring( 0, end ) );
+ return end == length ? str : str.substring( 0, end );
}
@@ -1377,7 +1376,7 @@
pos.end--;
}
- return ( pos.end == string.length() ? string : string.substring( 0, pos.end ) );
+ return pos.end == string.length() ? string : string.substring( 0, pos.end );
}
@@ -1671,7 +1670,7 @@
*/
public static String listToString( List<?> list )
{
- if ( ( list == null ) || ( list.size() == 0 ) )
+ if ( ( list == null ) || list.isEmpty() )
{
return "";
}
@@ -1705,7 +1704,7 @@
*/
public static String setToString( Set<?> set )
{
- if ( ( set == null ) || ( set.size() == 0 ) )
+ if ( ( set == null ) || set.isEmpty() )
{
return "";
}
@@ -1740,12 +1739,12 @@
*/
public static String listToString( List<?> list, String tabs )
{
- if ( ( list == null ) || ( list.size() == 0 ) )
+ if ( ( list == null ) || list.isEmpty() )
{
return "";
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for ( Object elem : list )
{
@@ -1767,12 +1766,12 @@
*/
public static String mapToString( Map<?, ?> map )
{
- if ( ( map == null ) || ( map.size() == 0 ) )
+ if ( ( map == null ) || map.isEmpty() )
{
return "";
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for ( Map.Entry<?, ?> entry : map.entrySet() )
@@ -1804,12 +1803,12 @@
*/
public static String mapToString( Map<?, ?> map, String tabs )
{
- if ( ( map == null ) || ( map.size() == 0 ) )
+ if ( ( map == null ) || map.isEmpty() )
{
return "";
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for ( Map.Entry<?, ?> entry : map.entrySet() )
{
@@ -1832,6 +1831,7 @@
* @return The lowercase string
* @deprecated Use {@link #toLowerCaseAscii(String)}
*/
+ @Deprecated
public static String toLowerCase( String value )
{
if ( ( null == value ) || ( value.length() == 0 ) )
@@ -1909,6 +1909,7 @@
* @return The uppercase string
* @deprecated Use {@link #toUpperCaseAscii(String)}
*/
+ @Deprecated
public static String toUpperCase( String value )
{
if ( ( null == value ) || ( value.length() == 0 ) )
@@ -2167,7 +2168,7 @@
}
char[] hex = encodeHex( bytes );
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( hex, 0, 8 );
sb.append( '-' );
sb.append( hex, 8, 4 );
@@ -2178,7 +2179,7 @@
sb.append( '-' );
sb.append( hex, 20, 12 );
- return Strings.toLowerCase( sb.toString() );
+ return Strings.toLowerCaseAscii( sb.toString() );
}
@@ -2232,7 +2233,7 @@
{
if ( isEmpty( value ) )
{
- return StringConstants.EMPTY_BYTES;
+ return EMPTY_BYTES;
}
byte[] copy = new byte[value.length];
@@ -2310,9 +2311,8 @@
*
* @param value The string to parse
* @return the parsed value.
- * @throws NumberFormatException If we don't have a number
*/
- public static int parseInt( String value ) throws NumberFormatException
+ public static int parseInt( String value )
{
long res = 0;
diff --git a/util/src/main/java/org/apache/directory/api/util/Unicode.java b/util/src/main/java/org/apache/directory/api/util/Unicode.java
index b892e48..47cfd63 100644
--- a/util/src/main/java/org/apache/directory/api/util/Unicode.java
+++ b/util/src/main/java/org/apache/directory/api/util/Unicode.java
@@ -488,7 +488,7 @@
// Start reading the string
strBuf = new StringBuffer( objectInput.readUTF() );
- if ( strLength == 0 && strBuf.toString().equals( "null" ) )
+ if ( ( strLength == 0 ) && ( "null".equals( strBuf.toString() ) ) )
{
// The special case of a 'null' string
return null;
diff --git a/util/src/main/java/org/apache/directory/api/util/exception/Exceptions.java b/util/src/main/java/org/apache/directory/api/util/exception/Exceptions.java
index edd4ea2..a5be66e 100644
--- a/util/src/main/java/org/apache/directory/api/util/exception/Exceptions.java
+++ b/util/src/main/java/org/apache/directory/api/util/exception/Exceptions.java
@@ -24,10 +24,8 @@
/**
- * <p>
* Provides utilities for manipulating and examining <code>Throwable</code>
* objects.
- * </p>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
diff --git a/util/src/main/java/org/apache/directory/api/util/exception/InvalidCharacterException.java b/util/src/main/java/org/apache/directory/api/util/exception/InvalidCharacterException.java
index 8a9ced2..5ac8ec0 100644
--- a/util/src/main/java/org/apache/directory/api/util/exception/InvalidCharacterException.java
+++ b/util/src/main/java/org/apache/directory/api/util/exception/InvalidCharacterException.java
@@ -31,15 +31,23 @@
public class InvalidCharacterException extends IOException
{
private static final long serialVersionUID = 1L;
- private int input;
+ private final int input;
+ /**
+ * Creates a new instance of an InvalidCharacterException
+ *
+ * @param input The char that has caused the exception
+ */
public InvalidCharacterException( int input )
{
this.input = input;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getMessage()
{
diff --git a/util/src/main/java/org/apache/directory/api/util/exception/MultiException.java b/util/src/main/java/org/apache/directory/api/util/exception/MultiException.java
index 3a2378f..aefd178 100644
--- a/util/src/main/java/org/apache/directory/api/util/exception/MultiException.java
+++ b/util/src/main/java/org/apache/directory/api/util/exception/MultiException.java
@@ -39,7 +39,7 @@
static final long serialVersionUID = 2889747406899775761L;
/** Collection of nested exceptions. */
- private Collection<Throwable> nestedExceptions = new ArrayList<Throwable>();
+ private final Collection<Throwable> nestedExceptions = new ArrayList<>();
/**
@@ -54,8 +54,7 @@
/**
* Constructs an Exception with a detailed message.
*
- * @param message
- * The message associated with the exception.
+ * @param message The message associated with the exception.
*/
public MultiException( String message )
{
@@ -99,10 +98,9 @@
/**
- * Add an exeception to this multiexception.
+ * Add an exception to this multiexception.
*
- * @param nested
- * exception to add to this MultiException.
+ * @param nested exception to add to this MultiException.
*/
public void addThrowable( Throwable nested )
{
@@ -118,9 +116,9 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions.
*
- * @param out
- * PrintWriter to write the nested stack trace to.
+ * @param out PrintWriter to write the nested stack trace to.
*/
+ @Override
public void printStackTrace( PrintWriter out )
{
super.printStackTrace( out );
@@ -139,7 +137,7 @@
out.println( "\n\t<<========= Next Nested Exception" + " ========>>\n" );
}
- throwable.printStackTrace();
+ throwable.printStackTrace( out );
}
out.println( "\n\t<<========= Last Nested Exception" + " ========>>\n" );
@@ -150,9 +148,9 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions.
*
- * @param out
- * PrintStream to write the nested stack trace to.
+ * @param out PrintStream to write the nested stack trace to.
*/
+ @Override
public void printStackTrace( PrintStream out )
{
super.printStackTrace( out );
@@ -171,7 +169,7 @@
out.println( "\n\t<<========= Next Nested Exception" + " ========>>\n" );
}
- throwable.printStackTrace();
+ throwable.printStackTrace( out );
}
out.println( "\n\t<<========= Last Nested Exception" + " ========>>\n" );
@@ -182,6 +180,7 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions using standard error.
*/
+ @Override
public void printStackTrace()
{
this.printStackTrace( System.err );
diff --git a/util/src/main/java/org/apache/directory/api/util/exception/NotImplementedException.java b/util/src/main/java/org/apache/directory/api/util/exception/NotImplementedException.java
index 0614d68..f3026ba 100644
--- a/util/src/main/java/org/apache/directory/api/util/exception/NotImplementedException.java
+++ b/util/src/main/java/org/apache/directory/api/util/exception/NotImplementedException.java
@@ -47,8 +47,7 @@
/**
* Constructs an Exception with a detailed message.
*
- * @param msg
- * The message associated with the exception.
+ * @param msg The message associated with the exception.
*/
public NotImplementedException( String msg )
{
diff --git a/util/src/main/java/org/apache/directory/api/util/exception/RuntimeMultiException.java b/util/src/main/java/org/apache/directory/api/util/exception/RuntimeMultiException.java
index 3569c37..59d363c 100644
--- a/util/src/main/java/org/apache/directory/api/util/exception/RuntimeMultiException.java
+++ b/util/src/main/java/org/apache/directory/api/util/exception/RuntimeMultiException.java
@@ -39,7 +39,7 @@
private static final long serialVersionUID = 8582253398936366771L;
/** Collection of nested exceptions. */
- private Collection<Throwable> nestedExceptions = new ArrayList<Throwable>();
+ private final Collection<Throwable> nestedExceptions = new ArrayList<>();
/**
@@ -111,8 +111,7 @@
/**
* Add an exeception to this multiexception.
*
- * @param nested
- * exception to add to this MultiException.
+ * @param nested exception to add to this MultiException.
*/
public void addThrowable( Throwable nested )
{
@@ -128,9 +127,9 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions.
*
- * @param out
- * PrintWriter to write the nested stack trace to.
+ * @param out PrintWriter to write the nested stack trace to.
*/
+ @Override
public void printStackTrace( PrintWriter out )
{
super.printStackTrace( out );
@@ -149,7 +148,7 @@
out.println( "\n\t<<========= Next Nested Exception" + " ========>>\n" );
}
- throwable.printStackTrace();
+ throwable.printStackTrace( out );
}
out.println( "\n\t<<========= Last Nested Exception" + " ========>>\n" );
@@ -160,9 +159,9 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions.
*
- * @param out
- * PrintStream to write the nested stack trace to.
+ * @param out PrintStream to write the nested stack trace to.
*/
+ @Override
public void printStackTrace( PrintStream out )
{
super.printStackTrace( out );
@@ -181,7 +180,7 @@
out.println( "\n\t<<========= Next Nested Exception" + " ========>>\n" );
}
- throwable.printStackTrace();
+ throwable.printStackTrace( out );
}
out.println( "\n\t<<========= Last Nested Exception" + " ========>>\n" );
@@ -192,6 +191,7 @@
* Beside printing out the standard stack trace this method prints out the
* stack traces of all the nested exceptions using standard error.
*/
+ @Override
public void printStackTrace()
{
this.printStackTrace( System.err );
diff --git a/util/src/test/java/org/apache/directory/api/util/FileUtilsTest.java b/util/src/test/java/org/apache/directory/api/util/FileUtilsTest.java
new file mode 100644
index 0000000..8c80351
--- /dev/null
+++ b/util/src/test/java/org/apache/directory/api/util/FileUtilsTest.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.api.util;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+
+/**
+ * Tests for FileUtils.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class FileUtilsTest
+{
+
+ @Rule
+ public TemporaryFolder tmpFolder = new TemporaryFolder();
+
+
+ @Test
+ public void testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder() throws Exception
+ {
+ File nonExistingFile = new File( tmpFolder.getRoot(),
+ "testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder/testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder" );
+
+ OutputStream os1 = FileUtils.openOutputStream( nonExistingFile, true );
+ os1.write( 'a' );
+ os1.write( 'b' );
+ os1.write( 'c' );
+ os1.close();
+
+ OutputStream os2 = FileUtils.openOutputStream( nonExistingFile, true );
+ os2.write( 'x' );
+ os2.write( 'y' );
+ os2.write( 'z' );
+ os2.close();
+
+ String content = FileUtils.readFileToString( nonExistingFile, StandardCharsets.UTF_8 );
+
+ assertEquals( "abcxyz", content );
+ }
+
+
+ @Test
+ public void testOpenOutputStreamAppendToExistingFile() throws Exception
+ {
+ File existingFile = tmpFolder.newFile( "testOpenOutputStreamAppendToExistingFile" );
+ FileUtils.writeStringToFile( existingFile, "abc", StandardCharsets.UTF_8, false );
+
+ OutputStream os = FileUtils.openOutputStream( existingFile, true );
+ os.write( 'x' );
+ os.write( 'y' );
+ os.write( 'z' );
+ os.close();
+
+ String content = FileUtils.readFileToString( existingFile, StandardCharsets.UTF_8 );
+
+ assertEquals( "abcxyz", content );
+ }
+
+
+ @Test
+ public void testOpenOutputStreamNotAppendToNonExistingFile() throws Exception
+ {
+ File nonExistingFile = new File( tmpFolder.getRoot(),
+ "testOpenOutputStreamNotAppendToNonExistingFile/testOpenOutputStreamNotAppendToNonExistingFile" );
+
+ OutputStream os1 = FileUtils.openOutputStream( nonExistingFile, false );
+ os1.write( 'a' );
+ os1.write( 'b' );
+ os1.write( 'c' );
+ os1.close();
+
+ OutputStream os2 = FileUtils.openOutputStream( nonExistingFile, false );
+ os2.write( 'x' );
+ os2.write( 'y' );
+ os2.write( 'z' );
+ os2.close();
+
+ String content = FileUtils.readFileToString( nonExistingFile, StandardCharsets.UTF_8 );
+
+ assertEquals( "xyz", content );
+ }
+
+
+ @Test
+ public void testOpenOutputStreamNotAppendToExistingFile() throws Exception
+ {
+ File existingFile = tmpFolder.newFile( "testOpenOutputStreamNotAppendToExistingFile" );
+ FileUtils.writeStringToFile( existingFile, "abc", StandardCharsets.UTF_8, false );
+
+ OutputStream os = FileUtils.openOutputStream( existingFile, false );
+ os.write( 'x' );
+ os.write( 'y' );
+ os.write( 'z' );
+ os.close();
+
+ String content = FileUtils.readFileToString( existingFile, StandardCharsets.UTF_8 );
+
+ assertEquals( "xyz", content );
+ }
+
+}
diff --git a/util/src/test/java/org/apache/directory/api/util/exception/MultiExceptionTest.java b/util/src/test/java/org/apache/directory/api/util/exception/MultiExceptionTest.java
new file mode 100644
index 0000000..132e039
--- /dev/null
+++ b/util/src/test/java/org/apache/directory/api/util/exception/MultiExceptionTest.java
@@ -0,0 +1,103 @@
+package org.apache.directory.api.util.exception;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MultiExceptionTest
+{
+ private PrintStream originalOut;
+ private PrintStream originalErr;
+
+
+ @Before
+ public void setUp()
+ {
+ originalOut = System.out;
+ originalErr = System.err;
+ }
+
+
+ @After
+ public void tearDown()
+ {
+ System.setOut( originalOut );
+ System.setErr( originalErr );
+ }
+
+
+ @Test
+ public void testPrintStacktracePrintWriterDoesNotWriteToSystemOutErr()
+ {
+ ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
+ PrintStream systemPrintStream = new PrintStream( systemOut );
+ System.setOut( systemPrintStream );
+ System.setErr( systemPrintStream );
+
+ StringWriter customOut = new StringWriter();
+ PrintWriter customPrintWriter = new PrintWriter( customOut );
+ MultiException multiException = new MultiException( "multi" );
+ multiException.addThrowable( new Exception( "nested1" ) );
+ multiException.addThrowable( new Exception( "nested2" ) );
+ multiException.printStackTrace( customPrintWriter );
+
+ assertThat( customOut.toString(), containsString( "multi" ) );
+ assertThat( customOut.toString(), containsString( "nested1" ) );
+ assertThat( customOut.toString(), containsString( "nested2" ) );
+ assertThat( systemOut.size(), equalTo( 0 ) );
+ }
+
+
+ @Test
+ public void testPrintStacktraceToPrintStreamDoesNotWriteToSystemOutErr()
+ {
+ ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
+ PrintStream systemPrintStream = new PrintStream( systemOut );
+ System.setOut( systemPrintStream );
+ System.setErr( systemPrintStream );
+
+ ByteArrayOutputStream customOut = new ByteArrayOutputStream();
+ PrintStream customPrintWriter = new PrintStream( customOut );
+ MultiException multiException = new MultiException( "multi" );
+ multiException.addThrowable( new Exception( "nested1" ) );
+ multiException.addThrowable( new Exception( "nested2" ) );
+ multiException.printStackTrace( customPrintWriter );
+
+ assertThat( customOut.toString(), containsString( "multi" ) );
+ assertThat( customOut.toString(), containsString( "nested1" ) );
+ assertThat( customOut.toString(), containsString( "nested2" ) );
+ assertThat( systemOut.size(), equalTo( 0 ) );
+ }
+}
diff --git a/util/src/test/java/org/apache/directory/api/util/exception/RuntimeMultiExceptionTest.java b/util/src/test/java/org/apache/directory/api/util/exception/RuntimeMultiExceptionTest.java
new file mode 100644
index 0000000..75782c8
--- /dev/null
+++ b/util/src/test/java/org/apache/directory/api/util/exception/RuntimeMultiExceptionTest.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.api.util.exception;
+
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class RuntimeMultiExceptionTest
+{
+ private PrintStream originalOut;
+ private PrintStream originalErr;
+
+
+ @Before
+ public void setUp()
+ {
+ originalOut = System.out;
+ originalErr = System.err;
+ }
+
+
+ @After
+ public void tearDown()
+ {
+ System.setOut( originalOut );
+ System.setErr( originalErr );
+ }
+
+
+ @Test
+ public void testPrintStacktracePrintWriterDoesNotWriteToSystemOutErr()
+ {
+ ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
+ PrintStream systemPrintStream = new PrintStream( systemOut );
+ System.setOut( systemPrintStream );
+ System.setErr( systemPrintStream );
+
+ StringWriter customOut = new StringWriter();
+ PrintWriter customPrintWriter = new PrintWriter( customOut );
+ RuntimeMultiException runtimeMultiException = new RuntimeMultiException( "multi" );
+ runtimeMultiException.addThrowable( new Exception( "nested1" ) );
+ runtimeMultiException.addThrowable( new Exception( "nested2" ) );
+ runtimeMultiException.printStackTrace( customPrintWriter );
+
+ assertThat( customOut.toString(), containsString( "multi" ) );
+ assertThat( customOut.toString(), containsString( "nested1" ) );
+ assertThat( customOut.toString(), containsString( "nested2" ) );
+ assertThat( systemOut.size(), equalTo( 0 ) );
+ }
+
+
+ @Test
+ public void testPrintStacktraceToPrintStreamDoesNotWriteToSystemOutErr()
+ {
+ ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
+ PrintStream systemPrintStream = new PrintStream( systemOut );
+ System.setOut( systemPrintStream );
+ System.setErr( systemPrintStream );
+
+ ByteArrayOutputStream customOut = new ByteArrayOutputStream();
+ PrintStream customPrintWriter = new PrintStream( customOut );
+ RuntimeMultiException runtimeMultiException = new RuntimeMultiException( "multi" );
+ runtimeMultiException.addThrowable( new Exception( "nested1" ) );
+ runtimeMultiException.addThrowable( new Exception( "nested2" ) );
+ runtimeMultiException.printStackTrace( customPrintWriter );
+
+ assertThat( customOut.toString(), containsString( "multi" ) );
+ assertThat( customOut.toString(), containsString( "nested1" ) );
+ assertThat( customOut.toString(), containsString( "nested2" ) );
+ assertThat( systemOut.size(), equalTo( 0 ) );
+ }
+}