use of javax.print.attribute.standard.PrinterURI in project jdk8u_jdk by JetBrains.
the class UnixPrintServiceLookup method addPrintServiceToList.
private int addPrintServiceToList(ArrayList printerList, PrintService ps) {
int index = printerList.indexOf(ps);
// Check if PrintService with same name is already in the list.
if (CUPSPrinter.isCupsRunning() && index != -1) {
// Bug in Linux: Duplicate entry of a remote printer
// and treats it as local printer but it is returning wrong
// information when queried using IPP. Workaround is to remove it.
// Even CUPS ignores these entries as shown in lpstat or using
// their web configuration.
PrinterURI uri = (PrinterURI) ps.getAttribute(PrinterURI.class);
if (uri.getURI().getHost().equals("localhost")) {
IPPPrintService.debug_println(debugPrefix + "duplicate PrintService, ignoring the new local printer: " + ps);
// Do not add this.
return index;
}
PrintService oldPS = (PrintService) (printerList.get(index));
uri = (PrinterURI) oldPS.getAttribute(PrinterURI.class);
if (uri.getURI().getHost().equals("localhost")) {
IPPPrintService.debug_println(debugPrefix + "duplicate PrintService, removing existing local printer: " + oldPS);
printerList.remove(oldPS);
} else {
return index;
}
}
printerList.add(ps);
return (printerList.size() - 1);
}
Aggregations