Add odm to build
Issue gh-610
This commit is contained in:
3
dependencies/build.gradle
vendored
3
dependencies/build.gradle
vendored
@@ -34,6 +34,7 @@ dependencies {
|
||||
api "com.squareup.okhttp3:okhttp:3.14.9"
|
||||
api "com.unboundid:unboundid-ldapsdk:4.0.14"
|
||||
api "commons-codec:commons-codec:1.15"
|
||||
api "commons-cli:commons-cli:1.2"
|
||||
api "commons-collections:commons-collections:3.2.2"
|
||||
api "commons-io:commons-io:2.11.0"
|
||||
api "commons-lang:commons-lang:2.6"
|
||||
@@ -47,6 +48,7 @@ dependencies {
|
||||
api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1"
|
||||
api "jakarta.persistence:jakarta.persistence-api:3.0.0"
|
||||
api "javax.activation:activation:1.1"
|
||||
api "jdepend:jdepend:2.9.1"
|
||||
api "ldapsdk:ldapsdk:4.1"
|
||||
api "net.sourceforge.htmlunit:htmlunit:2.54.0"
|
||||
api "net.sourceforge.nekohtml:nekohtml:1.9.22"
|
||||
@@ -65,6 +67,7 @@ dependencies {
|
||||
api "org.easymock:easymock:2.5.1"
|
||||
api "org.eclipse.jetty:jetty-server:11.0.6"
|
||||
api "org.eclipse.jetty:jetty-servlet:11.0.6"
|
||||
api "org.freemarker:freemarker:2.3.20"
|
||||
api "jakarta.persistence:jakarta.persistence-api:3.0.0"
|
||||
api "org.hamcrest:hamcrest:2.2"
|
||||
api "org.hibernate:hibernate-core-jakarta:5.6.0.Final"
|
||||
|
||||
@@ -7,17 +7,17 @@ jar {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
management platform(project(":spring-ldap-dependencies"))
|
||||
implementation project(":spring-ldap-core"),
|
||||
project(":spring-ldap-core-tiger"),
|
||||
"org.springframework:spring-core",
|
||||
"org.freemarker:freemarker:2.3.20",
|
||||
"org.freemarker:freemarker",
|
||||
"commons-logging:commons-logging",
|
||||
"commons-cli:commons-cli:1.2"
|
||||
"commons-cli:commons-cli"
|
||||
|
||||
runtimeOnly "org.springframework:spring-context"
|
||||
|
||||
provided "commons-pool:commons-pool",
|
||||
"com.sun:ldapbp:1.0",
|
||||
"commons-lang:commons-lang",
|
||||
"org.springframework:spring-context",
|
||||
"org.springframework:spring-jdbc",
|
||||
@@ -25,6 +25,14 @@ dependencies {
|
||||
|
||||
testImplementation project(":spring-ldap-test"),
|
||||
"junit:junit",
|
||||
"jdepend:jdepend:2.9.1",
|
||||
"jdepend:jdepend",
|
||||
"commons-io:commons-io"
|
||||
testImplementation "org.apache.directory.server:apacheds-core-entry"
|
||||
testImplementation "org.apache.directory.server:apacheds-core"
|
||||
testImplementation "org.apache.directory.server:apacheds-protocol-ldap"
|
||||
testImplementation "org.apache.directory.server:apacheds-protocol-shared"
|
||||
testImplementation "org.apache.directory.server:apacheds-server-jndi"
|
||||
testImplementation "org.apache.directory.shared:shared-ldap"
|
||||
testImplementation platform('org.junit:junit-bom')
|
||||
testImplementation "org.junit.vintage:junit-vintage-engine"
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.server.core.avltree;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.directory.shared.ldap.util.StringTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class to serialize the Array data.
|
||||
*
|
||||
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>> {
|
||||
|
||||
/** static logger */
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ArrayMarshaller.class);
|
||||
|
||||
/** used for serialized form of an empty AvlTree */
|
||||
private static final byte[] EMPTY_TREE = new byte[1];
|
||||
|
||||
/** marshaller to be used for marshalling the keys */
|
||||
private Marshaller<E> keyMarshaller;
|
||||
|
||||
/** key Comparator for the AvlTree */
|
||||
private Comparator<E> comparator;
|
||||
|
||||
/**
|
||||
* Creates a new instance of AvlTreeMarshaller with a custom key Marshaller.
|
||||
* @param comparator Comparator to be used for key comparision
|
||||
* @param keyMarshaller marshaller for keys
|
||||
*/
|
||||
public ArrayMarshaller(Comparator<E> comparator, Marshaller<E> keyMarshaller) {
|
||||
this.comparator = comparator;
|
||||
this.keyMarshaller = keyMarshaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of AvlTreeMarshaller with the default key Marshaller which
|
||||
* uses Java Serialization.
|
||||
* @param comparator Comparator to be used for key comparision
|
||||
*/
|
||||
public ArrayMarshaller(Comparator<E> comparator) {
|
||||
this.comparator = comparator;
|
||||
this.keyMarshaller = DefaultMarshaller.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshals the given tree to bytes
|
||||
* @param tree the tree to be marshalled
|
||||
*/
|
||||
public byte[] serialize(ArrayTree<E> tree) {
|
||||
if ((tree == null) || (tree.size() == 0)) {
|
||||
return EMPTY_TREE;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteStream);
|
||||
byte[] data = null;
|
||||
|
||||
try {
|
||||
out.writeByte(0); // represents the start of an Array byte stream
|
||||
out.writeInt(tree.size());
|
||||
|
||||
for (int position = 0; position < tree.size(); position++) {
|
||||
E value = tree.get(position);
|
||||
byte[] bytes = this.keyMarshaller.serialize(value);
|
||||
|
||||
// Write the key length
|
||||
out.writeInt(bytes.length);
|
||||
|
||||
// Write the key if its length is not null
|
||||
if (bytes.length != 0) {
|
||||
out.write(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
out.flush();
|
||||
data = byteStream.toByteArray();
|
||||
|
||||
// Try to deserialize, just to see
|
||||
try {
|
||||
deserialize(data);
|
||||
}
|
||||
catch (NullPointerException npe) {
|
||||
System.out.println("Bad serialization, tree : [" + StringTools.dumpBytes(data) + "]");
|
||||
throw npe;
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Array from given bytes of data.
|
||||
* @param data byte array to be converted into an array
|
||||
*/
|
||||
public ArrayTree<E> deserialize(byte[] data) throws IOException {
|
||||
try {
|
||||
if ((data == null) || (data.length == 0)) {
|
||||
throw new IOException("Null or empty data array is invalid.");
|
||||
}
|
||||
|
||||
if ((data.length == 1) && (data[0] == 0)) {
|
||||
E[] array = (E[]) new Object[] {};
|
||||
ArrayTree<E> tree = new ArrayTree<E>(this.comparator, array);
|
||||
return tree;
|
||||
}
|
||||
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(data);
|
||||
DataInputStream din = new DataInputStream(bin);
|
||||
|
||||
byte startByte = din.readByte();
|
||||
|
||||
if (startByte != 0) {
|
||||
throw new IOException("wrong array serialized data format");
|
||||
}
|
||||
|
||||
int size = din.readInt();
|
||||
E[] nodes = (E[]) new Object[size];
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
// Read the object's size
|
||||
int dataSize = din.readInt();
|
||||
|
||||
if (dataSize != 0) {
|
||||
byte[] bytes = new byte[dataSize];
|
||||
|
||||
din.read(bytes);
|
||||
E key = this.keyMarshaller.deserialize(bytes);
|
||||
nodes[i] = key;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayTree<E> arrayTree = new ArrayTree<E>(this.comparator, nodes);
|
||||
|
||||
return arrayTree;
|
||||
}
|
||||
catch (NullPointerException npe) {
|
||||
System.out.println("Bad tree : [" + StringTools.dumpBytes(data) + "]");
|
||||
throw npe;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,8 @@ import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import java.util.Base64;
|
||||
import org.junit.Ignore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.junit.After;
|
||||
@@ -56,6 +57,8 @@ import org.springframework.util.CollectionUtils;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.ldap.LdapName;
|
||||
import javax.naming.spi.NamingManager;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -124,7 +127,7 @@ public final class TestLdap {
|
||||
"Rn0HStE+IrZSQbEuRxvU4De4yc0UVFKCnuerms2vZryP/Z";
|
||||
|
||||
byte[] photoBytes=photoString.getBytes("US-ASCII");
|
||||
photo=Base64.decodeBase64(photoBytes);
|
||||
photo=Base64.getDecoder().decode(photoBytes);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Problem decoding photo", e);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ include 'core-tiger'
|
||||
include 'dependencies'
|
||||
include 'test-support'
|
||||
include 'ldif/ldif-core'
|
||||
//include 'odm'
|
||||
include 'odm'
|
||||
////include 'sandbox'
|
||||
//include 'test/integration-tests'
|
||||
//include 'test/integration-tests-spring20'
|
||||
|
||||
Reference in New Issue
Block a user