lift to module path, update dependencies

This commit is contained in:
Jörg Prante 2024-04-08 16:50:50 +02:00
parent 47972552c8
commit ab20035583
78 changed files with 228 additions and 250 deletions

View file

@ -1,17 +1,13 @@
plugins {
id "checkstyle"
id "pmd"
id 'maven-publish'
id 'signing'
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
id "com.github.spotbugs" version "5.0.14"
id "org.cyclonedx.bom" version "1.7.2"
}
wrapper {
gradleVersion = libs.versions.gradle.get()
distributionType = Wrapper.DistributionType.ALL
distributionType = Wrapper.DistributionType.BIN
}
ext {
@ -30,14 +26,10 @@ ext {
}
subprojects {
apply from: rootProject.file('gradle/ide/idea.gradle')
apply from: rootProject.file('gradle/repositories/maven.gradle')
apply from: rootProject.file('gradle/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/publish/maven.gradle')
apply from: rootProject.file('gradle/quality/checkstyle.gradle')
apply from: rootProject.file('gradle/quality/pmd.gradle')
apply from: rootProject.file('gradle/quality/spotbugs.gradle')
}
apply from: rootProject.file('gradle/publish/sonatype.gradle')
apply from: rootProject.file('gradle/publish/forgejo.gradle')

View file

@ -1,5 +1,3 @@
group = org.xbib
name = oai
version = 3.0.0
gradle.wrapper.version = 7.5.1
version = 4.0.0

View file

@ -1,34 +1,47 @@
apply plugin: 'java-library'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
modularity.inferModulePath.set(true)
withSourcesJar()
withJavadocJar()
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
manifest {
attributes('Implementation-Version': project.version)
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all'
tasks.withType(JavaCompile).configureEach {
doFirst {
options.fork = true
options.forkOptions.jvmArgs += ['-Duser.language=en', '-Duser.country=US']
options.encoding = 'UTF-8'
options.compilerArgs.add('-Xlint:all')
// enforce presence of module-info.java
options.compilerArgs.add("--module-version")
options.compilerArgs.add(project.version as String)
options.compilerArgs.add("--module-path")
options.compilerArgs.add(classpath.asPath)
classpath = files()
}
}
tasks.withType(Javadoc) {
tasks.withType(Javadoc).configureEach {
doFirst {
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
}
}
tasks.withType(JavaExec).configureEach {
doFirst {
jvmArguments.add("--module-path")
jvmArguments.add(classpath.asPath)
classpath = files()
}
}

View file

@ -1,34 +1,32 @@
dependencies {
testImplementation libs.junit.jupiter.api
testImplementation libs.junit.jupiter.params
testImplementation libs.hamcrest
testRuntimeOnly libs.junit.jupiter.engine
testImplementation testLibs.junit.jupiter.api
testImplementation testLibs.junit.jupiter.params
testImplementation testLibs.hamcrest
testRuntimeOnly testLibs.junit.jupiter.engine
testRuntimeOnly testLibs.junit.jupiter.platform.launcher
}
test {
useJUnitPlatform()
failFast = false
ignoreFailures = true
jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED',
'--add-opens=java.base/java.lang=ALL-UNNAMED',
'--add-opens=java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens=java.base/java.io=ALL-UNNAMED',
'--add-opens=java.base/java.nio=ALL-UNNAMED',
'--add-opens=java.base/java.util=ALL-UNNAMED'
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
systemProperty 'io.netty.tryReflectionSetAccessible', 'true'
systemProperty 'io.netty.tryReflectionSetAccessible', 'false'
systemProperty 'io.netty.allocator.typ', 'pooled'
systemProperty 'io.netty.noUnsafe', 'true'
systemProperty 'io.netty.noKeySetOptimization', 'true'
systemProperty 'io.netty.eventLoopThreads', '8'
systemProperty 'io.netty.recycler.maxCapacityPerThread', '0'
systemProperty 'io.netty.transport.noNative', 'true'
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
showStandardStreams = true
}
reports {
html.required = false
junitXml.outputLocation.set(layout.buildDirectory.dir("test-junit-xml"))
}
afterSuite { desc, result ->
if (!desc.parent) {

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

22
gradlew vendored
View file

@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

20
gradlew.bat vendored
View file

@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View file

@ -3,3 +3,13 @@ dependencies {
testImplementation libs.marc
testImplementation libs.charactersets
}
def patchArgs = ['--patch-module', "org.xbib.oai.client.test=" + sourceSets.test.resources.sourceDirectories.singleFile]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

View file

@ -6,8 +6,8 @@ module org.xbib.oai.client {
exports org.xbib.oai.client.listmetadataformats;
exports org.xbib.oai.client.listrecords;
exports org.xbib.oai.client.listsets;
requires org.xbib.oai;
//requires org.xbib.net;
exports org.xbib.oai.client.util;
requires transitive org.xbib.oai;
requires org.xbib.content.xml;
requires java.xml;
requires java.logging;

View file

@ -2,11 +2,9 @@ package org.xbib.oai.client.getrecord;
import org.xbib.oai.client.AbstractOAIRequest;
/**
*
*/
public class GetRecordRequest extends AbstractOAIRequest {
@SuppressWarnings("this-escape")
public GetRecordRequest() {
super();
addParameter(VERB_PARAMETER, GET_RECORD);

View file

@ -2,9 +2,8 @@ package org.xbib.oai.client.getrecord;
import org.xbib.oai.OAIResponse;
/**
*
*/
public class GetRecordResponse implements OAIResponse {
public GetRecordResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI get record verb.
*/
package org.xbib.oai.client.getrecord;

View file

@ -2,11 +2,9 @@ package org.xbib.oai.client.identify;
import org.xbib.oai.client.AbstractOAIRequest;
/**
*
*/
public class IdentifyRequest extends AbstractOAIRequest {
@SuppressWarnings("this-escape")
public IdentifyRequest() {
super();
addParameter(VERB_PARAMETER, IDENTIFY);

View file

@ -19,9 +19,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
/**
*
*/
public class IdentifyResponse implements OAIResponse {
private String repositoryName;
@ -40,6 +37,9 @@ public class IdentifyResponse implements OAIResponse {
private String compression;
public IdentifyResponse() {
}
public void receivedResponse(String message, int statusCode, String contentType, String retryAfter, Writer writer) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

View file

@ -1,4 +0,0 @@
/**
* OAI identify verb.
*/
package org.xbib.oai.client.identify;

View file

@ -2,11 +2,9 @@ package org.xbib.oai.client.listidentifiers;
import org.xbib.oai.client.AbstractOAIRequest;
/**
*
*/
public class ListIdentifiersRequest extends AbstractOAIRequest {
@SuppressWarnings("this-escape")
public ListIdentifiersRequest() {
super();
addParameter(VERB_PARAMETER, LIST_IDENTIFIERS);

View file

@ -4,4 +4,6 @@ import org.xbib.oai.OAIResponse;
public class ListIdentifiersResponse implements OAIResponse {
public ListIdentifiersResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list identifiers verb.
*/
package org.xbib.oai.client.listidentifiers;

View file

@ -2,11 +2,9 @@ package org.xbib.oai.client.listmetadataformats;
import org.xbib.oai.client.AbstractOAIRequest;
/**
*
*/
public class ListMetadataFormatsRequest extends AbstractOAIRequest {
@SuppressWarnings("this-escape")
public ListMetadataFormatsRequest() {
super();
addParameter(VERB_PARAMETER, LIST_METADATA_FORMATS);

View file

@ -4,4 +4,6 @@ import org.xbib.oai.OAIResponse;
public class ListMetadataFormatsResponse implements OAIResponse {
public ListMetadataFormatsResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list metadata formats verb.
*/
package org.xbib.oai.client.listmetadataformats;

View file

@ -11,10 +11,12 @@ public class ListRecordsRequest extends AbstractOAIRequest {
private final List<MetadataHandler> handlers = new LinkedList<>();
@SuppressWarnings("this-escape")
public ListRecordsRequest() {
super();
addParameter(OAIConstants.VERB_PARAMETER, LIST_RECORDS);
}
public ListRecordsRequest addHandler(MetadataHandler handler) {
handlers.add(handler);
return this;

View file

@ -1,4 +0,0 @@
/**
* OAI list records verb.
*/
package org.xbib.oai.client.listrecords;

View file

@ -2,11 +2,9 @@ package org.xbib.oai.client.listsets;
import org.xbib.oai.client.AbstractOAIRequest;
/**
*
*/
public class ListSetsRequest extends AbstractOAIRequest {
@SuppressWarnings("this-escape")
public ListSetsRequest() {
super();
addParameter(VERB_PARAMETER, LIST_SETS);

View file

@ -3,4 +3,7 @@ package org.xbib.oai.client.listsets;
import org.xbib.oai.OAIResponse;
public class ListSetsResponse implements OAIResponse {
public ListSetsResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list sets verb.
*/
package org.xbib.oai.client.listsets;

View file

@ -1,4 +0,0 @@
/**
* Classes for OAI client.
*/
package org.xbib.oai.client;

View file

@ -160,27 +160,27 @@ public final class PercentEncoder {
}
}
private class StringBuilderPercentEncoderOutputHandler {
public static class StringBuilderPercentEncoderOutputHandler {
private final StringBuilder stringBuilder;
StringBuilderPercentEncoderOutputHandler() {
public StringBuilderPercentEncoderOutputHandler() {
stringBuilder = new StringBuilder();
}
String getContents() {
public String getContents() {
return stringBuilder.toString();
}
void reset() {
public void reset() {
stringBuilder.setLength(0);
}
void ensureCapacity(int length) {
public void ensureCapacity(int length) {
stringBuilder.ensureCapacity(length);
}
void onOutputChar(char c) {
public void onOutputChar(char c) {
stringBuilder.append(c);
}
}

View file

@ -1,6 +1,7 @@
package org.xbib.oai.client.util;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetDecoder;
@ -103,7 +104,7 @@ public final class UrlBuilder {
}
public static UrlBuilder fromUrl(String urlSpec) throws CharacterCodingException, MalformedURLException {
return fromUrl(new URL(urlSpec));
return fromUrl(URI.create(urlSpec).toURL());
}
/**
@ -297,7 +298,7 @@ public final class UrlBuilder {
}
public URL build() throws CharacterCodingException, MalformedURLException {
return new URL(toUrlString());
return URI.create(toUrlString()).toURL();
}
/**

View file

@ -0,0 +1,8 @@
module org.xbib.oai.client.test {
requires java.logging;
requires org.junit.jupiter.api;
requires org.xbib.marc;
requires org.xbib.oai;
requires org.xbib.oai.client;
opens org.xbib.oai.client.test to org.junit.platform.commons;
}

View file

@ -1,4 +0,0 @@
/**
* Classes for testing OAI client.
*/
package org.xbib.oai.client;

View file

@ -1,8 +1,10 @@
package org.xbib.oai.client;
package org.xbib.oai.client.test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.oai.client.OAIClient;
import org.xbib.oai.client.SplitWriter;
import org.xbib.oai.client.identify.IdentifyResponse;
import org.xbib.oai.xml.SimpleMetadataHandler;

View file

@ -1,10 +1,11 @@
package org.xbib.oai.client;
package org.xbib.oai.client.test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.json.MarcJsonWriter;
import org.xbib.marc.xml.MarcContentHandler;
import org.xbib.oai.client.OAIClient;
import org.xbib.oai.client.identify.IdentifyResponse;
import org.xbib.oai.exceptions.OAIException;

View file

@ -1,7 +1,9 @@
package org.xbib.oai.client;
package org.xbib.oai.client.test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.xbib.oai.client.OAIClient;
import org.xbib.oai.client.SplitWriter;
import java.time.Instant;

View file

@ -1,6 +1,8 @@
package org.xbib.oai.client;
package org.xbib.oai.client.test;
import org.junit.jupiter.api.Test;
import org.xbib.oai.client.OAIClient;
import org.xbib.oai.client.SplitWriter;
import org.xbib.oai.client.identify.IdentifyResponse;
import org.xbib.oai.xml.SimpleMetadataHandler;

View file

@ -1,7 +1,8 @@
package org.xbib.oai.client.util;
package org.xbib.oai.client.test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.xbib.oai.client.util.PercentEncoder;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.MalformedInputException;

View file

@ -1,6 +1,7 @@
package org.xbib.oai.client.util;
package org.xbib.oai.client.test;
import org.junit.jupiter.api.Test;
import org.xbib.oai.client.util.UrlBuilder;
import java.net.MalformedURLException;
import java.net.URI;
@ -9,6 +10,7 @@ import java.net.URL;
import java.nio.charset.CharacterCodingException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public final class UrlBuilderTest {
@ -310,7 +312,7 @@ public final class UrlBuilderTest {
UrlBuilder.fromUrl("http://foo.com/fo%2o");
fail();
} catch (IllegalArgumentException e) {
assertEquals("Invalid %-tuple <%2o>", e.getMessage());
assertTrue(e.getMessage().startsWith("Malformed escape pair"));
}
}
@ -414,12 +416,13 @@ public final class UrlBuilderTest {
* @param finalUrl the URL string it should end up as
*/
private void assertUrlBuilderRoundtrip(String origUrl, String finalUrl) throws MalformedURLException, CharacterCodingException, URISyntaxException {
assertUrlEquals(finalUrl, UrlBuilder.fromUrl(new URL(origUrl)).toUrlString());
URL url = URI.create(origUrl).toURL();
assertUrlEquals(finalUrl, UrlBuilder.fromUrl(url).toUrlString());
}
private static void assertUrlEquals(String expected, String actual) throws URISyntaxException, MalformedURLException {
assertEquals(expected, actual);
assertEquals(expected, new URI(actual).toString());
assertEquals(expected, new URL(actual).toString());
assertEquals(expected, URI.create(actual).toURL().toString());
}
}

View file

@ -1,11 +1,8 @@
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
handlers=java.util.logging.ConsoleHandler
.level=ALL
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.pattern=build/oai.log
jdk.event.security.level=INFO
jdk.internal.httpclient.hpack.debug.level=INFO
jdk.internal.httpclient.debug.level=INFO

View file

@ -4,9 +4,6 @@ module org.xbib.oai {
exports org.xbib.oai.rdf;
exports org.xbib.oai.util;
exports org.xbib.oai.xml;
requires org.xbib.content.core;
requires org.xbib.content.rdf;
requires org.xbib.content.resource;
requires org.xbib.content.xml;
requires transitive org.xbib.content.rdf;
requires java.xml;
}

View file

@ -2,9 +2,6 @@ package org.xbib.oai.util;
import java.time.Instant;
/**
*
*/
public class RecordHeader {
private String identifier;
@ -13,6 +10,9 @@ public class RecordHeader {
private String set;
public RecordHeader() {
}
public RecordHeader setIdentifier(String identifier) {
this.identifier = identifier;
return this;

View file

@ -3,13 +3,13 @@ package org.xbib.oai.xml;
import org.xbib.content.xml.util.XMLFilterReader;
import org.xbib.oai.util.RecordHeader;
/**
*
*/
public class SimpleMetadataHandler extends XMLFilterReader implements MetadataHandler {
private RecordHeader header;
public SimpleMetadataHandler() {
}
@Override
public SimpleMetadataHandler setHeader(RecordHeader header) {
this.header = header;

View file

@ -22,9 +22,6 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Namespace;
/**
*
*/
public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements OAIConstants {
private static final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
@ -45,6 +42,9 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
private boolean needToCallStartDocument = false;
public XmlSimpleMetadataHandler() {
}
public XmlSimpleMetadataHandler setWriter(Writer writer) throws XMLStreamException {
this.writer = writer;
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);

View file

@ -0,0 +1,16 @@
import org.xbib.oai.server.OAIServer;
module org.xbib.oai.server.main {
requires java.logging;
requires transitive java.xml;
requires transitive org.xbib.oai;
exports org.xbib.oai.server;
exports org.xbib.oai.server.getrecord;
exports org.xbib.oai.server.identify;
exports org.xbib.oai.server.listidentifiers;
exports org.xbib.oai.server.listmetadataformats;
exports org.xbib.oai.server.listrecords;
exports org.xbib.oai.server.listsets;
exports org.xbib.oai.server.verb;
uses OAIServer;
}

View file

@ -8,9 +8,6 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public abstract class AbstractOAIRequest implements OAIRequest {
private String path;

View file

@ -11,6 +11,9 @@ public abstract class AbstractOAIResponse implements OAIResponse {
private XMLEventConsumer consumer;
public AbstractOAIResponse() {
}
public AbstractOAIResponse setConsumer(XMLEventConsumer consumer) {
this.consumer = consumer;
return this;

View file

@ -11,9 +11,6 @@ import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class OAIServiceFactory {
private static final Logger logger = Logger.getLogger(OAIServiceFactory.class.getName());

View file

@ -15,13 +15,11 @@ import org.xbib.oai.server.listsets.ListSetsServerRequest;
import org.xbib.oai.server.listsets.ListSetsServerResponse;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Date;
import java.util.Properties;
/**
*
*/
public class PropertiesOAIServer implements OAIServer {
private static final String ADAPTER_URI = "uri";
@ -42,7 +40,7 @@ public class PropertiesOAIServer implements OAIServer {
private static final String GRANULARITY = "identify.granularity";
private Properties properties;
private final Properties properties;
public PropertiesOAIServer(Properties properties) {
this.properties = properties;
@ -51,7 +49,7 @@ public class PropertiesOAIServer implements OAIServer {
@Override
public URL getURL() {
try {
return new URL(properties.getProperty(ADAPTER_URI).trim());
return URI.create(properties.getProperty(ADAPTER_URI).trim()).toURL();
} catch (MalformedURLException e) {
//
}
@ -70,7 +68,7 @@ public class PropertiesOAIServer implements OAIServer {
@Override
public URL getBaseURL() {
try {
return new URL(properties.getProperty(BASE_URL));
return URI.create(properties.getProperty(BASE_URL)).toURL();
} catch (MalformedURLException e) {
return null;
}

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.getrecord;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class GetRecordServerRequest extends AbstractOAIRequest {
public GetRecordServerRequest() {
}
}

View file

@ -2,8 +2,8 @@ package org.xbib.oai.server.getrecord;
import org.xbib.oai.server.AbstractOAIResponse;
/**
*
*/
public class GetRecordServerResponse extends AbstractOAIResponse {
public GetRecordServerResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI get record.
*/
package org.xbib.oai.server.getrecord;

View file

@ -2,8 +2,8 @@ package org.xbib.oai.server.identify;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class IdentifyServerRequest extends AbstractOAIRequest {
public IdentifyServerRequest() {
}
}

View file

@ -7,9 +7,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
public class IdentifyServerResponse extends AbstractOAIResponse {
private String repositoryName;
@ -18,7 +15,7 @@ public class IdentifyServerResponse extends AbstractOAIResponse {
private String protocolVersion;
private List<String> adminEmails = new ArrayList<>();
private final List<String> adminEmails = new ArrayList<>();
private Date earliestDatestamp;
@ -28,6 +25,9 @@ public class IdentifyServerResponse extends AbstractOAIResponse {
private String compression;
public IdentifyServerResponse() {
}
public void setRepositoryName(String repositoryName) {
this.repositoryName = repositoryName;
}

View file

@ -1,4 +0,0 @@
/**
* OAI identify verb.
*/
package org.xbib.oai.server.identify;

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listidentifiers;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class ListIdentifiersServerRequest extends AbstractOAIRequest {
public ListIdentifiersServerRequest() {
}
}

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listidentifiers;
import org.xbib.oai.server.AbstractOAIResponse;
/**
*
*/
public class ListIdentifiersServerResponse extends AbstractOAIResponse {
public ListIdentifiersServerResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list identifiers verb.
*/
package org.xbib.oai.server.listidentifiers;

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listmetadataformats;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class ListMetadataFormatsServerRequest extends AbstractOAIRequest {
public ListMetadataFormatsServerRequest() {
}
}

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listmetadataformats;
import org.xbib.oai.server.AbstractOAIResponse;
/**
*
*/
public class ListMetadataFormatsServerResponse extends AbstractOAIResponse {
public ListMetadataFormatsServerResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list metadata formats verb.
*/
package org.xbib.oai.server.listmetadataformats;

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listrecords;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class ListRecordsServerRequest extends AbstractOAIRequest {
public ListRecordsServerRequest() {
}
}

View file

@ -4,9 +4,6 @@ import org.xbib.oai.server.AbstractOAIResponse;
import java.util.Date;
/**
*
*/
public class ListRecordsServerResponse extends AbstractOAIResponse {
private String error;
@ -15,6 +12,9 @@ public class ListRecordsServerResponse extends AbstractOAIResponse {
private long expire;
public ListRecordsServerResponse() {
}
public void setError(String error) {
this.error = error;
}

View file

@ -1,4 +0,0 @@
/**
* OAI list records verb.
*/
package org.xbib.oai.server.listrecords;

View file

@ -2,9 +2,8 @@ package org.xbib.oai.server.listsets;
import org.xbib.oai.server.AbstractOAIRequest;
/**
*
*/
public class ListSetsServerRequest extends AbstractOAIRequest {
public ListSetsServerRequest() {
}
}

View file

@ -2,8 +2,8 @@ package org.xbib.oai.server.listsets;
import org.xbib.oai.server.AbstractOAIResponse;
/**
*
*/
public class ListSetsServerResponse extends AbstractOAIResponse {
public ListSetsServerResponse() {
}
}

View file

@ -1,4 +0,0 @@
/**
* OAI list sets verb.
*/
package org.xbib.oai.server.listsets;

View file

@ -1,4 +0,0 @@
/**
* Classes for OAI server.
*/
package org.xbib.oai.server;

View file

@ -1,4 +0,0 @@
/**
* Classes for OAI server verbs.
*/
package org.xbib.oai.server.verb;

View file

@ -0,0 +1,7 @@
module org.xbib.oai.server.test {
requires java.xml;
requires org.junit.jupiter.api;
requires org.xbib.oai;
requires org.xbib.oai.server.main;
opens org.xbib.oai.server.test to org.junit.platform.commons;
}

View file

@ -1,4 +0,0 @@
/**
* Classes for OAI server.
*/
package org.xbib.oai.server;

View file

@ -1,6 +1,7 @@
package org.xbib.oai.server;
package org.xbib.oai.server.test;
import org.xbib.oai.exceptions.OAIException;
import org.xbib.oai.server.OAIServer;
import org.xbib.oai.server.getrecord.GetRecordServerRequest;
import org.xbib.oai.server.getrecord.GetRecordServerResponse;
import org.xbib.oai.server.identify.IdentifyServerRequest;
@ -16,6 +17,7 @@ import org.xbib.oai.server.listsets.ListSetsServerResponse;
import org.xbib.oai.server.verb.Identify;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Date;
@ -58,7 +60,7 @@ public class SimpleServer implements OAIServer {
@Override
public URL getURL() {
try {
return new URL("http://localhost:8080/oai");
return URI.create("http://localhost:8080/oai").toURL();
} catch (MalformedURLException e) {
//
}

View file

@ -1,6 +1,8 @@
package org.xbib.oai.server;
package org.xbib.oai.server.test;
import org.junit.jupiter.api.Test;
import org.xbib.oai.server.OAIServer;
import org.xbib.oai.server.OAIServiceFactory;
import org.xbib.oai.server.identify.IdentifyServerRequest;
import org.xbib.oai.server.identify.IdentifyServerResponse;

View file

@ -1 +1 @@
org.xbib.oai.server.SimpleServer
org.xbib.oai.server.test.SimpleServer

View file

@ -1,20 +1,23 @@
dependencyResolutionManagement {
versionCatalogs {
libs {
version('gradle', '8.1.1')
version('junit', '5.9.3')
version('content', '5.0.3')
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
version('gradle', '8.7')
version('content', '5.2.0')
library('content-core', 'org.xbib', 'content-json').versionRef('content')
library('content-rdf', 'org.xbib', 'content-rdf').versionRef('content')
library('content-resource', 'org.xbib', 'content-resource').versionRef('content')
library('content-xml', 'org.xbib', 'content-xml').versionRef('content')
library('marc', 'org.xbib', 'marc').version('2.11.0')
library('marc', 'org.xbib', 'marc').version('2.14.1')
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('3.0.0')
}
testLibs {
version('junit', '5.10.2')
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
library('junit-jupiter-platform-launcher', 'org.junit.platform', 'junit-platform-launcher').version('1.10.1')
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
}
}
}