diff --git a/pom.xml b/pom.xml index 20471eb4a..22a55833e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,192 +1,151 @@ - 4.0.0 - - ch.eitchnet - ch.eitchnet.utils - jar - 0.1.0-SNAPSHOT - ch.eitchnet.utils - https://github.com/eitch/ch.eitchnet.utils + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 - - UTF-8 - + ch.eitchnet + ch.eitchnet.utils + jar + 0.1.0-SNAPSHOT + ch.eitchnet.utils + https://github.com/eitch/ch.eitchnet.utils - + + UTF-8 + - 2011 - - - GNU Lesser General Public License - http://www.gnu.org/licenses/lgpl.html - repo - - - - eitchnet.ch - http://blog.eitchnet.ch - - - - eitch - Robert von Vurg - eitch@eitchnet.ch - http://blog.eitchnet.ch - eitchnet.ch - http://blog.eitchnet.ch - - architect - developer - - +1 - - http://localhost - - - + - - Github Issues - https://github.com/eitch/ch.eitchnet.utils/issues - + 2011 + + + GNU Lesser General Public License + http://www.gnu.org/licenses/lgpl.html + repo + + + + eitchnet.ch + http://blog.eitchnet.ch + + + + eitch + Robert von Vurg + eitch@eitchnet.ch + http://blog.eitchnet.ch + eitchnet.ch + http://blog.eitchnet.ch + + architect + developer + + +1 + + http://localhost + + + - + - - scm:git:https://github.com/eitch/ch.eitchnet.utils.git - scm:git:git@github.com:eitch/ch.eitchnet.utils.git - https://github.com/eitch/ch.eitchnet.utils - + + scm:git:https://github.com/eitch/ch.eitchnet.utils.git + scm:git:git@github.com:eitch/ch.eitchnet.utils.git + https://github.com/eitch/ch.eitchnet.utils + - + - - - junit - junit - 4.10 - test - - - log4j - log4j - 1.2.17 - - + + + junit + junit + 4.10 + test + + + log4j + log4j + 1.2.17 + + - - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - true - true - - + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.9 + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + verify + + jar-no-fork + + + + - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - verify - - jar-no-fork - - - - + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + true + + + + + - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - true - true - - - - - - - - org.apache.maven.plugins - maven-site-plugin - 2.3 - - UTF-8 - - - - - + + org.apache.maven.plugins + maven-site-plugin + 2.3 + + UTF-8 + + + + diff --git a/src/main/java/ch/eitchnet/rmi/RmiFileDeletion.java b/src/main/java/ch/eitchnet/rmi/RmiFileDeletion.java index a8fc6d385..3071092f0 100644 --- a/src/main/java/ch/eitchnet/rmi/RmiFileDeletion.java +++ b/src/main/java/ch/eitchnet/rmi/RmiFileDeletion.java @@ -47,13 +47,13 @@ public class RmiFileDeletion implements Serializable { * @return the fileType */ public String getFileType() { - return fileType; + return this.fileType; } /** * @return the fileName */ public String getFileName() { - return fileName; + return this.fileName; } } diff --git a/src/main/java/ch/eitchnet/rmi/RmiFileHandler.java b/src/main/java/ch/eitchnet/rmi/RmiFileHandler.java index f21355aae..7d3ff04b4 100644 --- a/src/main/java/ch/eitchnet/rmi/RmiFileHandler.java +++ b/src/main/java/ch/eitchnet/rmi/RmiFileHandler.java @@ -80,7 +80,7 @@ public class RmiFileHandler { validateFileType(fileType); // evaluate the path where the file should reside - File file = new File(basePath + "/" + fileType, filePart.getFileName()); + File file = new File(this.basePath + "/" + fileType, filePart.getFileName()); // now evaluate the file exists if (!file.canRead()) { @@ -102,9 +102,9 @@ public class RmiFileHandler { // variables defining the part of the file we're going to return long requestOffset = filePart.getPartOffset(); int requestSize = filePart.getPartLength(); - if (requestSize > MAX_PART_SIZE) { + if (requestSize > RmiFileHandler.MAX_PART_SIZE) { throw new RuntimeException("The requested part size " + requestSize + " is greater than the allowed " - + MAX_PART_SIZE); + + RmiFileHandler.MAX_PART_SIZE); } // validate lengths and offsets @@ -125,7 +125,7 @@ public class RmiFileHandler { long l = Math.min(requestSize, remaining); // this is a fail safe - if (l > MAX_PART_SIZE) + if (l > RmiFileHandler.MAX_PART_SIZE) throw new RuntimeException("Something went wrong. Min of requestSize and remaining is > MAX_PART_SIZE!"); // this is the size of the array we want to return @@ -163,7 +163,7 @@ public class RmiFileHandler { try { fin.close(); } catch (IOException e) { - logger.error("Error while closing FileInputStream: " + e.getLocalizedMessage()); + RmiFileHandler.logger.error("Error while closing FileInputStream: " + e.getLocalizedMessage()); } } } @@ -190,7 +190,7 @@ public class RmiFileHandler { validateFileType(fileType); // evaluate the path where the file should reside - File dstFile = new File(basePath + "/" + fileType, filePart.getFileName()); + File dstFile = new File(this.basePath + "/" + fileType, filePart.getFileName()); // if the file already exists, then this may not be a start part if (filePart.getPartOffset() == 0 && dstFile.exists()) { @@ -231,7 +231,7 @@ public class RmiFileHandler { validateFileType(fileType); // evaluate the path where the file should reside - File fileToDelete = new File(basePath + "/" + fileType, fileDeletion.getFileName()); + File fileToDelete = new File(this.basePath + "/" + fileType, fileDeletion.getFileName()); // delete the file return FileHelper.deleteFiles(new File[] { fileToDelete }, true); diff --git a/src/main/java/ch/eitchnet/rmi/RmiFilePart.java b/src/main/java/ch/eitchnet/rmi/RmiFilePart.java index 750b993a6..627fcc373 100644 --- a/src/main/java/ch/eitchnet/rmi/RmiFilePart.java +++ b/src/main/java/ch/eitchnet/rmi/RmiFilePart.java @@ -64,7 +64,7 @@ public class RmiFilePart implements Serializable { * @return the fileLength */ public long getFileLength() { - return fileLength; + return this.fileLength; } /** @@ -79,7 +79,7 @@ public class RmiFilePart implements Serializable { * @return the fileHash */ public String getFileHash() { - return fileHash; + return this.fileHash; } /** @@ -94,14 +94,14 @@ public class RmiFilePart implements Serializable { * @return the fileType */ public String getFileType() { - return fileType; + return this.fileType; } /** * @return the partOffset */ public long getPartOffset() { - return partOffset; + return this.partOffset; } /** @@ -116,7 +116,7 @@ public class RmiFilePart implements Serializable { * @return the partLength */ public int getPartLength() { - return partLength; + return this.partLength; } /** @@ -131,7 +131,7 @@ public class RmiFilePart implements Serializable { * @return the partBytes */ public byte[] getPartBytes() { - return partBytes; + return this.partBytes; } /** @@ -146,7 +146,7 @@ public class RmiFilePart implements Serializable { * @return the lastPart */ public boolean isLastPart() { - return lastPart; + return this.lastPart; } /** @@ -161,6 +161,6 @@ public class RmiFilePart implements Serializable { * @return the fileName */ public String getFileName() { - return fileName; + return this.fileName; } } diff --git a/src/main/java/ch/eitchnet/rmi/RmiHelper.java b/src/main/java/ch/eitchnet/rmi/RmiHelper.java index a8530ad0c..6cf6dae2a 100644 --- a/src/main/java/ch/eitchnet/rmi/RmiHelper.java +++ b/src/main/java/ch/eitchnet/rmi/RmiHelper.java @@ -40,10 +40,10 @@ public class RmiHelper { /** * @param rmiFileClient - * @param filePart + * @param origFilePart * @param dstFile */ - public static void downloadFile(RMIFileClient rmiFileClient, RmiFilePart filePart, File dstFile) { + public static void downloadFile(RMIFileClient rmiFileClient, RmiFilePart origFilePart, File dstFile) { // here we don't overwrite, the caller must make sure the destination file does not exist if (dstFile.exists()) @@ -51,56 +51,59 @@ public class RmiHelper { + " already exists. Delete it first, if you want to overwrite it!"); try { + + RmiFilePart tmpPart = origFilePart; + int loops = 0; - int startLength = filePart.getPartLength(); + int startLength = tmpPart.getPartLength(); while (true) { loops += 1; // get the next part - filePart = rmiFileClient.requestFile(filePart); + tmpPart = rmiFileClient.requestFile(tmpPart); // validate length of data - if (filePart.getPartLength() != filePart.getPartBytes().length) - throw new RuntimeException("Invalid FilePart. Part length is not as long as the bytes passed " - + filePart.getPartLength() + " / " + filePart.getPartBytes().length); + if (tmpPart.getPartLength() != tmpPart.getPartBytes().length) + throw new RuntimeException("Invalid tmpPart. Part length is not as long as the bytes passed " + + tmpPart.getPartLength() + " / " + tmpPart.getPartBytes().length); // validate offset is size of file - if (filePart.getPartOffset() != dstFile.length()) { + if (tmpPart.getPartOffset() != dstFile.length()) { throw new RuntimeException("The part offset $offset is not at the end of the file " - + filePart.getPartOffset() + " / " + dstFile.length()); + + tmpPart.getPartOffset() + " / " + dstFile.length()); } // append the part - FileHelper.appendFilePart(dstFile, filePart.getPartBytes()); + FileHelper.appendFilePart(dstFile, tmpPart.getPartBytes()); // update the offset - filePart.setPartOffset(filePart.getPartOffset() + filePart.getPartBytes().length); + tmpPart.setPartOffset(tmpPart.getPartOffset() + tmpPart.getPartBytes().length); // break if the offset is past the length of the file - if (filePart.getPartOffset() >= filePart.getFileLength()) + if (tmpPart.getPartOffset() >= tmpPart.getFileLength()) break; } - logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Requested " + loops - + " parts. StartSize: " + startLength + " EndSize: " + filePart.getPartLength()); + RmiHelper.logger.info(tmpPart.getFileType() + ": " + tmpPart.getFileName() + ": Requested " + loops + + " parts. StartSize: " + startLength + " EndSize: " + tmpPart.getPartLength()); // validate that the offset is at the end of the file - if (filePart.getPartOffset() != filePart.getFileLength()) { - throw new RuntimeException("Offset " + filePart.getPartOffset() + " is not at file length " - + filePart.getFileLength() + " after reading all the file parts!"); + if (tmpPart.getPartOffset() != origFilePart.getFileLength()) { + throw new RuntimeException("Offset " + tmpPart.getPartOffset() + " is not at file length " + + origFilePart.getFileLength() + " after reading all the file parts!"); } // now validate hashes String dstFileHash = StringHelper.getHexString(FileHelper.hashFileSha256(dstFile)); - if (!dstFileHash.equals(filePart.getFileHash())) { - throw new RuntimeException("Downloading the file " + filePart.getFileName() - + " failed because the hashes don't match. Expected: " + filePart.getFileHash() + " / Actual: " - + dstFileHash); + if (!dstFileHash.equals(origFilePart.getFileHash())) { + throw new RuntimeException("Downloading the file " + origFilePart.getFileName() + + " failed because the hashes don't match. Expected: " + origFilePart.getFileHash() + + " / Actual: " + dstFileHash); } } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; - throw new RuntimeException("Downloading the file " + filePart.getFileName() + throw new RuntimeException("Downloading the file " + origFilePart.getFileName() + " failed because of an underlying exception " + e.getLocalizedMessage()); } } @@ -194,7 +197,7 @@ public class RmiHelper { offset = nextOffset; } - logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Sent " + loops + RmiHelper.logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Sent " + loops + " parts. StartSize: " + startLength + " EndSize: " + filePart.getPartLength()); } catch (Exception e) { @@ -207,7 +210,7 @@ public class RmiHelper { try { inputStream.close(); } catch (IOException e) { - logger.error("Exception while closing FileInputStream " + e.getLocalizedMessage()); + RmiHelper.logger.error("Exception while closing FileInputStream " + e.getLocalizedMessage()); } } } diff --git a/src/main/java/ch/eitchnet/utils/helper/FileHelper.java b/src/main/java/ch/eitchnet/utils/helper/FileHelper.java index 9cba18dc3..aac499b67 100644 --- a/src/main/java/ch/eitchnet/utils/helper/FileHelper.java +++ b/src/main/java/ch/eitchnet/utils/helper/FileHelper.java @@ -79,7 +79,7 @@ public class FileHelper { try { bufferedReader.close(); } catch (IOException e) { - logger.error("Failed to close BufferedReader: " + e.getLocalizedMessage()); + FileHelper.logger.error("Failed to close BufferedReader: " + e.getLocalizedMessage()); } } } @@ -115,7 +115,7 @@ public class FileHelper { * @return true if all went well, and false if it did not work. The log will contain the problems encountered */ public final static boolean deleteFile(File file, boolean log) { - return deleteFiles(new File[] { file }, log); + return FileHelper.deleteFiles(new File[] { file }, log); } /** @@ -132,28 +132,28 @@ public class FileHelper { for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { - boolean done = deleteFiles(file.listFiles(), log); + boolean done = FileHelper.deleteFiles(file.listFiles(), log); if (!done) { worked = false; - logger.warn("Could not empty the directory: " + file.getAbsolutePath()); + FileHelper.logger.warn("Could not empty the directory: " + file.getAbsolutePath()); } else { done = file.delete(); if (done) { if (log) - logger.info("Deleted DIR " + file.getAbsolutePath()); + FileHelper.logger.info("Deleted DIR " + file.getAbsolutePath()); } else { worked = false; - logger.warn("Could not delete the directory: " + file.getAbsolutePath()); + FileHelper.logger.warn("Could not delete the directory: " + file.getAbsolutePath()); } } } else { boolean done = file.delete(); if (done) { if (log) - logger.info("Deleted FILE " + file.getAbsolutePath()); + FileHelper.logger.info("Deleted FILE " + file.getAbsolutePath()); } else { worked = false; - logger.warn(("Could not delete the file: " + file.getAbsolutePath())); + FileHelper.logger.warn(("Could not delete the file: " + file.getAbsolutePath())); } } } @@ -195,7 +195,7 @@ public class FileHelper { String fromFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(fromFile)); String toFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(toFile)); if (!fromFileMD5.equals(toFileMD5)) { - logger.error("Copying failed, as MD5 sums are not equal: " + fromFileMD5 + " / " + toFileMD5); + FileHelper.logger.error("Copying failed, as MD5 sums are not equal: " + fromFileMD5 + " / " + toFileMD5); toFile.delete(); return false; @@ -204,7 +204,7 @@ public class FileHelper { // cleanup if files are not the same length if (fromFile.length() != toFile.length()) { - logger.error("Copying failed, as new files are not the same length: " + fromFile.length() + " / " + FileHelper.logger.error("Copying failed, as new files are not the same length: " + fromFile.length() + " / " + toFile.length()); toFile.delete(); @@ -213,7 +213,7 @@ public class FileHelper { } catch (Exception e) { - logger.error(e, e); + FileHelper.logger.error(e, e); return false; } finally { @@ -222,7 +222,7 @@ public class FileHelper { try { inBuffer.close(); } catch (IOException e) { - logger.error("Error closing BufferedInputStream" + e); + FileHelper.logger.error("Error closing BufferedInputStream" + e); } } @@ -230,7 +230,7 @@ public class FileHelper { try { outBuffer.close(); } catch (IOException e) { - logger.error("Error closing BufferedOutputStream" + e); + FileHelper.logger.error("Error closing BufferedOutputStream" + e); } } } @@ -254,11 +254,11 @@ public class FileHelper { return true; } - logger.warn("Simple File.renameTo failed, trying copy/delete..."); + FileHelper.logger.warn("Simple File.renameTo failed, trying copy/delete..."); // delete if copy was successful, otherwise move will fail if (FileHelper.copy(fromFile, toFile, true)) { - logger.info("Deleting fromFile: " + fromFile.getAbsolutePath()); + FileHelper.logger.info("Deleting fromFile: " + fromFile.getAbsolutePath()); return fromFile.delete(); } @@ -372,7 +372,7 @@ public class FileHelper { * @return the humanized form of the files size */ public final static String humanizeFileSize(File file) { - return humanizeFileSize(file.length()); + return FileHelper.humanizeFileSize(file.length()); } /** @@ -407,7 +407,7 @@ public class FileHelper { * @return the hash as a byte array */ public static byte[] hashFileMd5(File file) { - return hashFile(file, "MD5"); + return FileHelper.hashFile(file, "MD5"); } /** @@ -420,7 +420,7 @@ public class FileHelper { * @return the hash as a byte array */ public static byte[] hashFileSha1(File file) { - return hashFile(file, "SHA-1"); + return FileHelper.hashFile(file, "SHA-1"); } /** @@ -433,7 +433,7 @@ public class FileHelper { * @return the hash as a byte array */ public static byte[] hashFileSha256(File file) { - return hashFile(file, "SHA-256"); + return FileHelper.hashFile(file, "SHA-256"); } /** @@ -492,7 +492,7 @@ public class FileHelper { try { outputStream.close(); } catch (IOException e) { - logger.error("Exception while closing FileOutputStream " + e.getLocalizedMessage()); + FileHelper.logger.error("Exception while closing FileOutputStream " + e.getLocalizedMessage()); } } } diff --git a/src/main/java/ch/eitchnet/utils/helper/Log4jConfigurator.java b/src/main/java/ch/eitchnet/utils/helper/Log4jConfigurator.java index 327ab5446..678ff78f3 100644 --- a/src/main/java/ch/eitchnet/utils/helper/Log4jConfigurator.java +++ b/src/main/java/ch/eitchnet/utils/helper/Log4jConfigurator.java @@ -63,9 +63,9 @@ public class Log4jConfigurator { * Configures log4j with the default {@link ConsoleAppender} */ public static synchronized void configure() { - cleanupOldWatchdog(); + Log4jConfigurator.cleanupOldWatchdog(); BasicConfigurator.resetConfiguration(); - BasicConfigurator.configure(new ConsoleAppender(getDefaulLayout())); + BasicConfigurator.configure(new ConsoleAppender(Log4jConfigurator.getDefaulLayout())); Logger.getRootLogger().setLevel(Level.INFO); } @@ -119,13 +119,13 @@ public class Log4jConfigurator { + log4JPath.getAbsolutePath()); // now perform the loading - loadLog4jConfiguration(log4JPath); + Log4jConfigurator.loadLog4jConfiguration(log4JPath); } catch (Exception e) { Log4jConfigurator.configure(); - logger.error(e, e); - logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file exists at " + Log4jConfigurator.logger.error(e, e); + Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file exists at " + log4JPath.getAbsolutePath()); } @@ -152,7 +152,7 @@ public class Log4jConfigurator { throw new RuntimeException("log4jConfigPath may not be null!"); // first clean up any old watch dog in case of a programmatic re-load of the configuration - cleanupOldWatchdog(); + Log4jConfigurator.cleanupOldWatchdog(); // get the root directory String userDir = System.getProperty("user.dir"); @@ -184,16 +184,16 @@ public class Log4jConfigurator { // XXX if the server is in a web context, then we may not use the // FileWatchDog BasicConfigurator.resetConfiguration(); - watchDog = new Log4jPropertyWatchDog(pathNameToLog4jTemp); - watchDog.start(); + Log4jConfigurator.watchDog = new Log4jPropertyWatchDog(pathNameToLog4jTemp); + Log4jConfigurator.watchDog.start(); - logger.info("Log4j is configured to use and watch file " + pathNameToLog4jTemp); + Log4jConfigurator.logger.info("Log4j is configured to use and watch file " + pathNameToLog4jTemp); } catch (Exception e) { Log4jConfigurator.configure(); - logger.error(e, e); - logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file at " + Log4jConfigurator.logger.error(e, e); + Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file at " + log4jConfigPath); } finally { @@ -201,14 +201,14 @@ public class Log4jConfigurator { try { fin.close(); } catch (IOException e) { - logger.error("Exception closing input file: " + e, e); + Log4jConfigurator.logger.error("Exception closing input file: " + e, e); } } if (fout != null) { try { fout.close(); } catch (IOException e) { - logger.error("Exception closing output file: " + e, e); + Log4jConfigurator.logger.error("Exception closing output file: " + e, e); } } } @@ -229,9 +229,9 @@ public class Log4jConfigurator { if (clazz == null) throw new RuntimeException("clazz may not be null!"); - InputStream resourceAsStream = clazz.getResourceAsStream("/" + FILE_LOG4J); + InputStream resourceAsStream = clazz.getResourceAsStream("/" + Log4jConfigurator.FILE_LOG4J); if (resourceAsStream == null) { - throw new RuntimeException("The resource '" + FILE_LOG4J + "' could not be found for class " + throw new RuntimeException("The resource '" + Log4jConfigurator.FILE_LOG4J + "' could not be found for class " + clazz.getName()); } @@ -240,13 +240,13 @@ public class Log4jConfigurator { log4jProperties.load(resourceAsStream); // and then - loadLog4jConfiguration(log4jProperties); + Log4jConfigurator.loadLog4jConfiguration(log4jProperties); } catch (Exception e) { Log4jConfigurator.configure(); - logger.error(e, e); - logger.error("Log4j COULD NOT BE INITIALIZED. Please check that the log4j configuration file '" - + FILE_LOG4J + "' exists as a resource for class " + clazz.getName() + Log4jConfigurator.logger.error(e, e); + Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check that the log4j configuration file '" + + Log4jConfigurator.FILE_LOG4J + "' exists as a resource for class " + clazz.getName() + " and is a valid properties configuration"); } } @@ -272,19 +272,19 @@ public class Log4jConfigurator { throw new RuntimeException("log4jProperties may not be null!"); // first clean up any old watch dog in case of a programmatic re-load of the configuration - cleanupOldWatchdog(); + Log4jConfigurator.cleanupOldWatchdog(); // replace any variables StringHelper.replaceProperties(log4jProperties, System.getProperties()); // now configure log4j PropertyConfigurator.configure(log4jProperties); - logger.info("Log4j is configured using the given properties."); + Log4jConfigurator.logger.info("Log4j is configured using the given properties."); } catch (Exception e) { Log4jConfigurator.configure(); - logger.error(e, e); - logger.error("Log4j COULD NOT BE INITIALIZED. The given log4jProperties seem not to be valid!"); + Log4jConfigurator.logger.error(e, e); + Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. The given log4jProperties seem not to be valid!"); } } @@ -293,17 +293,17 @@ public class Log4jConfigurator { */ public static synchronized void cleanupOldWatchdog() { // clean up an old watch dog - if (watchDog != null) { - logger.info("Stopping old Log4j watchdog."); - watchDog.interrupt(); + if (Log4jConfigurator.watchDog != null) { + Log4jConfigurator.logger.info("Stopping old Log4j watchdog."); + Log4jConfigurator.watchDog.interrupt(); try { - watchDog.join(1000l); + Log4jConfigurator.watchDog.join(1000l); } catch (InterruptedException e) { - logger.error("Oops. Could not terminate an old WatchDog."); + Log4jConfigurator.logger.error("Oops. Could not terminate an old WatchDog."); } finally { - watchDog = null; + Log4jConfigurator.watchDog = null; } - logger.info("Done."); + Log4jConfigurator.logger.info("Done."); } } } diff --git a/src/main/java/ch/eitchnet/utils/helper/Log4jPropertyWatchDog.java b/src/main/java/ch/eitchnet/utils/helper/Log4jPropertyWatchDog.java index a4f2aecda..e13794550 100644 --- a/src/main/java/ch/eitchnet/utils/helper/Log4jPropertyWatchDog.java +++ b/src/main/java/ch/eitchnet/utils/helper/Log4jPropertyWatchDog.java @@ -44,7 +44,7 @@ public class Log4jPropertyWatchDog extends Thread { /** * The delay to observe between every check. By default set {@link #DEFAULT_DELAY}. */ - protected long delay = DEFAULT_DELAY; + protected long delay = Log4jPropertyWatchDog.DEFAULT_DELAY; protected File file; protected long lastModif = 0; @@ -57,7 +57,7 @@ public class Log4jPropertyWatchDog extends Thread { protected Log4jPropertyWatchDog(String filename) { super("FileWatchdog"); this.filename = filename; - file = new File(filename); + this.file = new File(filename); setDaemon(true); checkAndConfigure(); } @@ -75,24 +75,24 @@ public class Log4jPropertyWatchDog extends Thread { protected void checkAndConfigure() { boolean fileExists; try { - fileExists = file.exists(); + fileExists = this.file.exists(); } catch (SecurityException e) { - LogLog.warn("Was not allowed to read check file existance, file:[" + filename + "]."); - interrupted = true; // there is no point in continuing + LogLog.warn("Was not allowed to read check file existance, file:[" + this.filename + "]."); + this.interrupted = true; // there is no point in continuing return; } if (fileExists) { - long l = file.lastModified(); // this can also throw a SecurityException - if (l > lastModif) { // however, if we reached this point this - lastModif = l; // is very unlikely. + long l = this.file.lastModified(); // this can also throw a SecurityException + if (l > this.lastModif) { // however, if we reached this point this + this.lastModif = l; // is very unlikely. doOnChange(); - warnedAlready = false; + this.warnedAlready = false; } } else { - if (!warnedAlready) { - LogLog.debug("[" + filename + "] does not exist."); - warnedAlready = true; + if (!this.warnedAlready) { + LogLog.debug("[" + this.filename + "] does not exist."); + this.warnedAlready = true; } } } @@ -102,7 +102,7 @@ public class Log4jPropertyWatchDog extends Thread { */ public void doOnChange() { PropertyConfigurator propertyConfigurator = new PropertyConfigurator(); - propertyConfigurator.doConfigure(filename, LogManager.getLoggerRepository()); + propertyConfigurator.doConfigure(this.filename, LogManager.getLoggerRepository()); } /** @@ -110,12 +110,12 @@ public class Log4jPropertyWatchDog extends Thread { */ @Override public void run() { - while (!interrupted) { + while (!this.interrupted) { try { - Thread.sleep(delay); + Thread.sleep(this.delay); } catch (InterruptedException e) { // no interruption expected - interrupted = true; + this.interrupted = true; } checkAndConfigure(); } diff --git a/src/main/java/ch/eitchnet/utils/helper/ProcessHelper.java b/src/main/java/ch/eitchnet/utils/helper/ProcessHelper.java index 30a7a17bd..c30366426 100644 --- a/src/main/java/ch/eitchnet/utils/helper/ProcessHelper.java +++ b/src/main/java/ch/eitchnet/utils/helper/ProcessHelper.java @@ -45,7 +45,7 @@ public class ProcessHelper { Thread errorIn = new Thread("errorIn") { @Override public void run() { - readStream(sb, "[ERROR] ", errorStream); + ProcessHelper.readStream(sb, "[ERROR] ", errorStream); } }; errorIn.start(); @@ -55,7 +55,7 @@ public class ProcessHelper { Thread infoIn = new Thread("infoIn") { @Override public void run() { - readStream(sb, "[INFO] ", inputStream); + ProcessHelper.readStream(sb, "[INFO] ", inputStream); } }; infoIn.start(); @@ -72,7 +72,7 @@ public class ProcessHelper { throw new RuntimeException("Failed to perform command: " + e.getLocalizedMessage(), e); } catch (InterruptedException e) { - logger.error("Interrupted!"); + ProcessHelper.logger.error("Interrupted!"); sb.append("[FATAL] Interrupted"); return new ProcessResult(-1, sb.toString(), e); } @@ -102,7 +102,7 @@ public class ProcessHelper { Thread errorIn = new Thread("errorIn") { @Override public void run() { - readStream(sb, "[ERROR] ", errorStream); + ProcessHelper.readStream(sb, "[ERROR] ", errorStream); } }; errorIn.start(); @@ -112,7 +112,7 @@ public class ProcessHelper { Thread infoIn = new Thread("infoIn") { @Override public void run() { - readStream(sb, "[INFO] ", inputStream); + ProcessHelper.readStream(sb, "[INFO] ", inputStream); } }; infoIn.start(); @@ -129,7 +129,7 @@ public class ProcessHelper { throw new RuntimeException("Failed to perform command: " + e.getLocalizedMessage(), e); } catch (InterruptedException e) { - logger.error("Interrupted!"); + ProcessHelper.logger.error("Interrupted!"); sb.append("[FATAL] Interrupted"); return new ProcessResult(-1, sb.toString(), e); } @@ -165,33 +165,33 @@ public class ProcessHelper { ProcessResult processResult; if (SystemHelper.isLinux()) { - processResult = runCommand("xdg-open " + pdfPath.getAbsolutePath()); + processResult = ProcessHelper.runCommand("xdg-open " + pdfPath.getAbsolutePath()); } else if (SystemHelper.isMacOS()) { - processResult = runCommand("open " + pdfPath.getAbsolutePath()); + processResult = ProcessHelper.runCommand("open " + pdfPath.getAbsolutePath()); } else if (SystemHelper.isWindows()) { // remove the first char (/) from the report path (/D:/temp.....) String pdfFile = pdfPath.getAbsolutePath(); if (pdfFile.charAt(0) == '/') pdfFile = pdfFile.substring(1); - processResult = runCommand("rundll32 url.dll,FileProtocolHandler " + processResult = ProcessHelper.runCommand("rundll32 url.dll,FileProtocolHandler " + pdfFile); } else { throw new UnsupportedOperationException("Unexpected OS: " + SystemHelper.osName); } - logProcessResult(processResult); + ProcessHelper.logProcessResult(processResult); } public static void logProcessResult(ProcessResult processResult) { if (processResult.returnValue == 0) { - logger.info("Process executed successfully"); + ProcessHelper.logger.info("Process executed successfully"); } else if (processResult.returnValue == -1) { - logger.error("Process execution failed:\n" + ProcessHelper.logger.error("Process execution failed:\n" + processResult.processOutput); - logger.error(processResult.t, processResult.t); + ProcessHelper.logger.error(processResult.t, processResult.t); } else { - logger.info("Process execution was not successful with return value:" + ProcessHelper.logger.info("Process execution was not successful with return value:" + processResult.returnValue + "\n" + processResult.processOutput); diff --git a/src/main/java/ch/eitchnet/utils/helper/StringHelper.java b/src/main/java/ch/eitchnet/utils/helper/StringHelper.java index c44a2ac5e..9ba4b56fb 100644 --- a/src/main/java/ch/eitchnet/utils/helper/StringHelper.java +++ b/src/main/java/ch/eitchnet/utils/helper/StringHelper.java @@ -59,8 +59,8 @@ public class StringHelper { for (byte b : raw) { int v = b & 0xFF; - hex[index++] = HEX_CHAR_TABLE[v >>> 4]; - hex[index++] = HEX_CHAR_TABLE[v & 0xF]; + hex[index++] = StringHelper.HEX_CHAR_TABLE[v >>> 4]; + hex[index++] = StringHelper.HEX_CHAR_TABLE[v & 0xF]; } return new String(hex, "ASCII"); @@ -103,7 +103,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashMd5(String string) { - return hashMd5(string.getBytes()); + return StringHelper.hashMd5(string.getBytes()); } /** @@ -116,7 +116,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashMd5(byte[] bytes) { - return hash("MD5", bytes); + return StringHelper.hash("MD5", bytes); } /** @@ -129,7 +129,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashSha1(String string) { - return hashSha1(string.getBytes()); + return StringHelper.hashSha1(string.getBytes()); } /** @@ -142,7 +142,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashSha1(byte[] bytes) { - return hash("SHA-1", bytes); + return StringHelper.hash("SHA-1", bytes); } /** @@ -155,7 +155,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashSha256(String string) { - return hashSha256(string.getBytes()); + return StringHelper.hashSha256(string.getBytes()); } /** @@ -168,7 +168,7 @@ public class StringHelper { * @return the hash or null, if an exception was thrown */ public static byte[] hashSha256(byte[] bytes) { - return hash("SHA-256", bytes); + return StringHelper.hash("SHA-256", bytes); } /** @@ -209,7 +209,7 @@ public class StringHelper { * @return the new string */ public static String normalizeLength(String value, int length, boolean beginning, char c) { - return normalizeLength(value, length, beginning, false, c); + return StringHelper.normalizeLength(value, length, beginning, false, c); } /** @@ -235,20 +235,21 @@ public class StringHelper { if (value.length() < length) { - while (value.length() != length) { + String tmp = value; + while (tmp.length() != length) { if (beginning) { - value = c + value; + tmp = c + tmp; } else { - value = value + c; + tmp = tmp + c; } } - return value; + return tmp; } else if (shorten) { - logger.warn("Shortening length of value: " + value); - logger.warn("Length is: " + value.length() + " max: " + length); + StringHelper.logger.warn("Shortening length of value: " + value); + StringHelper.logger.warn("Length is: " + value.length() + " max: " + length); return value.substring(0, length); } @@ -263,7 +264,7 @@ public class StringHelper { * returned */ public static String replaceSystemPropertiesIn(String value) { - return replacePropertiesIn(System.getProperties(), value); + return StringHelper.replacePropertiesIn(System.getProperties(), value); } /** @@ -278,41 +279,41 @@ public class StringHelper { * * @return a new string with all defined properties replaced or if an error occurred the original value is returned */ - public static String replacePropertiesIn(Properties properties, String value) { + public static String replacePropertiesIn(Properties properties, String alue) { - // keep copy of original value - String origValue = value; + // get a copy of the value + String tmpValue = alue; // get first occurrence of $ character int pos = -1; int stop = 0; // loop on $ character positions - while ((pos = value.indexOf('$', pos + 1)) != -1) { + while ((pos = tmpValue.indexOf('$', pos + 1)) != -1) { // if pos+1 is not { character then continue - if (value.charAt(pos + 1) != '{') { + if (tmpValue.charAt(pos + 1) != '{') { continue; } // find end of sequence with } character - stop = value.indexOf('}', pos + 1); + stop = tmpValue.indexOf('}', pos + 1); // if no stop found, then break as another sequence should be able to start if (stop == -1) { - logger.error("Sequence starts at offset " + pos + " but does not end!"); - value = origValue; + StringHelper.logger.error("Sequence starts at offset " + pos + " but does not end!"); + tmpValue = alue; break; } // get sequence enclosed by pos and stop - String sequence = value.substring(pos + 2, stop); + String sequence = tmpValue.substring(pos + 2, stop); // make sure sequence doesn't contain $ { } characters if (sequence.contains("$") || sequence.contains("{") || sequence.contains("}")) { - logger.error("Enclosed sequence in offsets " + pos + " - " + stop + StringHelper.logger.error("Enclosed sequence in offsets " + pos + " - " + stop + " contains one of the illegal chars: $ { }: " + sequence); - value = origValue; + tmpValue = alue; break; } @@ -326,10 +327,10 @@ public class StringHelper { } // property exists, so replace in value - value = value.replace("${" + sequence + "}", property); + tmpValue = tmpValue.replace("${" + sequence + "}", property); } - return value; + return tmpValue; } /** @@ -340,7 +341,7 @@ public class StringHelper { * the properties in which the values must have any ${...} replaced by values of the respective key */ public static void replaceProperties(Properties properties) { - replaceProperties(properties, null); + StringHelper.replaceProperties(properties, null); } /** diff --git a/src/main/java/ch/eitchnet/utils/helper/SystemHelper.java b/src/main/java/ch/eitchnet/utils/helper/SystemHelper.java index eeb3aa284..50fb91628 100644 --- a/src/main/java/ch/eitchnet/utils/helper/SystemHelper.java +++ b/src/main/java/ch/eitchnet/utils/helper/SystemHelper.java @@ -34,7 +34,7 @@ public class SystemHelper { } public static SystemHelper getInstance() { - return instance; + return SystemHelper.instance; } public static final String osName = System.getProperty("os.name"); @@ -55,7 +55,7 @@ public class SystemHelper { */ @Override public String toString() { - return asString(); + return SystemHelper.asString(); } /** @@ -63,15 +63,15 @@ public class SystemHelper { */ public static String asString() { StringBuilder sb = new StringBuilder(); - sb.append(osName); + sb.append(SystemHelper.osName); sb.append(" "); - sb.append(osArch); + sb.append(SystemHelper.osArch); sb.append(" "); - sb.append(osVersion); + sb.append(SystemHelper.osVersion); sb.append(" "); - sb.append("on Java " + javaVendor); + sb.append("on Java " + SystemHelper.javaVendor); sb.append(" version "); - sb.append(javaVersion); + sb.append(SystemHelper.javaVersion); return sb.toString(); } @@ -80,23 +80,23 @@ public class SystemHelper { } public static boolean isMacOS() { - return osName.startsWith("Mac"); + return SystemHelper.osName.startsWith("Mac"); } public static boolean isWindows() { - return osName.startsWith("Win"); + return SystemHelper.osName.startsWith("Win"); } public static boolean isLinux() { - return osName.startsWith("Lin"); + return SystemHelper.osName.startsWith("Lin"); } public static boolean is32bit() { - return osArch.equals("x86") || osArch.equals("i386") || osArch.equals("i686"); + return SystemHelper.osArch.equals("x86") || SystemHelper.osArch.equals("i386") || SystemHelper.osArch.equals("i686"); } public static boolean is64bit() { - return osArch.equals("x86_64") || osArch.equals("amd64"); + return SystemHelper.osArch.equals("x86_64") || SystemHelper.osArch.equals("amd64"); } public static String getMaxMemory() { @@ -112,7 +112,7 @@ public class SystemHelper { } public static String getMemorySummary() { - return "Memory available " + getMaxMemory() + " / Used: " + getUsedMemory() + " / Free:" + getFreeMemory(); + return "Memory available " + SystemHelper.getMaxMemory() + " / Used: " + SystemHelper.getUsedMemory() + " / Free:" + SystemHelper.getFreeMemory(); } /** @@ -150,7 +150,7 @@ public class SystemHelper { * if the property is not set and def is null */ public static Boolean getPropertyBool(String context, String key, Boolean def) throws RuntimeException { - return Boolean.valueOf(getProperty(context, key, def == null ? null : def.toString())); + return Boolean.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString())); } /** @@ -163,7 +163,7 @@ public class SystemHelper { * if the property is not set and def is null */ public static Integer getPropertyInt(String context, String key, Integer def) throws RuntimeException { - return Integer.valueOf(getProperty(context, key, def == null ? null : def.toString())); + return Integer.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString())); } /** @@ -176,6 +176,6 @@ public class SystemHelper { * if the property is not set and def is null */ public static Double getPropertyDouble(String context, String key, Double def) throws RuntimeException { - return Double.valueOf(getProperty(context, key, def == null ? null : def.toString())); + return Double.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString())); } } diff --git a/src/main/java/ch/eitchnet/utils/objectfilter/ObjectCache.java b/src/main/java/ch/eitchnet/utils/objectfilter/ObjectCache.java index e2d0b5e09..2c55d2705 100644 --- a/src/main/java/ch/eitchnet/utils/objectfilter/ObjectCache.java +++ b/src/main/java/ch/eitchnet/utils/objectfilter/ObjectCache.java @@ -71,8 +71,8 @@ public class ObjectCache { this.object = object; this.operation = operation; - if (logger.isDebugEnabled()) { - logger.debug("Instanciated Cache: ID" + this.id + " / " + key + " OP: " + this.operation + " / " + if (ObjectCache.logger.isDebugEnabled()) { + ObjectCache.logger.debug("Instanciated Cache: ID" + this.id + " / " + key + " OP: " + this.operation + " / " + object.toString()); } } @@ -83,8 +83,8 @@ public class ObjectCache { * @param object */ public void setObject(T object) { - if (logger.isDebugEnabled()) { - logger.debug("Updating ID " + this.id + " to value " + object.toString()); + if (ObjectCache.logger.isDebugEnabled()) { + ObjectCache.logger.debug("Updating ID " + this.id + " to value " + object.toString()); } this.object = object; } @@ -95,8 +95,8 @@ public class ObjectCache { * @param newOperation */ public void setOperation(Operation newOperation) { - if (logger.isDebugEnabled()) { - logger.debug("Updating Operation of ID " + this.id + " from " + this.operation + " to " + newOperation); + if (ObjectCache.logger.isDebugEnabled()) { + ObjectCache.logger.debug("Updating Operation of ID " + this.id + " from " + this.operation + " to " + newOperation); } this.operation = newOperation; } @@ -105,27 +105,27 @@ public class ObjectCache { * @return the id */ public long getId() { - return id; + return this.id; } /** * @return the key */ public String getKey() { - return key; + return this.key; } /** * @return the object */ public T getObject() { - return object; + return this.object; } /** * @return the operation */ public Operation getOperation() { - return operation; + return this.operation; } } diff --git a/src/main/java/ch/eitchnet/utils/objectfilter/ObjectFilter.java b/src/main/java/ch/eitchnet/utils/objectfilter/ObjectFilter.java index a79970c11..51733db77 100644 --- a/src/main/java/ch/eitchnet/utils/objectfilter/ObjectFilter.java +++ b/src/main/java/ch/eitchnet/utils/objectfilter/ObjectFilter.java @@ -117,11 +117,11 @@ public class ObjectFilter { */ public void add(String key, T objectToAdd) { - if (logger.isDebugEnabled()) - logger.debug("add object " + objectToAdd + " with key " + key); + if (ObjectFilter.logger.isDebugEnabled()) + ObjectFilter.logger.debug("add object " + objectToAdd + " with key " + key); // add the key to the set - keySet.add(key); + this.keySet.add(key); // BEWARE: you fix a bug here, be sure to update BOTH tables on the logic. long id = objectToAdd.getTransactionID(); @@ -131,14 +131,14 @@ public class ObjectFilter { id = dispenseID(); objectToAdd.setTransactionID(id); ObjectCache cacheObj = new ObjectCache(key, objectToAdd, Operation.ADD); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { - ObjectCache cached = cache.get(Long.valueOf(objectToAdd.getTransactionID())); + ObjectCache cached = this.cache.get(Long.valueOf(objectToAdd.getTransactionID())); if (cached == null) { // The object got an ID during this run, but was not added to the cache. // Hence, we add it now, with the current operation. ObjectCache cacheObj = new ObjectCache(key, objectToAdd, Operation.ADD); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { String existingKey = cached.getKey(); if (!existingKey.equals(key)) { @@ -197,11 +197,11 @@ public class ObjectFilter { */ public void update(String key, T objectToUpdate) { - if (logger.isDebugEnabled()) - logger.debug("update object " + objectToUpdate + " with key " + key); + if (ObjectFilter.logger.isDebugEnabled()) + ObjectFilter.logger.debug("update object " + objectToUpdate + " with key " + key); // add the key to the keyset - keySet.add(key); + this.keySet.add(key); // BEWARE: you fix a bug here, be sure to update BOTH tables on the logic. long id = objectToUpdate.getTransactionID(); @@ -209,14 +209,14 @@ public class ObjectFilter { id = dispenseID(); objectToUpdate.setTransactionID(id); ObjectCache cacheObj = new ObjectCache(key, objectToUpdate, Operation.MODIFY); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { - ObjectCache cached = cache.get(Long.valueOf(objectToUpdate.getTransactionID())); + ObjectCache cached = this.cache.get(Long.valueOf(objectToUpdate.getTransactionID())); if (cached == null) { // The object got an ID during this run, but was not added to this cache. // Hence, we add it now, with the current operation. ObjectCache cacheObj = new ObjectCache(key, objectToUpdate, Operation.MODIFY); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { String existingKey = cached.getKey(); if (!existingKey.equals(key)) { @@ -275,25 +275,25 @@ public class ObjectFilter { */ public void remove(String key, T objectToRemove) { - if (logger.isDebugEnabled()) - logger.debug("remove object " + objectToRemove + " with key " + key); + if (ObjectFilter.logger.isDebugEnabled()) + ObjectFilter.logger.debug("remove object " + objectToRemove + " with key " + key); // add the key to the keyset - keySet.add(key); + this.keySet.add(key); // BEWARE: you fix a bug here, be sure to update BOTH tables on the logic. long id = objectToRemove.getTransactionID(); if (id == ITransactionObject.UNSET) { id = dispenseID(); objectToRemove.setTransactionID(id); ObjectCache cacheObj = new ObjectCache(key, objectToRemove, Operation.REMOVE); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { - ObjectCache cached = cache.get(Long.valueOf(id)); + ObjectCache cached = this.cache.get(Long.valueOf(id)); if (cached == null) { // The object got an ID during this run, but was not added to this cache. // Hence, we add it now, with the current operation. ObjectCache cacheObj = new ObjectCache(key, objectToRemove, Operation.REMOVE); - cache.put(id, cacheObj); + this.cache.put(id, cacheObj); } else { String existingKey = cached.getKey(); if (!existingKey.equals(key)) { @@ -315,7 +315,7 @@ public class ObjectFilter { case ADD: // this is a case where we're removing the object from the cache, since we are // removing it now and it was added previously. - cache.remove(Long.valueOf(id)); + this.cache.remove(Long.valueOf(id)); break; case MODIFY: cached.setObject(objectToRemove); @@ -448,7 +448,7 @@ public class ObjectFilter { */ public List getAdded(String key) { List addedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) { addedObjects.add(objectCache.getObject()); @@ -468,7 +468,7 @@ public class ObjectFilter { */ public List getAdded(Class clazz, String key) { List addedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) { if (objectCache.getObject().getClass() == clazz) { @@ -490,7 +490,7 @@ public class ObjectFilter { */ public List getUpdated(String key) { List updatedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) { updatedObjects.add(objectCache.getObject()); @@ -508,7 +508,7 @@ public class ObjectFilter { */ public List getUpdated(Class clazz, String key) { List updatedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) { if (objectCache.getObject().getClass() == clazz) { @@ -530,7 +530,7 @@ public class ObjectFilter { */ public List getRemoved(String key) { List removedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) { removedObjects.add(objectCache.getObject()); @@ -548,7 +548,7 @@ public class ObjectFilter { */ public List getRemoved(Class clazz, String key) { List removedObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) { if (objectCache.getObject().getClass() == clazz) { @@ -571,7 +571,7 @@ public class ObjectFilter { */ public List getAll(String key) { List allObjects = new LinkedList(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getKey().equals(key)) { allObjects.add(objectCache.getObject()); @@ -590,7 +590,7 @@ public class ObjectFilter { */ public List> getCache(String key) { List> allCache = new LinkedList>(); - Collection> allObjs = cache.values(); + Collection> allObjs = this.cache.values(); for (ObjectCache objectCache : allObjs) { if (objectCache.getKey().equals(key)) { allCache.add(objectCache); @@ -605,26 +605,26 @@ public class ObjectFilter { * @return The set containing the keys of that have been added to the filter. */ public Set keySet() { - return keySet; + return this.keySet; } /** * Clear the cache. */ public void clearCache() { - cache.clear(); - keySet.clear(); + this.cache.clear(); + this.keySet.clear(); } /** * @return get a unique transaction ID */ public synchronized long dispenseID() { - id++; - if (id == Long.MAX_VALUE) { - logger.error("Rolling IDs of objectFilter back to 1. Hope this is fine."); - id = 1; + ObjectFilter.id++; + if (ObjectFilter.id == Long.MAX_VALUE) { + ObjectFilter.logger.error("Rolling IDs of objectFilter back to 1. Hope this is fine."); + ObjectFilter.id = 1; } - return id; + return ObjectFilter.id; } }