1254 if (isSupportedValue(destination, attributes)) { 1255 try { 1256 // Old code (new File(destination.getURI())).getPath() 1257 // would generate a "URI is not hierarchical" IAE 1258 // for "file:out.prn" so we use getSchemeSpecificPart instead 1259 destinationAttr = "" + new File(destination.getURI(). 1260 getSchemeSpecificPart()); 1261 } catch (Exception e) { // paranoid exception 1262 Destination defaultDest = (Destination)service. 1263 getDefaultAttributeValue(Destination.class); 1264 if (defaultDest != null) { 1265 destinationAttr = "" + new File(defaultDest.getURI(). 1266 getSchemeSpecificPart()); 1267 } 1268 } 1269 } 1270 1271 JobSheets jobSheets = (JobSheets)attributes.get(JobSheets.class); 1272 if (jobSheets != null) { 1273 noJobSheet = jobSheets == JobSheets.NONE; 1274 } else { 1275 JobSheets js = (JobSheets)getPrintService(). 1276 getDefaultAttributeValue(JobSheets.class); 1277 if (js != null && js.equals(JobSheets.NONE)) { 1278 noJobSheet = true; 1279 } 1280 } 1281 1282 JobName jobName = (JobName)attributes.get(JobName.class); 1283 if (isSupportedValue(jobName, attributes) || 1284 (!fidelity && jobName != null)) { 1285 jobNameAttr = jobName.getValue(); 1286 setJobName(jobNameAttr); 1287 } else { 1288 jobNameAttr = getJobName(); 1289 } 1290 1291 RequestingUserName userName = 1292 (RequestingUserName)attributes.get(RequestingUserName.class); 1293 if (isSupportedValue(userName, attributes) || 1294 (!fidelity && userName != null)) { 1295 userNameAttr = userName.getValue(); 1296 } else { 1297 try { 1298 userNameAttr = getUserName(); 1299 } catch (SecurityException e) { 1459 } 1460 1461 // Check the list of services. This service may have been 1462 // deleted already 1463 PrinterState prnState = psvc.getAttribute(PrinterState.class); 1464 if (prnState == PrinterState.STOPPED) { 1465 PrinterStateReasons prnStateReasons = 1466 psvc.getAttribute(PrinterStateReasons.class); 1467 if ((prnStateReasons != null) && 1468 (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN))) 1469 { 1470 throw new PrinterException("PrintService is no longer available."); 1471 } 1472 } 1473 1474 if ((psvc.getAttribute(PrinterIsAcceptingJobs.class)) == 1475 PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) { 1476 throw new PrinterException("Printer is not accepting job."); 1477 } 1478 1479 if ((psvc instanceof SunPrinterJobService) && 1480 ((SunPrinterJobService)psvc).usesClass(getClass())) { 1481 setAttributes(attributes); 1482 // throw exception for invalid destination 1483 if (destinationAttr != null) { 1484 validateDestination(destinationAttr); 1485 } 1486 } else { 1487 spoolToService(psvc, attributes); 1488 return; 1489 } 1490 /* We need to make sure that the collation and copies 1491 * settings are initialised */ 1492 initPrinter(); 1493 1494 int numCollatedCopies = getCollatedCopies(); 1495 int numNonCollatedCopies = getNoncollatedCopies(); 1496 debug_println("getCollatedCopies() "+numCollatedCopies 1497 + " getNoncollatedCopies() "+ numNonCollatedCopies); 1498 | 1254 if (isSupportedValue(destination, attributes)) { 1255 try { 1256 // Old code (new File(destination.getURI())).getPath() 1257 // would generate a "URI is not hierarchical" IAE 1258 // for "file:out.prn" so we use getSchemeSpecificPart instead 1259 destinationAttr = "" + new File(destination.getURI(). 1260 getSchemeSpecificPart()); 1261 } catch (Exception e) { // paranoid exception 1262 Destination defaultDest = (Destination)service. 1263 getDefaultAttributeValue(Destination.class); 1264 if (defaultDest != null) { 1265 destinationAttr = "" + new File(defaultDest.getURI(). 1266 getSchemeSpecificPart()); 1267 } 1268 } 1269 } 1270 1271 JobSheets jobSheets = (JobSheets)attributes.get(JobSheets.class); 1272 if (jobSheets != null) { 1273 noJobSheet = jobSheets == JobSheets.NONE; 1274 } 1275 1276 JobName jobName = (JobName)attributes.get(JobName.class); 1277 if (isSupportedValue(jobName, attributes) || 1278 (!fidelity && jobName != null)) { 1279 jobNameAttr = jobName.getValue(); 1280 setJobName(jobNameAttr); 1281 } else { 1282 jobNameAttr = getJobName(); 1283 } 1284 1285 RequestingUserName userName = 1286 (RequestingUserName)attributes.get(RequestingUserName.class); 1287 if (isSupportedValue(userName, attributes) || 1288 (!fidelity && userName != null)) { 1289 userNameAttr = userName.getValue(); 1290 } else { 1291 try { 1292 userNameAttr = getUserName(); 1293 } catch (SecurityException e) { 1453 } 1454 1455 // Check the list of services. This service may have been 1456 // deleted already 1457 PrinterState prnState = psvc.getAttribute(PrinterState.class); 1458 if (prnState == PrinterState.STOPPED) { 1459 PrinterStateReasons prnStateReasons = 1460 psvc.getAttribute(PrinterStateReasons.class); 1461 if ((prnStateReasons != null) && 1462 (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN))) 1463 { 1464 throw new PrinterException("PrintService is no longer available."); 1465 } 1466 } 1467 1468 if ((psvc.getAttribute(PrinterIsAcceptingJobs.class)) == 1469 PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) { 1470 throw new PrinterException("Printer is not accepting job."); 1471 } 1472 1473 /* 1474 * Check the default job-sheet value on underlying platform. If IPP 1475 * reports job-sheets=none, then honour that and modify noJobSheet since 1476 * by default, noJobSheet is false which mean jdk will print banner page. 1477 * This is because if "attributes" is null (if user directly calls print() 1478 * without specifying any attributes and without showing printdialog) then 1479 * setAttribute will return without changing noJobSheet value. 1480 * Also, we do this before setAttributes() call so as to allow the user 1481 * to override this via explicitly adding JobSheets attributes to 1482 * PrintRequestAttributeSet while calling print(attributes) 1483 */ 1484 JobSheets js = (JobSheets)psvc.getDefaultAttributeValue(JobSheets.class); 1485 if (js != null && js.equals(JobSheets.NONE)) { 1486 noJobSheet = true; 1487 } 1488 1489 if ((psvc instanceof SunPrinterJobService) && 1490 ((SunPrinterJobService)psvc).usesClass(getClass())) { 1491 setAttributes(attributes); 1492 // throw exception for invalid destination 1493 if (destinationAttr != null) { 1494 validateDestination(destinationAttr); 1495 } 1496 } else { 1497 spoolToService(psvc, attributes); 1498 return; 1499 } 1500 /* We need to make sure that the collation and copies 1501 * settings are initialised */ 1502 initPrinter(); 1503 1504 int numCollatedCopies = getCollatedCopies(); 1505 int numNonCollatedCopies = getNoncollatedCopies(); 1506 debug_println("getCollatedCopies() "+numCollatedCopies 1507 + " getNoncollatedCopies() "+ numNonCollatedCopies); 1508 |