Author: ritchiem
Date: Thu Jul 22 14:21:05 2010
New Revision: 966677

URL: http://svn.apache.org/viewvc?rev=966677&view=rev
Log:
QPID-2739 : Updated deleteFile to add the backupFilesToPath for delete requests 
if it is set.

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java?rev=966677&r1=966676&r2=966677&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
 Thu Jul 22 14:21:05 2010
@@ -674,10 +674,43 @@ public class QpidCompositeRollingAppende
         }
     }
 
-    /** Delete's the specified file if it exists */
-    protected void deleteFile(String fileName)
+    /**
+     * Delete the given file that is prepended with the relative path to the 
log
+     * directory.
+     *
+     * Compress is enabled check for file with COMPRESS_EXTENSION(.gz)
+     *
+     * if backupFilesToPath is set then check in this directory not the
+     * main log directory.
+     */
+    protected void deleteFile(String relativeFileName)
     {
-        File file = compress ? new File(fileName + COMPRESS_EXTENSION) : new 
File(fileName);
+        String fileName="";
+        // If we have configured a backup location then we should look in there
+        // for the file we are trying to delete
+        if (backupFilesToPath != null)
+        {
+            int index = relativeFileName.lastIndexOf(File.separator);
+            if (index != -1)
+            {
+                fileName = backupFilesToPath + File.separator
+                           + relativeFileName.substring(index);
+            }
+            else
+            {
+                fileName = relativeFileName;
+            }
+        }
+
+        // If we are compressing the at the extension
+        if (compress)
+        {
+            fileName += COMPRESS_EXTENSION;
+        }
+
+
+        File file = new File(fileName);
+
         if (file.exists())
         {
             file.delete();



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to