Skip to content

Commit

Permalink
Merge pull request 'Bump goobi workflow dependency to 23.04.1' (#4) f…
Browse files Browse the repository at this point in the history
…rom update_goobi_dep_to_23.04.1 into master

Reviewed-on: https://gitea.intranda.com/goobi-workflow/goobi-plugin-opac-sru/pulls/4
  • Loading branch information
rsehr committed May 8, 2023
2 parents 149663c + 83d83d0 commit 4520a13
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 49 deletions.
14 changes: 14 additions & 0 deletions plugin/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
4 changes: 2 additions & 2 deletions plugin/module-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>sru-opac-main</artifactId>
<version>1.2.2</version>
<version>23.04.1</version>
<properties>
<jar.name>plugin_intranda_opac_sru</jar.name>
<dest.folder>/opt/digiverso/goobi/plugins/opac/</dest.folder>
Expand All @@ -12,7 +12,7 @@
<parent>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>sru-opac</artifactId>
<version>1.2.2</version>
<version>23.04.1</version>
</parent>
<repositories>
<repository>
Expand Down
4 changes: 2 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>sru-opac</artifactId>
<version>1.2.2</version>
<version>23.04.1</version>
<packaging>pom</packaging>
<name>sru-opac</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<goobi.version>23.03.2</goobi.version>
<goobi.version>23.04.1</goobi.version>
</properties>
<modules>
<module>module-main</module>
Expand Down
97 changes: 52 additions & 45 deletions plugin/src/de/intranda/goobi/plugins/utils/SRUClient.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* This file is part of the SRU opac import plugin for the Goobi Application - a Workflow tool for the support of mass digitization.
*
* Visit the websites for more information.
* - http://digiverso.com
* Visit the websites for more information.
* - http://digiverso.com
* - http://www.intranda.com
*
* Copyright 2013, intranda GmbH, Göttingen
Expand All @@ -29,7 +29,6 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand All @@ -41,15 +40,15 @@

import de.intranda.goobi.plugins.SruOpacImport;
import de.intranda.utils.DocumentUtils;
import de.sub.goobi.helper.HttpClientHelper;
import de.unigoettingen.sub.search.opac.ConfigOpacCatalogue;
import io.goobi.workflow.api.connection.HttpUtils;

public class SRUClient {

private static final Logger logger = Logger.getLogger(SruOpacImport.class);
private static final String ENCODING = "UTF-8";
private String sruVersion = "1.1";

private String sruVersion = "1.1";

/**
* Queries the given catalog via Z.3950 (SRU) and returns its response.
Expand Down Expand Up @@ -79,8 +78,8 @@ public String querySRU(ConfigOpacCatalogue cat, String query, String recordSchem
url += "&recordSchema=" + recordSchema;

logger.debug("SRU URL: " + url);
ret = HttpClientHelper.getStringFromUrl(url);
// ret = StringEscapeUtils.unescapeHtml(ret);
ret = HttpUtils.getStringFromUrl(url);
// ret = StringEscapeUtils.unescapeHtml(ret);
return ret;
}

Expand Down Expand Up @@ -113,7 +112,7 @@ public static String encodeAsString(byte[] bytes, Charset charset) {

return new String(bytes);
}

/**
* Converts a <code>String</code> from one given encoding to the other.
*
Expand Down Expand Up @@ -141,49 +140,57 @@ public static String convertStringEncoding(String string, String from, String to
public static Document retrieveMarcRecord(String input) throws JDOMException, IOException, SRUException {
Document wholeDoc = DocumentUtils.getDocumentFromString(input, null);
try {
Element record = wholeDoc.getRootElement().getChild("records", null).getChild("record", null).getChild("recordData", null).getChild(
"record", null);
Document outDoc = new Document((Element) record.detach());
Element record = wholeDoc.getRootElement()
.getChild("records", null)
.getChild("record", null)
.getChild("recordData", null)
.getChild(
"record", null);
Document outDoc = new Document(record.detach());
return outDoc;
} catch (NullPointerException e) {
Element diagnosticsEle = wholeDoc.getRootElement().getChild("diagnostics", null);
if(diagnosticsEle != null && diagnosticsEle.getChild("diagnostic", null) != null) {
throw new SRUException(diagnosticsEle.getChild("diagnostic", null).getChildText("message", null));
}
Element recordsFoundEle = wholeDoc.getRootElement().getChild("numberOfRecords", null);
if(recordsFoundEle != null) {
String recordsFoundText = recordsFoundEle.getTextTrim();
if(StringUtils.isNotBlank(recordsFoundText) && StringUtils.isNumeric(recordsFoundText) && Integer.parseInt(recordsFoundText) == 0) {
throw new SRUException("No records found");
}
}
Element diagnosticsEle = wholeDoc.getRootElement().getChild("diagnostics", null);
if (diagnosticsEle != null && diagnosticsEle.getChild("diagnostic", null) != null) {
throw new SRUException(diagnosticsEle.getChild("diagnostic", null).getChildText("message", null));
}
Element recordsFoundEle = wholeDoc.getRootElement().getChild("numberOfRecords", null);
if (recordsFoundEle != null) {
String recordsFoundText = recordsFoundEle.getTextTrim();
if (StringUtils.isNotBlank(recordsFoundText) && StringUtils.isNumeric(recordsFoundText) && Integer.parseInt(recordsFoundText) == 0) {
throw new SRUException("No records found");
}
}
throw new SRUException("No parsable response from SRU server");
}
}

public String getSruVersion() {
return sruVersion;
}
return sruVersion;
}

public void setSruVersion(String sruVersion) {
this.sruVersion = sruVersion;
}
this.sruVersion = sruVersion;
}

public static class SRUException extends Exception {
public SRUException() {
super();
}
public SRUException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
super(arg0, arg1, arg2, arg3);
}
public SRUException(String arg0, Throwable arg1) {
super(arg0, arg1);
}
public SRUException(String arg0) {
super(arg0);
}
public SRUException(Throwable arg0) {
super(arg0);
}
public SRUException() {
super();
}

public SRUException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
super(arg0, arg1, arg2, arg3);
}

public SRUException(String arg0, Throwable arg1) {
super(arg0, arg1);
}

public SRUException(String arg0) {
super(arg0);
}

public SRUException(Throwable arg0) {
super(arg0);
}
}
}

0 comments on commit 4520a13

Please sign in to comment.