servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r557640 - in /incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src: main/java/org/apache/servicemix/ftp/ test/java/org/apache/servicemix/ftp/
Date Thu, 19 Jul 2007 14:28:22 GMT
Author: gertv
Date: Thu Jul 19 07:28:21 2007
New Revision: 557640

URL: http://svn.apache.org/viewvc?view=rev&rev=557640
Log:
Fix for SM-932: PMD/CheckStyle for servicemix-ftp

Modified:
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/ConnectionRefusedException.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FTPClientPool.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpComponent.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpSenderEndpoint.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/SocketClientPoolSupport.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/PollDirectoryTest.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/SpringComponentTest.java

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/ConnectionRefusedException.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/ConnectionRefusedException.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/ConnectionRefusedException.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/ConnectionRefusedException.java
Thu Jul 19 07:28:21 2007
@@ -24,7 +24,8 @@
  * @version $Revision: 426415 $
  */
 public class ConnectionRefusedException extends MessagingException {
-    private int code;
+    
+    private final int code;
 
     public ConnectionRefusedException(int code) {
         super("Connection refused with return code: " + code);

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FTPClientPool.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FTPClientPool.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FTPClientPool.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FTPClientPool.java
Thu Jul 19 07:28:21 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.servicemix.ftp;
 
-import org.apache.commons.net.ftp.FTPClientConfig;
+import java.io.IOException;
+
+import org.apache.commons.net.SocketClient;
+import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPReply;
-import org.apache.commons.net.ftp.FTP;
-import org.apache.commons.net.SocketClient;
-
-import java.io.IOException;
 
 /**
  * A pool of FTP clients for
@@ -39,7 +39,7 @@
     private String username;
     private String password;
     private boolean binaryMode = true;
-    private boolean passiveMode = false;
+    private boolean passiveMode;
     private FTPClientConfig config;
     private String controlEncoding = DEFAULT_CONTROL_ENCODING;
     private int dataTimeout = DEFAULT_DATA_TIMEOUT;
@@ -48,8 +48,7 @@
         FTPClient client = (FTPClient) object;
         try {
             return client.sendNoOp();
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             throw new RuntimeException("Failed to validate client: " + e, e);
         }
     }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpComponent.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpComponent.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpComponent.java
Thu Jul 19 07:28:21 2007
@@ -50,7 +50,7 @@
     }
 
     protected Class[] getEndpointClasses() {
-        return new Class[] { FtpPollerEndpoint.class, FtpSenderEndpoint.class };
+        return new Class[] {FtpPollerEndpoint.class, FtpSenderEndpoint.class};
     }
 
     protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
Thu Jul 19 07:28:21 2007
@@ -1,5 +1,4 @@
-/**
- *
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -7,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -55,7 +54,7 @@
 public class FtpPollerEndpoint extends PollingEndpoint implements FtpEndpointType {
 
     private FTPClientPool clientPool;
-    private FileFilter filter;
+    private FileFilter filter;  
     private boolean deleteFile = true;
     private boolean recursive = true;
     private FileMarshaler marshaler = new DefaultFileMarshaler();
@@ -200,8 +199,7 @@
         try {
             logger.debug("Polling directory " + fileOrDirectory);
             pollFileOrDirectory(ftp, fileOrDirectory, isRecursive());
-        }
-        finally {
+        } finally {
             returnClient(ftp);
         }
     }
@@ -210,7 +208,7 @@
         FTPFile[] files = ftp.listFiles(fileOrDirectory);
         for (int i = 0; i < files.length; i++) {
             String name = files[i].getName();
-            if (name.equals(".") || name.equals("..")) {
+            if (".".equals(name) || "..".equals(name)) {
                 continue; // ignore "." and ".."
             }
             String file = fileOrDirectory + "/" + name;
@@ -244,8 +242,7 @@
                     boolean unlock = true;
                     try {
                         unlock = processFileAndDelete(file);
-                    }
-                    finally {
+                    } finally {
                         if (unlock) {
                             lock.unlock();
                         }
@@ -274,8 +271,7 @@
                 }
                 unlock = true;
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             logger.error("Failed to process file: " + file + ". Reason: " + e, e);
         } finally {
             returnClient(ftp);
@@ -320,8 +316,7 @@
     protected FTPClient borrowClient() throws JBIException {
         try {
             return (FTPClient) getClientPool().borrowClient();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new JBIException(e);
         }
     }
@@ -330,8 +325,7 @@
         if (client != null) {
             try {
                 getClientPool().returnClient(client);
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 logger.error("Failed to return client to pool: " + e, e);
             }
         }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpSenderEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpSenderEndpoint.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpSenderEndpoint.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpSenderEndpoint.java
Thu Jul 19 07:28:21 2007
@@ -42,7 +42,7 @@
     private FTPClientPool clientPool;
     private FileMarshaler marshaler = new DefaultFileMarshaler();
     private String uniqueFileName = "ServiceMix";
-    private boolean overwrite = false;
+    private boolean overwrite;
     private URI uri;
     private String uploadSuffix;
 
@@ -161,12 +161,10 @@
             if (name == null) {
                 if (uniqueFileName != null) {
                     out = client.storeUniqueFileStream(uniqueFileName);
-                }
-                else {
+                } else {
                     out = client.storeUniqueFileStream();
                 }
-            }
-            else {
+            } else {
                 if (client.listFiles(name).length > 0) {
                     if (overwrite) {
                         client.deleteFile(name);
@@ -182,19 +180,15 @@
                 throw new IOException("No output stream available for output name: " + uploadName
+ ". Maybe the file already exists?");
             }
             marshaler.writeMessage(exchange, message, out, uploadName);
-        }
-        finally {
+        } finally {
             if (out != null) {
                 try {
                     out.close();
                     client.completePendingCommand();
-                    if (name != null && !name.equals(uploadName)) {
-                        if (!client.rename(uploadName, name)) {
-                            throw new IOException("File " + uploadName + " could not be renamed
to " + name);
-                        }
+                    if (name != null && !name.equals(uploadName) && !client.rename(uploadName,
name)) {
+                        throw new IOException("File " + uploadName + " could not be renamed
to " + name);
                     }
-                }
-                catch (IOException e) {
+                } catch (IOException e) {
                     logger.error("Caught exception while closing stream on error: " + e,
e);
                 }
             }
@@ -211,8 +205,7 @@
     protected FTPClient borrowClient() throws JBIException {
         try {
             return (FTPClient) getClientPool().borrowClient();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new JBIException(e);
         }
     }
@@ -221,8 +214,7 @@
         if (client != null) {
             try {
                 getClientPool().returnClient(client);
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 logger.error("Failed to return client to pool: " + e, e);
             }
         }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/SocketClientPoolSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/SocketClientPoolSupport.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/SocketClientPoolSupport.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/SocketClientPoolSupport.java
Thu Jul 19 07:28:21 2007
@@ -16,16 +16,16 @@
  */
 package org.apache.servicemix.ftp;
 
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.DisposableBean;
-import org.apache.commons.pool.PoolableObjectFactory;
+import java.io.IOException;
+import java.net.InetAddress;
+import javax.jbi.JBIException;
+
+import org.apache.commons.net.SocketClient;
 import org.apache.commons.pool.ObjectPool;
+import org.apache.commons.pool.PoolableObjectFactory;
 import org.apache.commons.pool.impl.GenericObjectPool;
-import org.apache.commons.net.SocketClient;
-
-import javax.jbi.JBIException;
-import java.net.InetAddress;
-import java.io.IOException;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
 
 /**
  * A pool of {@link org.apache.commons.net.SocketClient} instances from the
@@ -148,26 +148,20 @@
         if (host != null) {
             if (localAddress != null) {
                 client.connect(host, port, localAddress, localPort);
-            }
-            else if (port >= 0) {
+            } else if (port >= 0) {
                 client.connect(host, port);
-            }
-            else {
+            } else {
                 client.connect(host);
             }
-        }
-        else if (address != null) {
+        } else if (address != null) {
             if (localAddress != null) {
                 client.connect(address, port, localAddress, localPort);
-            }
-            else if (port >= 0) {
+            } else if (port >= 0) {
                 client.connect(address, port);
-            }
-            else {
+            } else {
                 client.connect(address);
             }
-        }
-        else {
+        } else {
             throw new JBIException("You must configure the address or host property");
         }
     }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
Thu Jul 19 07:28:21 2007
@@ -51,12 +51,10 @@
         if (me.getStatus() == ExchangeStatus.ERROR) {
             if (me.getError() != null) {
                 throw me.getError();
-            }
-            else {
+            } else {
                 fail("Received ERROR status");
             }
-        }
-        else if (me.getFault() != null) {
+        } else if (me.getFault() != null) {
             fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
         }
     }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/PollDirectoryTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/PollDirectoryTest.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/PollDirectoryTest.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/PollDirectoryTest.java
Thu Jul 19 07:28:21 2007
@@ -1,5 +1,4 @@
-/**
- *
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -7,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,12 +32,12 @@
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
 public class PollDirectoryTest extends SpringTestSupport {
+    private static final int NUMBER = 100;
+    private static final int SIZE = 100;
+
     protected String directoryName = "target/pollDirectory";
     protected String dynamicURI = "file:" + directoryName;
 
-    private int NUMBER = 100;
-    private int SIZE = 100;
-
     public void testSendToWriterSoItCanBePolled() throws Exception {
         // now lets make a request on this endpoint
         DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
@@ -68,12 +67,10 @@
         if (me.getStatus() == ExchangeStatus.ERROR) {
             if (me.getError() != null) {
                 throw me.getError();
-            }
-            else {
+            } else {
                 fail("Received ERROR status");
             }
-        }
-        else if (me.getFault() != null) {
+        } else if (me.getFault() != null) {
             fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
         }
     }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/SpringComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/SpringComponentTest.java?view=diff&rev=557640&r1=557639&r2=557640
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/SpringComponentTest.java
(original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/SpringComponentTest.java
Thu Jul 19 07:28:21 2007
@@ -16,23 +16,23 @@
  */
 package org.apache.servicemix.ftp;
 
-import org.apache.servicemix.tck.SpringTestSupport;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.components.util.DefaultFileMarshaler;
-import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.xml.namespace.QName;
-
 public class SpringComponentTest extends SpringTestSupport {
 
-    private int NUMBER = 10;
+    private static final int NUMBER = 10;
 
     public void testSendingToStaticEndpoint() throws Exception {
         for (int i = 0; i < NUMBER; i++) {



Mime
View raw message