reorganize package structure for fine grained dependencies

This commit is contained in:
Jörg Prante 2019-03-15 13:45:07 +01:00
parent d0c91568a8
commit b2df8b14ba
208 changed files with 618 additions and 454 deletions

View file

@ -1,5 +1,5 @@
plugins { plugins {
id "com.github.spotbugs" version "1.6.2" id "com.github.spotbugs" version "1.6.9"
id "org.sonarqube" version '2.6.1' id "org.sonarqube" version '2.6.1'
id "io.codearte.nexus-staging" version "0.11.0" id "io.codearte.nexus-staging" version "0.11.0"
} }
@ -18,22 +18,14 @@ printf "Host: %s\nOS: %s %s %s\nJVM: %s %s %s %s\nGradle: %s Groovy: %s Java: %s
GroovySystem.getVersion(), GroovySystem.getVersion(),
JavaVersion.current() JavaVersion.current()
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'jacoco'
apply plugin: "com.github.spotbugs"
apply from: "${rootProject.projectDir}/gradle/ext.gradle"
apply from: "${rootProject.projectDir}/gradle/sonarqube.gradle"
subprojects { subprojects {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'signing' apply plugin: 'signing'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: "com.github.spotbugs"
configurations { configurations {
wagon wagon
@ -63,8 +55,9 @@ subprojects {
} }
test { test {
systemProperty 'java.util.logging.config.file', project.file('src/test/resources/logging.properties')
testLogging { testLogging {
showStandardStreams = false showStandardStreams = true
exceptionFormat = 'full' exceptionFormat = 'full'
} }
} }
@ -87,6 +80,16 @@ subprojects {
sign configurations.archives sign configurations.archives
} }
} }
ext {
user = 'xbib'
projectName = 'z3950'
projectDescription = 'Z39.50 for Java'
scmUrl = 'https://github.com/xbib/z3950'
scmConnection = 'scm:git:git://github.com/xbib/z3950.git'
scmDeveloperConnection = 'scm:git:git://github.com/xbib/z3950.git'
}
apply from: "${rootProject.projectDir}/gradle/publish.gradle" apply from: "${rootProject.projectDir}/gradle/publish.gradle"
apply from: "${rootProject.projectDir}/gradle/sonarqube.gradle"
} }

View file

@ -1,9 +1,9 @@
group = org.xbib group = org.xbib
name = z3950 name = z3950
version = 1.2.1 version = 1.3.0
xbib-cql.version = 1.2.0 xbib-cql.version = 1.2.0
netty.version = 4.1.29.Final netty.version = 4.1.34.Final
junit.version = 4.12 junit.version = 4.12
wagon.version = 3.0.0 wagon.version = 3.0.0

View file

@ -1,8 +0,0 @@
ext {
user = 'xbib'
projectName = 'z3950'
projectDescription = 'Z39.50 for Java'
scmUrl = 'https://github.com/xbib/z3950'
scmConnection = 'scm:git:git://github.com/xbib/z3950.git'
scmDeveloperConnection = 'scm:git:git://github.com/xbib/z3950.git'
}

View file

