--- /dev/null
+/**\r
+ * Copyright (C) 2003 <a href="http://www.lohndirekt.de/">lohndirekt.de</a>\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ * \r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * \r
+ */package de.lohndirekt.print;\r
+\r
+import java.io.IOException;\r
+import java.util.logging.Level;\r
+\r
+import javax.print.CancelablePrintJob;\r
+import javax.print.PrintException;\r
+import javax.print.attribute.AttributeSet;\r
+import javax.print.attribute.HashAttributeSet;\r
+import javax.print.event.PrintJobEvent;\r
+\r
+import de.lohndirekt.print.attribute.IppStatus;\r
+import de.lohndirekt.print.attribute.ipp.printerdesc.supported.OperationsSupported;\r
+\r
+/**\r
+ * @author bpusch\r
+ *\r
+ */\r
+class CancelableJob extends Job implements CancelablePrintJob{\r
+ \r
+ \r
+ /**\r
+ * @param service\r
+ */\r
+ public CancelableJob(IppPrintService service) {\r
+ super(service);\r
+ }\r
+ \r
+ public void cancel() throws PrintException {\r
+ if (!ok) {\r
+ throw new PrintException("Job has not been sent. Cannot be canceled");\r
+ }\r
+ AttributeSet operationAttributes = new HashAttributeSet();\r
+ operationAttributes.add(this.jobUri);\r
+ try {\r
+ IppResponse response =\r
+ sendRequest(\r
+ OperationsSupported.CANCEL_JOB,\r
+ operationAttributes);\r
+ if (response.getStatus().equals(IppStatus.SUCCESSFUL_OK)\r
+ || response.getStatus().equals(\r
+ IppStatus.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES)\r
+ || response.getStatus().equals(\r
+ IppStatus.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES)) {\r
+ notifyJobListeners(PrintJobEvent.JOB_CANCELED);\r
+ }\r
+ } catch (IOException e) {\r
+ log.log(Level.SEVERE, e.getMessage(), e);\r
+ throw new PrintException("Cannot be canceled: IOException", e);\r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+\r
+}\r