KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > response > SetStickyResponse


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.cvsclient.response;
21
22 import java.io.*;
23
24 import org.netbeans.lib.cvsclient.util.*;
25
26 /**
27  * Handles the Set-sticky response.
28  * @author Milos Kleint
29  */

30
31 class SetStickyResponse implements Response {
32
33     /**
34      * Process the data for the response.
35      * @param dis the data inputstream allowing the client to read the server's
36      * response. Note that the actual response name has already been read
37      * and the input stream is positioned just before the first argument, if
38      * any.
39      */

40     public void process(LoggedDataInputStream dis, ResponseServices services)
41             throws ResponseException {
42         PrintWriter w = null;
43         try {
44             String JavaDoc localPath = dis.readLine();
45
46             String JavaDoc repositoryPath = dis.readLine();
47             String JavaDoc tag = dis.readLine();
48             //System.err.println("Repository path is: " + repositoryPath);
49
// services.updateAdminData(localPath, repositoryPath, null);
50
String JavaDoc absPath = services.convertPathname(localPath, repositoryPath);
51             
52             if (services.getGlobalOptions().isExcluded(new File(absPath))) {
53                 return;
54             }
55             
56             absPath = absPath + "/CVS"; //NOI18N
57
File absFile = new File(absPath);
58             if (absFile.exists()) {
59                 File tagFile = new File(absPath, "Tag"); //NOI18N
60
if ("THEAD".equals(tag) | "NHEAD".equals(tag) ) { //NOI18N
61
tagFile.delete();
62                 } else {
63                     w = new PrintWriter(
64                             new BufferedWriter(new FileWriter(tagFile)));
65                     // we write out the sticky tag/date
66
w.println(tag);
67                 }
68             }
69         }
70         catch (IOException e) {
71             throw new ResponseException(e);
72         } finally {
73             if (w != null) {
74                 w.close();
75             }
76         }
77     }
78
79     /**
80      * Is this a terminal response, i.e. should reading of responses stop
81      * after this response. This is true for responses such as OK or
82      * an error response
83      */

84     public boolean isTerminalResponse() {
85         return false;
86     }
87 }
88
Popular Tags