2 * Copyright (C) 2003 <a href="http://www.lohndirekt.de/">lohndirekt.de</a>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */package de
.lohndirekt
.print
;
20 import java
.io
.IOException
;
21 import java
.util
.logging
.Level
;
23 import javax
.print
.CancelablePrintJob
;
24 import javax
.print
.PrintException
;
25 import javax
.print
.attribute
.AttributeSet
;
26 import javax
.print
.attribute
.HashAttributeSet
;
27 import javax
.print
.event
.PrintJobEvent
;
29 import de
.lohndirekt
.print
.attribute
.IppStatus
;
30 import de
.lohndirekt
.print
.attribute
.ipp
.printerdesc
.supported
.OperationsSupported
;
36 class CancelableJob
extends Job
implements CancelablePrintJob
{
42 public CancelableJob(IppPrintService service
) {
46 public void cancel() throws PrintException
{
48 throw new PrintException("Job has not been sent. Cannot be canceled");
50 AttributeSet operationAttributes
= new HashAttributeSet();
51 operationAttributes
.add(this.jobUri
);
53 IppResponse response
=
55 OperationsSupported
.CANCEL_JOB
,
57 if (response
.getStatus().equals(IppStatus
.SUCCESSFUL_OK
)
58 || response
.getStatus().equals(
59 IppStatus
.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES
)
60 || response
.getStatus().equals(
61 IppStatus
.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES
)) {
62 notifyJobListeners(PrintJobEvent
.JOB_CANCELED
);
64 } catch (IOException e
) {
65 log
.log(Level
.SEVERE
, e
.getMessage(), e
);
66 throw new PrintException("Cannot be canceled: IOException", e
);