camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-7443: camel-printer to better find remote printer where forward/backward slashes do not care.
Date Thu, 28 Apr 2016 12:28:40 GMT
CAMEL-7443: camel-printer to better find remote printer where forward/backward slashes do not
care.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/49baf409
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/49baf409
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/49baf409

Branch: refs/heads/camel-2.16.x
Commit: 49baf4092aa559eab5ce3cbd31cd280e5512ecba
Parents: 54b3bf7
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Apr 28 14:27:55 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Apr 28 14:28:26 2016 +0200

----------------------------------------------------------------------
 .../camel/component/printer/PrinterProducer.java      | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/49baf409/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
index ee3239c..ea8fd99 100644
--- a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
+++ b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
@@ -17,7 +17,7 @@
 package org.apache.camel.component.printer;
 
 import java.io.InputStream;
-
+import java.util.Locale;
 import javax.print.DocFlavor;
 import javax.print.PrintException;
 import javax.print.PrintService;
@@ -121,7 +121,7 @@ public class PrinterProducer extends DefaultProducer {
                 // no hostname for localhost printers
                 name = config.getPrintername();
             } else {
-                name = "\\\\" + config.getHostname() + "\\" + config.getPrintername();
+                name = config.getHostname() + "/" + config.getPrintername();
                 if (config.getPrinterPrefix() != null) {
                     name = config.getPrinterPrefix() + name;
                 }
@@ -139,8 +139,16 @@ public class PrinterProducer extends DefaultProducer {
     
     private int findPrinter(PrintService[] services, String printer) {
         int position = -1;
+        // align slashes so we match / or \
+        printer = printer.toLowerCase(Locale.US);
+        printer = printer.replace('\\', '/');
         for (int i = 0; i < services.length; i++) {
-            if (services[i].getName().toLowerCase().endsWith(printer.toLowerCase())) {
+            String printerName = services[i].getName();
+            log.debug("Printer service printer name: {}", printerName);
+            // align slashes so we match / or \
+            printerName = printerName.toLowerCase(Locale.US);
+            printerName = printerName.replace('\\', '/');
+            if (printerName.endsWith(printer)) {
                 position = i;
                 break;
             }


Mime
View raw message