KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > vfs > webdav > DAVNotModified


1 /* ========================================================================== *
2  * Copyright (C) 2004-2005 Pier Fumagalli <http://www.betaversion.org/~pier/> *
3  * All rights reserved. *
4  * ========================================================================== *
5  * *
6  * Licensed under the Apache License, Version 2.0 (the "License"). You may *
7  * not use this file except in compliance with the License. You may obtain a *
8  * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
9  * *
10  * Unless required by applicable law or agreed to in writing, software *
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
13  * License for the specific language governing permissions and limitations *
14  * under the License. *
15  * *
16  * ========================================================================== */

17 package com.sslexplorer.vfs.webdav;
18
19 import java.io.IOException JavaDoc;
20
21 import com.sslexplorer.vfs.VFSResource;
22
23 /**
24  * <p>A simple {@link DAVException} encapsulating an
25  * <a HREF="http://www.rfc-editor.org/rfc/rfc2616.txt">HTTP</a> not modified
26  * response.</p>
27  *
28  * @author <a HREF="http://www.betaversion.org/~pier/">Pier Fumagalli</a>
29  */

30 public class DAVNotModified extends DAVException {
31
32     private VFSResource resource = null;
33
34     /**
35      * <p>Create a new {@link DAVNotModified} instance.</p>
36      */

37     public DAVNotModified(VFSResource resource) {
38         super(304, "Resource Not Modified");
39         this.resource = resource;
40     }
41
42     /**
43      * <p>Write the body of this {@link DAVNotModified} to the specified
44      * {@link DAVTransaction}'s output.</p>
45      */

46     public void write(DAVTransaction transaction)
47     throws IOException JavaDoc {
48         transaction.setStatus(this.getStatus());
49
50         /* Figure out what we're dealing with here */
51         String JavaDoc etag = resource.getEntityTag();
52         String JavaDoc lmod = DAVUtilities.format(resource.getLastModified());
53
54         /* Set the normal headers that are required for a GET */
55         if (etag != null) transaction.setHeader("ETag", etag);
56         if (lmod != null) transaction.setHeader("Last-Modified", lmod);
57     }
58 }
59
Popular Tags