From 7dee39ba8291a6c98c62034dcaeea889212859ca Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <andreas.romeyke@slub-dresden.de> Date: Thu, 22 Nov 2018 10:47:04 +0100 Subject: [PATCH] - reenabled logger output - updated SDK version --- Makefile | 4 +- .../metadata_SLUBVirusCheckClamAVPlugin.xml | 2 +- .../plugin/SLUBVirusCheckClamAVPlugin.java | 41 +++++++++++-------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 597955c..8bcf475 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ # von ExLibris an Rosetta übergibt. # Pfad zu Java 7 -JAVAPATH=$(wildcard /usr/lib/jvm/java-1.7.0-openjdk-*/bin/) +JAVAPATH=$(wildcard /usr/lib/jvm/java-8-openjdk-*/bin/) # Verwendete Rosetta-Version -ROSETTAVERSION=4.1.0 +ROSETTAVERSION=5.5.0 # Pfad zum Rosetta-SDK ROSETTASDK=/exlibris/dps/d4_1/system.dir/dps-sdk-${ROSETTAVERSION}/lib/ diff --git a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml index 4c542f1..e765e81 100644 --- a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml +++ b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml @@ -49,7 +49,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Virus Check Plugin using installed ClamAV daemon via tcp-sockets</pl:description> - <pl:version>1.4</pl:version> + <pl:version>1.5</pl:version> <pl:materialType>DIGITAL</pl:materialType> <pl:module>Repository</pl:module> <pl:generalType>TASK</pl:generalType> diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java index 1d50496..a133abc 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java @@ -23,6 +23,7 @@ limitations under the License. package org.slub.rosetta.dps.repository.plugin; +import com.exlibris.core.infra.common.exceptions.logging.ExLogger; import com.exlibris.dps.repository.plugin.virusChcek.VirusCheckPlugin; import java.io.DataOutputStream; @@ -35,7 +36,6 @@ import java.net.SocketException; import java.util.HashMap; import java.util.Map; - /** * SLUBVirusCheckClamAVPlugin * <p/> @@ -57,6 +57,8 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { private static final String RESPONSEOK = "stream: OK"; private static final String FOUND_SUFFIX = "FOUND"; private static final String STREAM_PREFIX = "stream: "; + + private static final ExLogger log = ExLogger.getExLogger(SLUBVirusCheckClamAVPlugin.class); private int timeout; private String host; private int port; @@ -76,8 +78,8 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { this.host = initp.get("host"); this.port = Integer.parseInt(initp.get("port")); this.timeout = Integer.parseInt(initp.get("timeout")); - //log.info("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); - System.out.println("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); + log.info("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); + //System.out.println("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); } /** stand alone check, main file to call local installed clamd * @param args list of files which should be scanned @@ -181,8 +183,8 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { try { socket.setSoTimeout(getTimeOut()); } catch (SocketException e) { - System.out.println("Could not set socket timeout to " + getTimeOut() + "ms " + e); - //log.error( "Could not set socket timeout to " + getTimeOut() + "ms", e); + //System.out.println("Could not set socket timeout to " + getTimeOut() + "ms " + e); + log.error( "Could not set socket timeout to " + getTimeOut() + "ms", e); } return socket; } @@ -196,14 +198,14 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { if (dos != null) try { dos.close(); } catch (IOException e) { - // log.debug("exception closing DOS", e); - System.out.println("exception closing DOS " + e); + log.error("exception closing DOS", e); + //System.out.println("exception closing DOS " + e); } try { socket.close(); } catch (IOException e) { - // log.debug("exception closing socket", e); - System.out.println("exception closing socket " + e); + log.error("exception closing socket", e); + //System.out.println("exception closing socket " + e); } } @@ -266,23 +268,26 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { byte[] command = INSTREAM; callSocketCommandStream(socket, command, in); in.close(); - //log.debug( "Response: " + response); - System.out.println("Response: " + response.trim()); - // parse return code String result = response.trim(); + log.debug( "Response: " + result); + //System.out.println("Response: " + result); + // parse return code + if (RESPONSEOK.equals(result)) { setStatus(Status.PASSED); + log.info("scan of file '" + fileFullPath + "' passed"); } else if (result.endsWith(FOUND_SUFFIX)) { setStatus(Status.FAILED); setSignature(result.substring(STREAM_PREFIX.length(), result.lastIndexOf(FOUND_SUFFIX) - 1)); + log.info("scan of file '" + fileFullPath + "' failed"); } else { setStatus(Status.FAILED); - //log.warn("clamd protocol not fully implemented"); - System.out.println("clamd protocol not fully implemented"); + log.warn("clamd protocol not fully implemented, result='" + result + "'"); + //System.out.println("clamd protocol not fully implemented"); } } catch (IOException e) { - //log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e); - System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e); + log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e); + //System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e); setStatus(Status.FAILED); setSignature("ERROR: clamd not available"); } @@ -309,8 +314,8 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin { callSocketCommand(socket, command); return response.trim(); } catch (IOException e) { - //log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e); - System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e); + log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e); + //System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e); setStatus(Status.FAILED); setSignature("ERROR: clamd not available"); return "ERROR: clamd not available"; -- GitLab