diff --git a/dspace-api/src/main/java/org/dspace/health/PIDCheck.java b/dspace-api/src/main/java/org/dspace/health/PIDCheck.java deleted file mode 100644 index 07fd3b4533b..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/PIDCheck.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health; - -import org.apache.commons.lang.NotImplementedException; -import org.dspace.handle.PIDService; -import org.dspace.health.additionalUtilities.PIDLogMiner; -import org.dspace.health.additionalUtilities.PIDLogStatistics; -import org.dspace.health.additionalUtilities.PIDLogStatisticsEntry; -import org.dspace.services.ConfigurationService; -import org.dspace.services.factory.DSpaceServicesFactory; - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.List; -import java.util.Map; - -public class PIDCheck extends Check { - protected static final ConfigurationService configurationService - = DSpaceServicesFactory.getInstance().getConfigurationService(); - - @Override - protected String run(ReportInfo ri) { - String output = ""; - output += "This is space for PID Check output"; - try { - String whoami = PIDService.who_am_i("encoding=xml"); - output += String.format("Who am I\n\t%s\n", - whoami.replaceAll("\n", "\n\t")); - String test_pid = configurationService.getProperty("lr.pid.service.testPid"); - output += "Testing PID server\n\t"; - if (test_pid != null) { - output += PIDService.test_pid(test_pid); - } else { - output += "Testing PID server not done! Test pid not in dspace.cfg!"; - } - } catch (IllegalArgumentException e) { - error(e, "Warning: PID service type is not defined or wrong"); - } catch (NotImplementedException e) { - error(e, "Testing PID server - method who_am_i not implemented"); - } catch (Exception e) { - error(e, "Testing PID server failed - exception occurred: %s"); - } - -// try { -// long total_count = Core.getHandlesTotalCount(); -// output += "\n"; -// output += String.format("Total count: %d\n", total_count); -// List invalid_handles = Core.getHandlesInvalidRows(); -// output += String.format("Invalid handles count: %d\n", -// invalid_handles.size()); -// if (invalid_handles.size() > 0) { -// output += "\n"; -// output += "Invalid handles:\n"; -// output += "----------------\n"; -// output += String.format("%-6s\t%-32s\t%-10s\t%-10s\t%s\n", -// "Handle ID", "Handle", "Res. type ID", "Resource ID", -// "URL"); -// for (TableRow row : invalid_handles) { -// int handle_id = row.getIntColumn("handle_id"); -// String handle = row.getStringColumn("handle"); -// -// Integer resource_type_id = row.getIntColumn("resource_type_id"); -// if (resource_type_id < 0) -// resource_type_id = null; -// -// Integer resource_id = row.getIntColumn("resource_id"); -// if (resource_id < 0) -// resource_id = null; -// -// String url = row.getStringColumn("url"); -// output += String.format("%-10d\t%-32s\t%-10d\t%-10d\t%s\n", -// handle_id, handle, resource_type_id, resource_id, -// url); -// } -// } -// } catch (SQLException e) { -// error(e); -// } - - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Calendar realEndDate = Calendar.getInstance(); - realEndDate.setTime(ri.till()); - realEndDate.add(Calendar.DATE, -1); - - final int topN = 10; - StringBuffer buf = new StringBuffer(); - buf.append("============================================================\n"); - buf.append(String.format("PID resolution statistics\n")); - buf.append("============================================================\n"); - buf.append("\n\n"); - PIDLogMiner logMiner = new PIDLogMiner(); - PIDLogStatistics statistics = logMiner.computeStatistics( - ri.from(), realEndDate.getTime()); - Map> topNEntries = statistics - .getTopN(topN); - String eventsToDisplay[] = { PIDLogMiner.FAILURE_EVENT, - PIDLogMiner.REQUEST_EVENT, PIDLogMiner.SUCCESS_EVENT, - PIDLogMiner.UNKNOWN_EVENT }; - SimpleDateFormat dateTimeFormat = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss.SSS"); - for (String event : eventsToDisplay) { - if (topNEntries.containsKey(event)) { - buf.append(String.format( - "Top %d events of type %s between %s and %s\n", topN, - event, dateFormat.format(ri.from()), - dateFormat.format(realEndDate.getTime()))); - buf.append(String - .format("---------------------------------------------------------------\n")); - buf.append(String.format("%-10s%-40s%-25s%-25s\n", "Count", - "PID", "First occurence", "Last occurence")); - buf.append(String - .format("--------------------------------------------------------------------------------------------------\n")); - for (PIDLogStatisticsEntry entry : topNEntries.get(event)) { - buf.append(String.format("%-10d%-40s%-25s%-25s\n", - entry.getCount(), entry.getPID(), - dateTimeFormat.format(entry.getFirstOccurence()), - dateTimeFormat.format(entry.getLastOccurence()))); - } - buf.append("\n"); - } - } - return output + buf.toString(); - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java b/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java index a20e278c329..d4f2010af8d 100644 --- a/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java +++ b/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java @@ -9,16 +9,16 @@ import org.dspace.services.ConfigurationService; import org.dspace.services.factory.DSpaceServicesFactory; -//import java.io.BufferedReader; -//import java.io.File; -//import java.io.InputStreamReader; -//import java.io.StringWriter; -//import java.net.URL; -//import java.text.SimpleDateFormat; -//import java.util.Date; -//import java.util.HashSet; -//import java.util.Iterator; -//import java.util.Set; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; public class ShibbolethCheck extends Check { diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogMiner.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogMiner.java deleted file mode 100644 index 44753239da0..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogMiner.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.dspace.services.ConfigurationService; -import org.dspace.services.factory.DSpaceServicesFactory; - -public class PIDLogMiner { - protected static final ConfigurationService configurationService - = DSpaceServicesFactory.getInstance().getConfigurationService(); - - private static org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(PIDLogMiner.class); - - private static final Pattern REQUEST_PATTERN = Pattern - .compile("Resolving \\[(.*)\\]"); - - private static final Pattern FAILURE_PATTERN = Pattern - .compile("Unable to resolve \\[(.*)\\]"); - - private static final Pattern SUCCESS_PATTERN = Pattern - .compile("Handle \\[(.*)\\] resolved to \\[(.*)\\]"); - - public static final String REQUEST_EVENT = "REQUEST"; - public static final String SUCCESS_EVENT = "SUCCESS"; - public static final String FAILURE_EVENT = "FAILURE"; - public static final String UNKNOWN_EVENT = "UNKNOWN"; - - private String logDir; - - public PIDLogMiner() - { - this.logDir = getConfigLogDir(); - } - - public PIDLogMiner(String logDir) - { - this.logDir = logDir; - } - - private List getDatesInInterval(Date startDate, Date endDate) - { - List dates = new ArrayList(); - Calendar calendar = new GregorianCalendar(); - calendar.setTime(startDate); - - while (calendar.getTime().before(endDate) || calendar.getTime().equals(endDate)) - { - dates.add(calendar.getTime()); - calendar.add(Calendar.DATE, 1); - } - return dates; - } - - /** - * Function for computing log statistics - * - * Note: The current log is not processed, only from yesterday backwards. - * - * @param startDate the first day of the statistics - * @param endDate the last day of the statistics - * @return - */ - - public PIDLogStatistics computeStatistics(Date startDate, Date endDate) - { - PIDLogStatistics statistics = new PIDLogStatistics(); - List dates = getDatesInInterval(startDate, endDate); - - for (Date date : dates) - { - String formattedDate = new SimpleDateFormat("yyyy-MM-dd") - .format(date); - String logFilename = String.format("handle-plugin.log.%s", - formattedDate); - log.info(String.format("Logfile [%s] processing started", - logFilename)); - - SimpleLogFile logFile = new SimpleLogFile(logDir, logFilename); - - for (SimpleLogEntry logEntry : logFile) - { - updateStatistics(statistics, logEntry); - } - - log.info(String.format("Logfile [%s] processing finished", - logFilename)); - - } - return statistics; - - } - - private void updateStatistics(PIDLogStatistics statistics, - SimpleLogEntry logEntry) - { - String message = logEntry.getMessage(); - Date eventDate = logEntry.getDate(); - Matcher matcher; - String pid; - String event; - - matcher = REQUEST_PATTERN.matcher(message); - if (matcher.find()) - { - event = REQUEST_EVENT; - pid = matcher.group(1); - statistics.updateStatistics(event, pid, eventDate); - return; - } - - matcher = SUCCESS_PATTERN.matcher(message); - if (matcher.find()) - { - event = SUCCESS_EVENT; - pid = matcher.group(1); - statistics.updateStatistics(event, pid, eventDate); - return; - } - - matcher = FAILURE_PATTERN.matcher(message); - if (matcher.find()) - { - event = FAILURE_EVENT; - pid = matcher.group(1); - statistics.updateStatistics(event, pid, eventDate); - return; - } - - event = UNKNOWN_EVENT; - pid = ""; - statistics.updateStatistics(event, pid, eventDate); - return; - - } - - private String getConfigLogDir() - { - return configurationService.getProperty("log.dir"); - } - -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatistics.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatistics.java deleted file mode 100644 index d0de591346b..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatistics.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class PIDLogStatistics { - private HashMap> entries = null; - - PIDLogStatistics() - { - entries = new HashMap>(); - } - - public void updateStatistics(String event, String pid, Date eventDate) - { - if (!entries.containsKey(event)) - { - entries.put(event, new HashMap()); - } - HashMap subentries = entries.get(event); - - if (!subentries.containsKey(pid)) - { - subentries.put(pid, new PIDLogStatisticsEntry(event, pid, 0, - eventDate, eventDate)); - } - PIDLogStatisticsEntry entry = subentries.get(pid); - entry.update(eventDate); - } - - public List getEntriesList() - { - List entriesList = new ArrayList(); - for (Map subentries : entries - .values()) - { - for (PIDLogStatisticsEntry entry : subentries.values()) - { - entriesList.add(entry); - } - } - return entriesList; - } - - public Map> getTopN(int topN) - { - Map> topEntriesMap = new HashMap>(); - for (String event: entries.keySet()) - { - List subentries = new ArrayList(entries.get(event).values()); - Collections.sort( subentries, new Comparator(){ - public int compare( PIDLogStatisticsEntry a, PIDLogStatisticsEntry b ){ - if(a.getCount() != b.getCount()) { - return b.getCount() - a.getCount(); - } - else { - return a.getPID().compareTo(b.getPID()); - } - } - }); - topEntriesMap.put(event, subentries.subList(0, topN > subentries.size() ? subentries.size() : topN)); - - } - return topEntriesMap; - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatisticsEntry.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatisticsEntry.java deleted file mode 100644 index 13ee9e726aa..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/PIDLogStatisticsEntry.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.util.Date; - -public class PIDLogStatisticsEntry { - private String event; - - private String pid; - - private int count; - - private Date firstOccurence; - - private Date lastOccurence; - - PIDLogStatisticsEntry(String event, String pid, int count, - Date firstOccurence, Date lastOccurence) - { - this.event = event; - this.pid = pid; - this.count = count; - this.firstOccurence = firstOccurence; - this.lastOccurence = lastOccurence; - } - - public void update(Date eventDate) - { - this.count++; - - if (eventDate.before(firstOccurence)) - { - firstOccurence = eventDate; - } - - if (eventDate.after(lastOccurence)) - { - lastOccurence = eventDate; - } - } - - public String getEvent() - { - return event; - } - - public String getPID() - { - return pid; - } - - public int getCount() - { - return count; - } - - public Date getFirstOccurence() - { - return firstOccurence; - } - - public Date getLastOccurence() - { - return lastOccurence; - } - - public String toString() { - return String.format("" - + "Event: %s\n" - + "PID: %s\n" - + "Count: %d\n" - + "First occurence: %s\n" - + "Last occurence: %s\n", - event, pid, count, firstOccurence.toString(), lastOccurence.toString() - ); - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/Record.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/Record.java deleted file mode 100644 index efc07e09630..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/Record.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -public interface Record { - public void setLineNumber(int lineNumber); - - public int getLineNumber(); - - public void setValid(boolean valid); - - public boolean isValid(); - -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordFileLineIterator.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordFileLineIterator.java deleted file mode 100644 index 1a2ce0ab8eb..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordFileLineIterator.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.Iterator; -import java.util.NoSuchElementException; - -public class RecordFileLineIterator implements Iterator { - private BufferedReader reader; - - private RecordParser recordParser; - - private int cachedLineNumber; - - private String cachedLine; - - private boolean finished; - - public RecordFileLineIterator(InputStreamReader inputReader, RecordParser recordParser) - { - this.recordParser = recordParser; - this.reader = inputReader == null ? null : new BufferedReader(inputReader); - this.cachedLine = null; - this.cachedLineNumber = 0; - this.finished = false; - nextRecord(); - } - - private String nextRecord() - { - if (reader == null || finished) - { - finished = true; - return null; - } - StringBuffer buf = new StringBuffer(); - buf.append(cachedLine); - try - { - while (true) - { - cachedLine = reader.readLine(); - cachedLineNumber++; - if (cachedLine == null) - { - close(); - break; - } - if (recordParser.matches(cachedLine)) - { - break; - } - buf.append("\n"); - buf.append(cachedLine); - } - } - catch (IOException ioe) - { - close(); - throw new IllegalStateException(ioe.toString()); - } - return buf.toString(); - } - - @Override - public boolean hasNext() - { - return !finished; - } - - @Override - public T next() - { - T res = null; - String s; - - int lineNumber = cachedLineNumber; - s = nextRecord(); - if (!s.isEmpty()) - { - res = recordParser.parse(s); - res.setLineNumber(lineNumber); - } - - if (res == null) - { - throw new NoSuchElementException(); - } - return res; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException( - "Remove unsupported on RecordFileLineIterator"); - } - - public void close() - { - finished = true; - try - { - reader.close(); - } - catch (IOException ioe) - { - throw new IllegalStateException(ioe.toString()); - } - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordParser.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordParser.java deleted file mode 100644 index 43e29a7e616..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/RecordParser.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -public interface RecordParser { - public T parse(String s); - - public boolean matches(String s); -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntry.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntry.java deleted file mode 100644 index 15e012b664b..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntry.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.util.Date; - -public class SimpleLogEntry implements Record { - private String filename; - - private int lineNumber; - - private Date date; - - private String level; - - private String loggingClass; - - private String message; - - private boolean valid; - - public static final String ERROR_LEVEL = "ERROR"; - - public static final String WARNING_LEVEL = "WARN"; - - public static final String INFO_LEVEL = "INFO"; - - public static final String DEBUG_LEVEL = "DEBUG"; - - public static final String FATAL_LEVEL = "FATAL"; - - public static final String CRITICAL_LEVEL = "CRIT"; - - public SimpleLogEntry() - { - this.lineNumber = 0; - this.date = null; - this.level = null; - this.loggingClass = null; - this.message = null; - } - - public SimpleLogEntry(Date date, String level, String loggingClass, - String message) - { - this.lineNumber = 0; - this.date = date; - this.level = level; - this.loggingClass = loggingClass; - this.message = message; - } - - public String getFilename() - { - return filename; - } - - public int getLineNumber() - { - return lineNumber; - } - - public Date getDate() - { - return date; - } - - public void setDate(Date date) - { - this.date = date; - } - - public void setLevel(String level) - { - this.level = level; - } - - public void setLoggingClass(String loggingClass) - { - this.loggingClass = loggingClass; - } - - public void setMessage(String message) - { - this.message = message; - } - - public String getLevel() - { - return level; - } - - public String getLoggingClass() - { - return loggingClass; - } - - public String getMessage() - { - return message; - } - - public void setLineNumber(int lineNumber) - { - this.lineNumber = lineNumber; - } - - public void setFilename(String filename) - { - this.filename = filename; - } - - public boolean isValid() - { - return valid; - } - - public void setValid(boolean valid) - { - this.valid = valid; - } - - public boolean isError() - { - return ERROR_LEVEL.equals(level); - } - - public boolean isWarning() - { - return WARNING_LEVEL.equals(level); - } - - public boolean isInfo() - { - return INFO_LEVEL.equals(level); - } - - public boolean isDebug() - { - return DEBUG_LEVEL.equals(level); - } - - public boolean isFatal() - { - return FATAL_LEVEL.equals(level); - } - - public boolean isCritical() - { - return CRITICAL_LEVEL.equals(level); - } - - public String toString() - { - return String.format("" + "Date: %s\n" + "Level: %s\n" - + "Logging class: %s\n" + "Message: %s\n", date.toString(), - level, loggingClass, message); - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntryParser.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntryParser.java deleted file mode 100644 index f9ec7ed51fb..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogEntryParser.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class SimpleLogEntryParser implements RecordParser { - private final static String LOG_ENTRY_PATTERN = "^(\\d{4}-\\d{2}-\\d{2} +\\d{2}:\\d{2}:\\d{2},\\d{3}) +([^ ]+) +([^ ]+) +@ +(.*)$"; - - private final static Pattern pattern = Pattern.compile(LOG_ENTRY_PATTERN, Pattern.DOTALL); - - public SimpleLogEntry parse(String s) - { - - SimpleLogEntry entry = new SimpleLogEntry(); - Matcher matcher = pattern.matcher(s); - if (matcher.find()) - { - String dateString = matcher.group(1); - entry.setValid(true); - entry.setLevel(matcher.group(2)); - entry.setLoggingClass(matcher.group(3)); - entry.setMessage(matcher.group(4)); - - try - { - Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS") - .parse(dateString); - entry.setDate(date); - } - catch (ParseException e) - { - entry.setValid(false); - } - } - else - { - entry.setValid(false); - } - return entry; - } - - public boolean matches(String s) - { - - return pattern.matcher(s).matches(); - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogFile.java b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogFile.java deleted file mode 100644 index c4565b4fae9..00000000000 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/SimpleLogFile.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.health.additionalUtilities; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; - -public class SimpleLogFile implements Iterable { - private static org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(SimpleLogFile.class); - - private InputStreamReader inputReader; - - public SimpleLogFile(String dirname, String filename) - { - this(new File(dirname, filename)); - } - - public SimpleLogFile(String filePath) - { - this(new File(filePath)); - } - - public SimpleLogFile(File file) - { - if (file == null) { - throw new IllegalArgumentException("File cannot be null"); - } - else if (!file.exists()) - { - log.warn(String.format("Logfile [%s] not found at [%s]", - file.getName(), file.getPath())); - } - else if (file.exists() && file.length() == 0) - { - log.warn(String.format("Logfile [%s] at [%s] is empty", - file.getName(), file.getPath())); - } - else - { - try - { - this.inputReader = new InputStreamReader(new FileInputStream( - file), Charset.forName("UTF8")); - } - catch (FileNotFoundException e) - { - log.error(e.toString()); - } - } - - } - - public RecordFileLineIterator iterator() - { - return new RecordFileLineIterator(inputReader, - new SimpleLogEntryParser()); - } -} diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/__pycache__/validator.cpython-311.pyc b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/__pycache__/validator.cpython-311.pyc index 7cf141f65c8..eb8fe54fbd1 100644 Binary files a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/__pycache__/validator.cpython-311.pyc and b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/__pycache__/validator.cpython-311.pyc differ diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/validator.py b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/validator.py index dfbbe2f1eda..7a823287e28 100644 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/validator.py +++ b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/oval/validator.py @@ -163,6 +163,7 @@ def __init__(self, base_url, timeout=10): self.results['HTTPMethod'] = ('warning', message) self.method = 'GET' + # Protocol Version self.protocol_version = get_protocol_version( self.base_url, self.method) if self.protocol_version is None: @@ -227,6 +228,7 @@ def check_identify_base_url(self): except Exception as exc: message = "Could not compare basic URLs: %s" % str(exc) self.results['BaseURLMatch'] = ('unverified', message) + print('Self.base_url - ' + self.base_url) return if urlparse(response.url).netloc != urlparse(self.base_url).netloc: message = "Requests seem to be redirected to: %s" % response.url diff --git a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/validate.py b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/validate.py index e35336413a3..9c4cb2ef159 100644 --- a/dspace-api/src/main/java/org/dspace/health/additionalUtilities/validate.py +++ b/dspace-api/src/main/java/org/dspace/health/additionalUtilities/validate.py @@ -14,4 +14,4 @@ print("\nFirst argument is " + sys.argv[0]) print("\nSecond argument is " + sys.argv[1]) -validator.main() +validator.main({"base_url":"http://localhost:8080/server/oai/"}) diff --git a/dspace/config/clarin-dspace.cfg b/dspace/config/clarin-dspace.cfg index df3d81271ae..f27d6830c21 100644 --- a/dspace/config/clarin-dspace.cfg +++ b/dspace/config/clarin-dspace.cfg @@ -301,5 +301,3 @@ autocomplete.custom.separator.solr-dataProvider_ac = \\|\\|\\| autocomplete.custom.separator.solr-dctype_ac = \\|\\|\\| autocomplete.custom.separator.solr-author_ac = \\|\\|\\| autocomplete.custom.allowed = solr-author_ac,solr-publisher_ac,solr-dataProvider_ac,solr-dctype_ac,solr-subject_ac,solr-handle_title_ac,json_static-iso_langs.json - -testing-config = TESTINGCONFIG \ No newline at end of file diff --git a/dspace/config/modules/healthcheck.cfg b/dspace/config/modules/healthcheck.cfg index 6b24c941727..8bb3d38179e 100644 --- a/dspace/config/modules/healthcheck.cfg +++ b/dspace/config/modules/healthcheck.cfg @@ -11,7 +11,6 @@ healthcheck.checks = General Information,\ Log Analyser Check,\ Additional Information,\ OAI-PMH validation,\ - PID Check,\ Shibboleth Check plugin.named.org.dspace.health.Check = \ @@ -23,7 +22,6 @@ plugin.named.org.dspace.health.Check = \ org.dspace.health.LogAnalyserCheck = Log Analyser Check,\ org.dspace.health.AdditionalInfoCheck = Additional Information,\ org.dspace.health.OAIPMHCheck = OAI-PMH validation,\ - org.dspace.health.PIDCheck = PID Check,\ org.dspace.health.ShibbolethCheck = Shibboleth Check # report from the last N days (where dates are applicable)