Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE01619CD6 for ; Thu, 28 Apr 2016 12:28:57 +0000 (UTC) Received: (qmail 6328 invoked by uid 500); 28 Apr 2016 12:28:57 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 6280 invoked by uid 500); 28 Apr 2016 12:28:57 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 6271 invoked by uid 99); 28 Apr 2016 12:28:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Apr 2016 12:28:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 79D07DFDCC; Thu, 28 Apr 2016 12:28:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: 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:57 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 1fb67d6b8 -> ef74ad512 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/ef74ad51 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ef74ad51 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ef74ad51 Branch: refs/heads/master Commit: ef74ad512a44f94f0ebe58670419c5d914cadfb3 Parents: 1fb67d6 Author: Claus Ibsen Authored: Thu Apr 28 14:27:55 2016 +0200 Committer: Claus Ibsen Committed: Thu Apr 28 14:28:50 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/ef74ad51/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; }