@ -1,5 +1,4 @@
spotbugs { spotbugs {
toolVersion = '3.1.3' toolVersion = '3.1.3'
sourceSets = [sourceSets.main] sourceSets = [sourceSets.main]
@ -7,14 +6,17 @@ spotbugs {
effort = "max" effort = "max"
reportLevel = "high" reportLevel = "high"
} }
spotbugsMain.reports { spotbugsMain.reports {
xml.enabled = false xml.enabled = false
html.enabled = true html.enabled = true
} }
spotbugsTest.reports { spotbugsTest.reports {
xml.enabled = false xml.enabled = false
html.enabled = true html.enabled = true
} }
tasks.withType(Pmd) { tasks.withType(Pmd) {
ignoreFailures = true ignoreFailures = true
reports { reports {
@ -31,20 +33,12 @@ tasks.withType(Checkstyle) {
} }
} }
jacocoTestReport {
reports {
xml.enabled = true
csv.enabled = false
}
}
sonarqube { sonarqube {
properties { properties {
property "sonar.projectName", "${project.group} ${project.name}" property "sonar.projectName", "${project.group} ${project.name}"
property "sonar.sourceEncoding", "UTF-8" property "sonar.sourceEncoding", "UTF-8"
property "sonar.tests", "src/test/java" property "sonar.tests", "src/test/java"
property "sonar.scm.provider", "git" property "sonar.scm.provider", "git"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.junit.reportsPath", "build/test-results/test/" property "sonar.junit.reportsPath", "build/test-results/test/"
} }
} }

Binary file not shown.

View file

@ -1,6 +1,6 @@
#Fri Sep 07 18:47:56 CEST 2018 #Thu Mar 14 15:23:27 CET 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

2
gradlew vendored
View file

@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"

2
gradlew.bat vendored
View file

@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View file

@ -1,2 +1,6 @@
include 'asn1' include 'z3950-asn1'
include 'z3950' include 'z3950-api'
include 'z3950-common'
include 'z3950-client'
include 'z3950-client-netty'
include 'z3950-sru'

3
z3950-api/build.gradle Normal file
View file

@ -0,0 +1,3 @@
dependencies {
compile project(':z3950-asn1')
}

View file

@ -0,0 +1,44 @@
package org.xbib.z3950.api;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
public interface Client extends Closeable {
int searchCQL(String query, int offset, int length,
SearchListener searchListener,
RecordListener recordListener) throws IOException;
int searchPQF(String query, int offset, int length,
SearchListener searchListener,
RecordListener recordListener) throws IOException;
void scanPQF(String query, int nTerms, int step, int position,
ScanListener scanListener) throws IOException;
String getHost();
int getPort();
String getUser();
String getPass();
long getTimeout();
String getPreferredRecordSyntax();
String getResultSetName();
String getElementSetName();
String getEncoding();
String getFormat();
String getType();
List<String> getDatabases();
}

View file

@ -0,0 +1,6 @@
package org.xbib.z3950.api;
public interface ClientProvider<C extends Client> {
C getClient();
}

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950; package org.xbib.z3950.api;
/** /**
* *

View file

@ -0,0 +1,13 @@
package org.xbib.z3950.api;
import java.io.InputStream;
import java.nio.charset.Charset;
public interface Record {
int getNumber();
InputStream asStream();
String toString(Charset charset);
}

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950; package org.xbib.z3950.api;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950; package org.xbib.z3950.api;
import org.xbib.asn1.BEREncoding; import org.xbib.asn1.BEREncoding;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950; package org.xbib.z3950.api;
import java.io.IOException; import java.io.IOException;

View file

@ -0,0 +1,5 @@
dependencies {
compile project(':z3950-common')
compile "io.netty:netty-handler:${project.property('netty.version')}"
compile "io.netty:netty-transport:${project.property('netty.version')}"
}

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.netty; package org.xbib.z3950.client.netty;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -42,7 +42,6 @@ public class NettyZClient {
} }
public void shutdown() throws InterruptedException { public void shutdown() throws InterruptedException {
group.shutdownGracefully().sync(); group.shutdownGracefully().sync();
} }

View file

@ -0,0 +1,3 @@
dependencies {
compile project(':z3950-common')
}

View file

@ -1,12 +1,17 @@
package org.xbib.io.iso23950; package org.xbib.z3950.client;
import org.xbib.asn1.io.InputStreamBERReader; import org.xbib.asn1.io.InputStreamBERReader;
import org.xbib.asn1.io.OutputStreamBERWriter; import org.xbib.asn1.io.OutputStreamBERWriter;
import org.xbib.io.iso23950.operations.CloseOperation; import org.xbib.z3950.common.operations.CloseOperation;
import org.xbib.io.iso23950.operations.InitOperation; import org.xbib.z3950.common.operations.InitOperation;
import org.xbib.io.iso23950.operations.PresentOperation; import org.xbib.z3950.common.operations.PresentOperation;
import org.xbib.io.iso23950.operations.ScanOperation; import org.xbib.z3950.common.operations.ScanOperation;
import org.xbib.io.iso23950.operations.SearchOperation; import org.xbib.z3950.common.operations.SearchOperation;
import org.xbib.z3950.api.Client;
import org.xbib.z3950.api.InitListener;
import org.xbib.z3950.api.RecordListener;
import org.xbib.z3950.api.ScanListener;
import org.xbib.z3950.api.SearchListener;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -27,9 +32,9 @@ import java.util.logging.Logger;
/** /**
* Default Z client. * Default Z client.
*/ */
public class ZClient implements AutoCloseable { public class DefaultClient implements Client {
private static final Logger logger = Logger.getLogger(ZClient.class.getName()); private static final Logger logger = Logger.getLogger(DefaultClient.class.getName());
private final String host; private final String host;
@ -67,7 +72,7 @@ public class ZClient implements AutoCloseable {
private OutputStreamBERWriter berWriter; private OutputStreamBERWriter berWriter;
private ZClient(String host, int port, String user, String pass, long timeout, private DefaultClient(String host, int port, String user, String pass, long timeout,
String preferredRecordSyntax, String preferredRecordSyntax,
String resultSetName, String resultSetName,
String elementSetName, String elementSetName,
@ -127,6 +132,7 @@ public class ZClient implements AutoCloseable {
} }
} }
@Override
public int searchCQL(String query, int offset, int length, public int searchCQL(String query, int offset, int length,
SearchListener searchListener, SearchListener searchListener,
RecordListener recordListener) throws IOException { RecordListener recordListener) throws IOException {
@ -167,6 +173,7 @@ public class ZClient implements AutoCloseable {
} }
} }
@Override
public int searchPQF(String query, int offset, int length, public int searchPQF(String query, int offset, int length,
SearchListener searchListener, SearchListener searchListener,
RecordListener recordListener) throws IOException { RecordListener recordListener) throws IOException {
@ -208,6 +215,7 @@ public class ZClient implements AutoCloseable {
} }
} }
@Override
public void scanPQF(String query, int nTerms, int step, int position, public void scanPQF(String query, int nTerms, int step, int position,
ScanListener scanListener) throws IOException { ScanListener scanListener) throws IOException {
ensureConnected(); ensureConnected();
@ -220,55 +228,76 @@ public class ZClient implements AutoCloseable {
} }
} }
@Override
public String getHost() { public String getHost() {
return host; return host;
} }
@Override
public int getPort() { public int getPort() {
return port; return port;
} }
@Override
public String getUser() { public String getUser() {
return user; return user;
} }
@Override
public String getPass() { public String getPass() {
return pass; return pass;
} }
@Override
public long getTimeout() { public long getTimeout() {
return timeout; return timeout;
} }
@Override
public String getPreferredRecordSyntax() { public String getPreferredRecordSyntax() {
return preferredRecordSyntax; return preferredRecordSyntax;
} }
@Override
public String getResultSetName() { public String getResultSetName() {
return resultSetName; return resultSetName;
} }
@Override
public String getElementSetName() { public String getElementSetName() {
return elementSetName; return elementSetName;
} }
@Override
public String getEncoding() { public String getEncoding() {
return encoding; return encoding;
} }
@Override
public String getFormat() { public String getFormat() {
return format; return format;
} }
@Override
public String getType() { public String getType() {
return type; return type;
} }
@Override
public List<String> getDatabases() { public List<String> getDatabases() {
return databases; return databases;
} }
private void connect() throws IOException { private void connect() throws IOException {
}
private boolean isConnected() {
return socket != null && socket.isConnected();
}
private void ensureConnected() throws IOException {
if (!isConnected()) {
try { try {
lock.lock(); lock.lock();
Socket socket = new Socket(); Socket socket = new Socket();
@ -288,15 +317,6 @@ public class ZClient implements AutoCloseable {
lock.unlock(); lock.unlock();
} }
} }
private boolean isConnected() {
return socket != null && socket.isConnected();
}
private void ensureConnected() throws IOException {
if (!isConnected()) {
connect();
}
} }
public static Builder builder() { public static Builder builder() {
@ -331,7 +351,7 @@ public class ZClient implements AutoCloseable {
public static class Builder { public static class Builder {
private static final ResourceBundle recordSyntaxBundle = private static final ResourceBundle recordSyntaxBundle =
ResourceBundle.getBundle("org.xbib.io.iso23950.recordsyntax"); ResourceBundle.getBundle("org.xbib.z3950.common.recordsyntax");
private String host; private String host;
@ -434,8 +454,8 @@ public class ZClient implements AutoCloseable {
return this; return this;
} }
public ZClient build() { public DefaultClient build() {
return new ZClient(host, port, user, pass, timeout, return new DefaultClient(host, port, user, pass, timeout,
preferredRecordSyntax, preferredRecordSyntax,
resultSetName, resultSetName,
elementSetName, elementSetName,

View file

@ -1,6 +1,7 @@
package org.xbib.io.iso23950; package org.xbib.z3950.client.test;
import org.junit.Test; import org.junit.Test;
import org.xbib.z3950.client.DefaultClient;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -14,9 +15,9 @@ import java.util.logging.Logger;
/** /**
* *
*/ */
public class ZClientTest { public class DefaultClientTest {
private static final Logger logger = Logger.getLogger(ZClientTest.class.getName()); private static final Logger logger = Logger.getLogger(DefaultClientTest.class.getName());
@Test @Test
public void testCQL() { public void testCQL() {
@ -24,7 +25,7 @@ public class ZClientTest {
String query = "bib.identifierISSN = 00280836"; String query = "bib.identifierISSN = 00280836";
int from = 1; int from = 1;
int size = 10; int size = 10;
try (ZClient client = newZClient(serviceName)) { try (DefaultClient client = newZClient(serviceName)) {
logger.log(Level.INFO, "executing CQL " + serviceName); logger.log(Level.INFO, "executing CQL " + serviceName);
int count = client.searchCQL(query, from, size, int count = client.searchCQL(query, from, size,
(status, total, returned, elapsedMillis) -> (status, total, returned, elapsedMillis) ->
@ -37,31 +38,13 @@ public class ZClientTest {
} }
} }
@Test
public void testGBV() {
String serviceName = "GBV";
String query = "gbv.controlNumberZDB = 1413423-8";
int from = 1;
int size = 2;
try (ZClient client = newZClient(serviceName)) {
logger.log(Level.INFO, "executing CQL " + query);
int count = client.searchCQL(query, from, size,
(status, total, returned, elapsedMillis) ->
logger.log(Level.INFO, serviceName + " total results = " + total),
record -> logger.log(Level.INFO, "record = " + record));
logger.log(Level.INFO, "returned records = " + count);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@Test @Test
public void testPQF() { public void testPQF() {
for (String serviceName : Arrays.asList("LIBRIS", "SWB")) { for (String serviceName : Arrays.asList("LIBRIS", "SWB")) {
String query = "@attr 1=8 \"00280836\""; String query = "@attr 1=8 \"00280836\"";
int from = 1; int from = 1;
int size = 10; int size = 10;
try (ZClient client = newZClient(serviceName)) { try (DefaultClient client = newZClient(serviceName)) {
logger.log(Level.INFO, "executing PQF " + serviceName); logger.log(Level.INFO, "executing PQF " + serviceName);
int count = client.searchPQF(query, from, size, int count = client.searchPQF(query, from, size,
(status, total, returned, elapsedMillis) -> (status, total, returned, elapsedMillis) ->
@ -74,21 +57,20 @@ public class ZClientTest {
} }
} }
private static ZClient newZClient(String name) throws IOException { private DefaultClient newZClient(String name) throws IOException {
return newZClient(getProperties(name)); return newZClient(getProperties(name));
} }
private static Properties getProperties(String name) throws IOException { private Properties getProperties(String name) throws IOException {
Properties properties = new Properties(); Properties properties = new Properties();
try (InputStream inputStream = try (InputStream inputStream = getClass().getResourceAsStream(name + ".properties")) {
ZClient.class.getResourceAsStream("/org/xbib/io/iso23950/service/" + name + ".properties")) {
properties.load(inputStream); properties.load(inputStream);
} }
return properties; return properties;
} }
private static ZClient newZClient(Properties properties) { private static DefaultClient newZClient(Properties properties) {
ZClient.Builder builder = ZClient.builder(); DefaultClient.Builder builder = DefaultClient.builder();
if (properties.containsKey("host")) { if (properties.containsKey("host")) {
builder.setHost(properties.getProperty("host")); builder.setHost(properties.getProperty("host"));
} }

View file

@ -0,0 +1,110 @@
package org.xbib.z3950.client.test;
import org.junit.Test;
import org.xbib.z3950.client.DefaultClient;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
/**
* GBV test.
*/
public class GBVZClientTest {
private static final Logger logger = Logger.getLogger(GBVZClientTest.class.getName());
@Test
public void testGBV() {
String query = "@attr 1=4 linux";
int from = 1;
int size = 10;
try (DefaultClient client = newZClient("GBV")) {
logger.log(Level.INFO, "executing PQF " + query);
int count = client.searchPQF(query, from, size,
(status, total, returned, elapsedMillis) ->
logger.log(Level.INFO, "total results = " + total + " millis = " + elapsedMillis),
record -> logger.log(Level.INFO, "record = " + record.toString(StandardCharsets.UTF_8)));
logger.log(Level.INFO, "record count = " + count);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
@Test
public void testControlNumberZDB() {
String serviceName = "GBV";
String query = "bib.controlNumberZDB = 1413423-8";
int from = 1;
int size = 2;
try (DefaultClient client = newZClient(serviceName)) {
logger.log(Level.INFO, "executing CQL " + query);
int count = client.searchCQL(query, from, size,
(status, total, returned, elapsedMillis) ->
logger.log(Level.INFO, serviceName + " total results = " + total),
record -> logger.log(Level.INFO, "record = " + record));
logger.log(Level.INFO, "returned records = " + count);
assertEquals(1, count);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
private DefaultClient newZClient(String name) throws IOException {
return newZClient(getProperties(name));
}
private Properties getProperties(String name) throws IOException {
Properties properties = new Properties();
try (InputStream inputStream = getClass().getResourceAsStream(name + ".properties")) {
properties.load(inputStream);
}
return properties;
}
private static DefaultClient newZClient(Properties properties) {
DefaultClient.Builder builder = DefaultClient.builder();
if (properties.containsKey("host")) {
builder.setHost(properties.getProperty("host"));
}
if (properties.containsKey("port")) {
builder.setPort(Integer.parseInt(properties.getProperty("port")));
}
if (properties.containsKey("user")) {
builder.setUser(properties.getProperty("user"));
}
if (properties.containsKey("pass")) {
builder.setPass(properties.getProperty("pass"));
}
if (properties.containsKey("database")) {
builder.setDatabases(Collections.singletonList(properties.getProperty("database")));
}
if (properties.containsKey("elementsetname")) {
builder.setElementSetName(properties.getProperty("elementsetname"));
}
if (properties.containsKey("preferredrecordsyntax")) {
builder.setPreferredRecordSyntax(properties.getProperty("preferredrecordsyntax"));
}
if (properties.containsKey("resultsetname")) {
builder.setResultSetName(properties.getProperty("resultsetname"));
}
if (properties.containsKey("encoding")) {
builder.setEncoding(properties.getProperty("encoding"));
}
if (properties.containsKey("format")) {
builder.setFormat(properties.getProperty("format"));
}
if (properties.containsKey("type")) {
builder.setType(properties.getProperty("type"));
}
return builder.build();
}
}

View file

@ -4,8 +4,6 @@ plugins {
} }
dependencies { dependencies {
compile project(':asn1') compile project(':z3950-api')
compile "org.xbib:cql-common:${project.property('xbib-cql.version')}" compile "org.xbib:cql-common:${project.property('xbib-cql.version')}"
compile "io.netty:netty-handler:${project.property('netty.version')}"
compile "io.netty:netty-transport:${project.property('netty.version')}"
} }

View file

@ -0,0 +1 @@
%{ import java.io.Reader; import java.io.IOException; /** Mike Taylor, IndexData: "Prefix Query Format (PQF), also known as Prefix Query Notation (PQN) was defined in 1995, as part of the YAZ toolkit, and has since become the de facto standard representation of RPN queries." From: http://www.indexdata.com/yaz/doc/tools.tkl#PQF The grammar of the PQF is as follows: query ::= top-set query-struct. top-set ::= [ '@attrset' string ] query-struct ::= attr-spec | simple | complex | '@term' term-type query attr-spec ::= '@attr' [ string ] string query-struct complex ::= operator query-struct query-struct. operator ::= '@and' | '@or' | '@not' | '@prox' proximity. simple ::= result-set | term. result-set ::= '@set' string. term ::= string. proximity ::= exclusion distance ordered relation which-code unit-code. exclusion ::= '1' | '0' | 'void'. distance ::= integer. ordered ::= '1' | '0'. relation ::= integer. which-code ::= 'known' | 'private' | integer. unit-code ::= integer. term-type ::= 'general' | 'numeric' | 'string' | 'oid' | 'datetime' | 'null'. You will note that the syntax above is a fairly faithful representation of RPN, except for the Attribute, which has been moved a step away from the term, allowing you to associate one or more attributes with an entire query structure. The parser will automatically apply the given attributes to each term as required. The @attr operator is followed by an attribute specification (attr-spec above). The specification consists of an optional attribute set, an attribute type-value pair and a sub-query. The attribute type-value pair is packed in one string: an attribute type, an equals sign, and an attribute value, like this: @attr 1=1003. The type is always an integer but the value may be either an integer or a string (if it doesn't start with a digit character). A string attribute-value is encoded as a Type-1 ``complex'' attribute with the list of values containing the single string specified, and including no semantic indicators. */ %} %class PQFParser %interface PQFTokens %package org.xbib.z3950.common.pqf %token NL %token <String> OR %token <String> AND %token <String> NOT %token <String> ATTR %token <String> ATTRSET %token <String> TERM %token <String> SET %token <String> VOID %token <String> KNOWN %token <String> PRIVATE %token <String> TERMTYPE %token <String> CHARSTRING1 %token <String> CHARSTRING2 %token <String> OPERATORS %token <String> EQUALS %token <Integer> INTEGER %left AND %left OR %left NOT %type <PQF> pqf %type <Query> querystruct %type <Expression> expression %type <AttrStr> attrstr %type <Term> term %type <Setname> resultset %start pqf %% pqf : ATTRSET CHARSTRING1 querystruct { this.pqf = new PQF($2, $3); $$ = this.pqf; } | querystruct { this.pqf = new PQF($1); $$ = this.pqf; } ; querystruct : attrspec | simple | complex | TERM TERMTYPE pqf { $$ = new Query($3); }; attrspec : ATTR attrstr querystruct { $$ = new Query($2, $3); } | ATTR CHARSTRING1 attrstr querystruct { $$ = new Query($2, $3, $4); }; simple : resultset { $$ = new Query($1); } | term { $$ = new Query($1); }; complex : expression { $$ = new Query($1); }; resultset : SET CHARSTRING1 { $$ = new Setname($2); }; term : CHARSTRING1 { $$ = new Term($1); } | CHARSTRING2 { $$ = new Term($1); } }; attrstr: INTEGER EQUALS INTEGER { $$ = new AttrStr($1, $3); } | INTEGER EQUALS CHARSTRING1 { $$ = new AttrStr($1, $3); }; expression: AND querystruct querystruct { $$ = new Expression($1, $2, $3); } | OR querystruct querystruct { $$ = new Expression($1, $2, $3); } | NOT querystruct querystruct { $$ = new Expression($1, $2, $3); } ; %% private PQFLexer lexer; private PQF pqf; public PQFParser(Reader r) { this.lexer = new PQFLexer(r); lexer.nextToken(); } public void yyerror(String error) { throw new SyntaxException("PQF error at " + "[" + lexer.getLine() + "," + lexer.getColumn() +"]" + ": " + error); } public PQF getResult() { return pqf; }

View file

@ -1,4 +1,6 @@
package org.xbib.io.iso23950; package org.xbib.z3950.common;
import org.xbib.z3950.api.Record;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -7,7 +9,7 @@ import java.nio.charset.Charset;
/** /**
* A record for Z39.50 presentations. * A record for Z39.50 presentations.
*/ */
public class Record { public class DefaultRecord implements Record {
private final int number; private final int number;
@ -15,20 +17,23 @@ public class Record {
private final ByteArrayInputStream stream; private final ByteArrayInputStream stream;
public Record(int number, byte[] content) { public DefaultRecord(int number, byte[] content) {
this.number = number; this.number = number;
this.content = content; this.content = content;
this.stream = new ByteArrayInputStream(content); this.stream = new ByteArrayInputStream(content);
} }
@Override
public int getNumber() { public int getNumber() {
return number; return number;
} }
@Override
public InputStream asStream() { public InputStream asStream() {
return stream; return stream;
} }
@Override
public String toString(Charset charset) { public String toString(Charset charset) {
return new String(content, charset); return new String(content, charset);
} }

View file

@ -0,0 +1,38 @@
package org.xbib.z3950.common;
import java.io.IOException;
import java.util.ResourceBundle;
/**
* Diagnostics for Z server.
*/
public class Diagnostics extends IOException {
private static final ResourceBundle bundle =
ResourceBundle.getBundle("org.xbib.z3950.common.diagnostics");
private static final long serialVersionUID = -899201811019819079L;
private int diagCode;
private String message;
public Diagnostics(int diagCode, String message) {
super("" + diagCode + " " + bundle.getString(Integer.toString(diagCode)) + " " + message);
this.diagCode = diagCode;
this.message = message;
}
public int getDiagCode() {
return diagCode;
}
public String getPlainText() {
return message;
}
@Override
public String toString() {
return message;
}
}

View file

@ -1,9 +1,9 @@
package org.xbib.io.iso23950; package org.xbib.z3950.common;
/** /**
* *
*/ */
public class ErrorRecord extends Record { public class ErrorRecord extends DefaultRecord {
public ErrorRecord(int number, byte[] content) { public ErrorRecord(int number, byte[] content) {
super(number, content); super(number, content);

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.cql; package org.xbib.z3950.common.cql;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Integer; import org.xbib.asn1.ASN1Integer;
@ -22,16 +22,16 @@ import org.xbib.cql.SortSpec;
import org.xbib.cql.SortedQuery; import org.xbib.cql.SortedQuery;
import org.xbib.cql.Term; import org.xbib.cql.Term;
import org.xbib.cql.Visitor; import org.xbib.cql.Visitor;
import org.xbib.io.iso23950.v3.AttributeElement; import org.xbib.z3950.common.v3.AttributeElement;
import org.xbib.io.iso23950.v3.AttributeElementAttributeValue; import org.xbib.z3950.common.v3.AttributeElementAttributeValue;
import org.xbib.io.iso23950.v3.AttributeList; import org.xbib.z3950.common.v3.AttributeList;
import org.xbib.io.iso23950.v3.AttributeSetId; import org.xbib.z3950.common.v3.AttributeSetId;
import org.xbib.io.iso23950.v3.AttributesPlusTerm; import org.xbib.z3950.common.v3.AttributesPlusTerm;
import org.xbib.io.iso23950.v3.Operand; import org.xbib.z3950.common.v3.Operand;
import org.xbib.io.iso23950.v3.Operator; import org.xbib.z3950.common.v3.Operator;
import org.xbib.io.iso23950.v3.RPNQuery; import org.xbib.z3950.common.v3.RPNQuery;
import org.xbib.io.iso23950.v3.RPNStructure; import org.xbib.z3950.common.v3.RPNStructure;
import org.xbib.io.iso23950.v3.RPNStructureRpnRpnOp; import org.xbib.z3950.common.v3.RPNStructureRpnRpnOp;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -52,9 +52,9 @@ public final class CQLRPNGenerator implements Visitor {
private final Map<String, ResourceBundle> contexts = new HashMap<String, ResourceBundle>() { private final Map<String, ResourceBundle> contexts = new HashMap<String, ResourceBundle>() {
private static final long serialVersionUID = 8199395368653216950L; private static final long serialVersionUID = 8199395368653216950L;
{ {
put("bib", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.bib-1")); put("bib", ResourceBundle.getBundle("org.xbib.z3950.common.cql.bib-1"));
put("dc", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.dc")); put("dc", ResourceBundle.getBundle("org.xbib.z3950.common.cql.dc"));
put("gbv", ResourceBundle.getBundle("org.xbib.io.iso23950.cql.gbv")); put("gbv", ResourceBundle.getBundle("org.xbib.z3950.common.cql.gbv"));
} }
}; };
private Stack<ASN1Any> result; private Stack<ASN1Any> result;
@ -182,7 +182,7 @@ public final class CQLRPNGenerator implements Visitor {
} }
Operand operand = new Operand(); Operand operand = new Operand();
operand.attrTerm = new AttributesPlusTerm(); operand.attrTerm = new AttributesPlusTerm();
operand.attrTerm.term = new org.xbib.io.iso23950.v3.Term(); operand.attrTerm.term = new org.xbib.z3950.common.v3.Term();
operand.attrTerm.term.c_general = new ASN1OctetString(node.getTerm().getValue()); operand.attrTerm.term.c_general = new ASN1OctetString(node.getTerm().getValue());
Stack<AttributeElement> attrs = new Stack<>(); Stack<AttributeElement> attrs = new Stack<>();
ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null; ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.cql; package org.xbib.z3950.common.cql;
/** /**
* Syntax exception. * Syntax exception.

View file

@ -0,0 +1,4 @@
/**
*
*/
package org.xbib.z3950.common.cql;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.exceptions; package org.xbib.z3950.common.exceptions;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.exceptions; package org.xbib.z3950.common.exceptions;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.exceptions; package org.xbib.z3950.common.exceptions;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.exceptions; package org.xbib.z3950.common.exceptions;
import java.io.IOException; import java.io.IOException;

View file

@ -0,0 +1,4 @@
/**
*
*/
package org.xbib.z3950.common.exceptions;

View file

@ -1,19 +1,19 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Exception; import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.BEREncoding; import org.xbib.asn1.BEREncoding;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.v3.Close; import org.xbib.z3950.common.v3.Close;
import org.xbib.io.iso23950.v3.InitializeRequest; import org.xbib.z3950.common.v3.InitializeRequest;
import org.xbib.io.iso23950.v3.InitializeResponse; import org.xbib.z3950.common.v3.InitializeResponse;
import org.xbib.io.iso23950.v3.PresentRequest; import org.xbib.z3950.common.v3.PresentRequest;
import org.xbib.io.iso23950.v3.PresentResponse; import org.xbib.z3950.common.v3.PresentResponse;
import org.xbib.io.iso23950.v3.ScanRequest; import org.xbib.z3950.common.v3.ScanRequest;
import org.xbib.io.iso23950.v3.ScanResponse; import org.xbib.z3950.common.v3.ScanResponse;
import org.xbib.io.iso23950.v3.SearchRequest; import org.xbib.z3950.common.v3.SearchRequest;
import org.xbib.io.iso23950.v3.SearchResponse; import org.xbib.z3950.common.v3.SearchResponse;
import java.io.IOException; import java.io.IOException;

View file

@ -1,15 +1,19 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1Integer; import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.v3.Close; import org.xbib.z3950.common.v3.Close;
import org.xbib.io.iso23950.v3.CloseReason; import org.xbib.z3950.common.v3.CloseReason;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class CloseOperation extends AbstractOperation<Close, Close> { public class CloseOperation extends AbstractOperation<Close, Close> {
private static final Logger logger = Logger.getLogger(CloseOperation.class.getName());
public CloseOperation(BERReader reader, BERWriter writer) { public CloseOperation(BERReader reader, BERWriter writer) {
super(reader, writer); super(reader, writer);
} }
@ -19,6 +23,9 @@ public class CloseOperation extends AbstractOperation<Close, Close> {
close.closeReason = new CloseReason(); close.closeReason = new CloseReason();
close.closeReason.value = new ASN1Integer(reason); close.closeReason.value = new ASN1Integer(reason);
close.referenceId = null; close.referenceId = null;
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, close.toString());
}
write(close); write(close);
// do not wait, it may hang // do not wait, it may hang
//waitClosePDU(); //waitClosePDU();

View file

@ -1,20 +1,21 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1BitString; import org.xbib.asn1.ASN1BitString;
import org.xbib.asn1.ASN1GeneralString; import org.xbib.asn1.ASN1GeneralString;
import org.xbib.asn1.ASN1Integer; import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.InitListener; import org.xbib.z3950.common.v3.IdAuthentication;
import org.xbib.io.iso23950.v3.IdAuthentication; import org.xbib.z3950.common.v3.IdAuthenticationIdPass;
import org.xbib.io.iso23950.v3.IdAuthenticationIdPass; import org.xbib.z3950.common.v3.InitializeRequest;
import org.xbib.io.iso23950.v3.InitializeRequest; import org.xbib.z3950.common.v3.InitializeResponse;
import org.xbib.io.iso23950.v3.InitializeResponse; import org.xbib.z3950.common.v3.InternationalString;
import org.xbib.io.iso23950.v3.InternationalString; import org.xbib.z3950.common.v3.Options;
import org.xbib.io.iso23950.v3.Options; import org.xbib.z3950.common.v3.ProtocolVersion;
import org.xbib.io.iso23950.v3.ProtocolVersion; import org.xbib.z3950.api.InitListener;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@ -79,10 +80,9 @@ public class InitOperation extends AbstractOperation<InitializeResponse, Initial
init.idAuthentication.idPass.s_password = new InternationalString(); init.idAuthentication.idPass.s_password = new InternationalString();
init.idAuthentication.idPass.s_password.value = new ASN1GeneralString(pass); init.idAuthentication.idPass.s_password.value = new ASN1GeneralString(pass);
} }
/*if (group != null) { }
init.s_idAuthentication.c_idPass.s_groupId = new InternationalString(); if (logger.isLoggable(Level.FINE)) {
init.s_idAuthentication.c_idPass.s_groupId.value = new ASN1GeneralString(group); logger.log(Level.FINE, init.toString());
}*/
} }
write(init); write(init);
InitializeResponse initResp = read(); InitializeResponse initResp = read();

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1Exception; import org.xbib.asn1.ASN1Exception;
import org.xbib.asn1.ASN1External; import org.xbib.asn1.ASN1External;
@ -7,25 +7,24 @@ import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1ObjectIdentifier; import org.xbib.asn1.ASN1ObjectIdentifier;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.Diagnostics; import org.xbib.z3950.common.ErrorRecord;
import org.xbib.io.iso23950.ErrorRecord; import org.xbib.z3950.common.DefaultRecord;
import org.xbib.io.iso23950.Record; import org.xbib.z3950.common.exceptions.MessageSizeTooSmallException;
import org.xbib.io.iso23950.RecordListener; import org.xbib.z3950.common.exceptions.NoRecordsReturnedException;
import org.xbib.io.iso23950.SearchListener; import org.xbib.z3950.common.exceptions.RequestTerminatedByAccessControlException;
import org.xbib.io.iso23950.exceptions.MessageSizeTooSmallException; import org.xbib.z3950.common.exceptions.RequestTerminatedException;
import org.xbib.io.iso23950.exceptions.NoRecordsReturnedException; import org.xbib.z3950.common.exceptions.ZException;
import org.xbib.io.iso23950.exceptions.RequestTerminatedByAccessControlException; import org.xbib.z3950.common.v3.DefaultDiagFormat;
import org.xbib.io.iso23950.exceptions.RequestTerminatedException; import org.xbib.z3950.common.v3.ElementSetNames;
import org.xbib.io.iso23950.exceptions.ZException; import org.xbib.z3950.common.v3.InternationalString;
import org.xbib.io.iso23950.v3.DefaultDiagFormat; import org.xbib.z3950.common.v3.NamePlusRecord;
import org.xbib.io.iso23950.v3.ElementSetNames; import org.xbib.z3950.common.v3.PresentRequest;
import org.xbib.io.iso23950.v3.InternationalString; import org.xbib.z3950.common.v3.PresentRequestRecordComposition;
import org.xbib.io.iso23950.v3.NamePlusRecord; import org.xbib.z3950.common.v3.PresentResponse;
import org.xbib.io.iso23950.v3.PresentRequest; import org.xbib.z3950.common.v3.PresentStatus;
import org.xbib.io.iso23950.v3.PresentRequestRecordComposition; import org.xbib.z3950.common.v3.ResultSetId;
import org.xbib.io.iso23950.v3.PresentResponse; import org.xbib.z3950.api.RecordListener;
import org.xbib.io.iso23950.v3.PresentStatus; import org.xbib.z3950.api.SearchListener;
import org.xbib.io.iso23950.v3.ResultSetId;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -82,7 +81,7 @@ public class PresentOperation extends AbstractOperation<PresentResponse, Present
try { try {
if (nr.record.retrievalRecord != null) { if (nr.record.retrievalRecord != null) {
ASN1External asn1External = new ASN1External(nr.record.retrievalRecord.berEncode(), true); ASN1External asn1External = new ASN1External(nr.record.retrievalRecord.berEncode(), true);
Record record = new Record(offset + n, asn1External.getcOctetAligned().getBytes()); DefaultRecord record = new DefaultRecord(offset + n, asn1External.getcOctetAligned().getBytes());
if (recordListener != null) { if (recordListener != null) {
recordListener.onRecord(record); recordListener.onRecord(record);
} }

View file

@ -1,27 +1,31 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1GeneralString; import org.xbib.asn1.ASN1GeneralString;
import org.xbib.asn1.ASN1Integer; import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1ObjectIdentifier; import org.xbib.asn1.ASN1ObjectIdentifier;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.io.iso23950.ScanListener; import org.xbib.z3950.common.pqf.PQFParser;
import org.xbib.io.iso23950.pqf.PQFParser; import org.xbib.z3950.common.pqf.PQFRPNGenerator;
import org.xbib.io.iso23950.pqf.PQFRPNGenerator; import org.xbib.z3950.common.v3.AttributeSetId;
import org.xbib.io.iso23950.v3.AttributeSetId; import org.xbib.z3950.common.v3.AttributesPlusTerm;
import org.xbib.io.iso23950.v3.AttributesPlusTerm; import org.xbib.z3950.common.v3.DatabaseName;
import org.xbib.io.iso23950.v3.DatabaseName; import org.xbib.z3950.common.v3.InternationalString;
import org.xbib.io.iso23950.v3.InternationalString; import org.xbib.z3950.common.v3.RPNQuery;
import org.xbib.io.iso23950.v3.RPNQuery; import org.xbib.z3950.common.v3.ScanRequest;
import org.xbib.io.iso23950.v3.ScanRequest; import org.xbib.z3950.common.v3.ScanResponse;
import org.xbib.io.iso23950.v3.ScanResponse; import org.xbib.z3950.api.ScanListener;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ScanOperation extends AbstractOperation<ScanResponse, ScanRequest> { public class ScanOperation extends AbstractOperation<ScanResponse, ScanRequest> {
private static final Logger logger = Logger.getLogger(ScanOperation.class.getName());
private final List<String> databases; private final List<String> databases;
public ScanOperation(BERReader reader, BERWriter writer, public ScanOperation(BERReader reader, BERWriter writer,
@ -51,6 +55,9 @@ public class ScanOperation extends AbstractOperation<ScanResponse, ScanRequest>
scanRequest.stepSize = new ASN1Integer(step); scanRequest.stepSize = new ASN1Integer(step);
scanRequest.preferredPositionInResponse = new ASN1Integer(position); scanRequest.preferredPositionInResponse = new ASN1Integer(position);
scanRequest.termListAndStartPoint = term; scanRequest.termListAndStartPoint = term;
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, scanRequest.toString());
}
write(scanRequest); write(scanRequest);
ScanResponse scanResponse = read(); ScanResponse scanResponse = read();
if (scanResponse != null) { if (scanResponse != null) {

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.operations; package org.xbib.z3950.common.operations;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Boolean; import org.xbib.asn1.ASN1Boolean;
@ -9,18 +9,18 @@ import org.xbib.asn1.ASN1Sequence;
import org.xbib.asn1.io.BERReader; import org.xbib.asn1.io.BERReader;
import org.xbib.asn1.io.BERWriter; import org.xbib.asn1.io.BERWriter;
import org.xbib.cql.CQLParser; import org.xbib.cql.CQLParser;
import org.xbib.io.iso23950.Diagnostics; import org.xbib.z3950.common.Diagnostics;
import org.xbib.io.iso23950.cql.CQLRPNGenerator; import org.xbib.z3950.common.cql.CQLRPNGenerator;
import org.xbib.io.iso23950.pqf.PQFParser; import org.xbib.z3950.common.pqf.PQFParser;
import org.xbib.io.iso23950.pqf.PQFRPNGenerator; import org.xbib.z3950.common.pqf.PQFRPNGenerator;
import org.xbib.io.iso23950.v3.DatabaseName; import org.xbib.z3950.common.v3.DatabaseName;
import org.xbib.io.iso23950.v3.InternationalString; import org.xbib.z3950.common.v3.InternationalString;
import org.xbib.io.iso23950.v3.OtherInformation1; import org.xbib.z3950.common.v3.OtherInformation1;
import org.xbib.io.iso23950.v3.PresentStatus; import org.xbib.z3950.common.v3.PresentStatus;
import org.xbib.io.iso23950.v3.Query; import org.xbib.z3950.common.v3.Query;
import org.xbib.io.iso23950.v3.RPNQuery; import org.xbib.z3950.common.v3.RPNQuery;
import org.xbib.io.iso23950.v3.SearchRequest; import org.xbib.z3950.common.v3.SearchRequest;
import org.xbib.io.iso23950.v3.SearchResponse; import org.xbib.z3950.common.v3.SearchResponse;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
@ -79,13 +79,16 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
search.replaceIndicator = new ASN1Boolean(true); search.replaceIndicator = new ASN1Boolean(true);
search.resultSetName = new InternationalString(); search.resultSetName = new InternationalString();
search.resultSetName.value = new ASN1GeneralString(resultSetName); search.resultSetName.value = new ASN1GeneralString(resultSetName);
DatabaseName dbs[] = new DatabaseName[databases.size()]; DatabaseName[] dbs = new DatabaseName[databases.size()];
for (int n = 0; n < databases.size(); n++) { for (int n = 0; n < databases.size(); n++) {
dbs[n] = new DatabaseName(); dbs[n] = new DatabaseName();
dbs[n].value = new InternationalString(); dbs[n].value = new InternationalString();
dbs[n].value.value = new ASN1GeneralString(databases.get(n)); dbs[n].value.value = new ASN1GeneralString(databases.get(n));
} }
search.databaseNames = dbs; search.databaseNames = dbs;
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, search.toString());
}
write(search); write(search);
SearchResponse response = read(); SearchResponse response = read();
if (response != null) { if (response != null) {
@ -95,7 +98,6 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
ASN1Boolean b = response.s_searchStatus; ASN1Boolean b = response.s_searchStatus;
status = b != null && b.get(); status = b != null && b.get();
if (!status) { if (!status) {
String message = "no message";
if (response.s_records != null && response.s_records.c_nonSurrogateDiagnostic != null) { if (response.s_records != null && response.s_records.c_nonSurrogateDiagnostic != null) {
int code = response.s_records.c_nonSurrogateDiagnostic.condition.get(); int code = response.s_records.c_nonSurrogateDiagnostic.condition.get();
String addInfo = response.s_records.c_nonSurrogateDiagnostic.addinfo.v2Addinfo.get(); String addInfo = response.s_records.c_nonSurrogateDiagnostic.addinfo.v2Addinfo.get();
@ -119,7 +121,7 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
dbName = new DatabaseName(details[0].berEncode(), false); dbName = new DatabaseName(details[0].berEncode(), false);
if (!dbName.value.value.get().equalsIgnoreCase(databases.get(i))) { if (!dbName.value.value.get().equalsIgnoreCase(databases.get(i))) {
String message = "database name listed in additional search info " + String message = "database name listed in additional search info " +
"doesn't match database name in names set."; "doesn't match database name in names set";
throw new IOException(host + ": " + message); throw new IOException(host + ": " + message);
} }
ASN1Integer res = (ASN1Integer) details[1]; ASN1Integer res = (ASN1Integer) details[1];
@ -133,7 +135,7 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
} }
} }
} catch (IOException e) { } catch (IOException e) {
// set host in IOException message // add host in IOException message
throw new IOException(host + ": " + e.getMessage(), e); throw new IOException(host + ": " + e.getMessage(), e);
} }
return status; return status;

View file

@ -0,0 +1,4 @@
/**
*
*/
package org.xbib.z3950.common.operations;

View file

@ -0,0 +1,4 @@
/**
*
*/
package org.xbib.z3950.common;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* PQF abstract syntax tree. * PQF abstract syntax tree.

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* PQF abstract syntax tree. * PQF abstract syntax tree.

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* PQF abstract syntax tree. * PQF abstract syntax tree.

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* PQF abstract syntax tree. * PQF abstract syntax tree.

View file

@ -1,20 +1,20 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Integer; import org.xbib.asn1.ASN1Integer;
import org.xbib.asn1.ASN1Null; import org.xbib.asn1.ASN1Null;
import org.xbib.asn1.ASN1ObjectIdentifier; import org.xbib.asn1.ASN1ObjectIdentifier;
import org.xbib.asn1.ASN1OctetString; import org.xbib.asn1.ASN1OctetString;
import org.xbib.io.iso23950.v3.AttributeElement; import org.xbib.z3950.common.v3.AttributeElement;
import org.xbib.io.iso23950.v3.AttributeElementAttributeValue; import org.xbib.z3950.common.v3.AttributeElementAttributeValue;
import org.xbib.io.iso23950.v3.AttributeList; import org.xbib.z3950.common.v3.AttributeList;
import org.xbib.io.iso23950.v3.AttributeSetId; import org.xbib.z3950.common.v3.AttributeSetId;
import org.xbib.io.iso23950.v3.AttributesPlusTerm; import org.xbib.z3950.common.v3.AttributesPlusTerm;
import org.xbib.io.iso23950.v3.Operand; import org.xbib.z3950.common.v3.Operand;
import org.xbib.io.iso23950.v3.Operator; import org.xbib.z3950.common.v3.Operator;
import org.xbib.io.iso23950.v3.RPNQuery; import org.xbib.z3950.common.v3.RPNQuery;
import org.xbib.io.iso23950.v3.RPNStructure; import org.xbib.z3950.common.v3.RPNStructure;
import org.xbib.io.iso23950.v3.RPNStructureRpnRpnOp; import org.xbib.z3950.common.v3.RPNStructureRpnRpnOp;
import java.util.Stack; import java.util.Stack;
@ -54,7 +54,7 @@ public class PQFRPNGenerator implements Visitor {
public void visit(Query query) { public void visit(Query query) {
Operand operand = new Operand(); Operand operand = new Operand();
operand.attrTerm = new AttributesPlusTerm(); operand.attrTerm = new AttributesPlusTerm();
operand.attrTerm.term = new org.xbib.io.iso23950.v3.Term(); operand.attrTerm.term = new org.xbib.z3950.common.v3.Term();
operand.attrTerm.term.c_general = new ASN1OctetString(query.getTerm().getValue()); operand.attrTerm.term.c_general = new ASN1OctetString(query.getTerm().getValue());
Stack<AttributeElement> attrs = new Stack<>(); Stack<AttributeElement> attrs = new Stack<>();
ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null; ASN1Any any = !result.isEmpty() && result.peek() instanceof AttributeElement ? result.pop() : null;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* Syntax exception. * Syntax exception.

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* *

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.pqf; package org.xbib.z3950.common.pqf;
/** /**
* PQF abstract syntax tree visitor. * PQF abstract syntax tree visitor.

View file

@ -0,0 +1,4 @@
/**
*
*/
package org.xbib.z3950.common.pqf;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1Exception; import org.xbib.asn1.ASN1Exception;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

View file

@ -1,4 +1,4 @@
package org.xbib.io.iso23950.v3; package org.xbib.z3950.common.v3;
import org.xbib.asn1.ASN1Any; import org.xbib.asn1.ASN1Any;
import org.xbib.asn1.ASN1EncodingException; import org.xbib.asn1.ASN1EncodingException;

Some files were not shown because too many files have changed in this diff Show more