001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.lib.cvsclient.response;
043:
044: import java.io.*;
045:
046: import org.netbeans.lib.cvsclient.util.*;
047:
048: /**
049: * Handles the Set-sticky response.
050: * @author Milos Kleint
051: */
052:
053: class SetStickyResponse implements Response {
054:
055: /**
056: * Process the data for the response.
057: * @param dis the data inputstream allowing the client to read the server's
058: * response. Note that the actual response name has already been read
059: * and the input stream is positioned just before the first argument, if
060: * any.
061: */
062: public void process(LoggedDataInputStream dis,
063: ResponseServices services) throws ResponseException {
064: PrintWriter w = null;
065: try {
066: String localPath = dis.readLine();
067:
068: String repositoryPath = dis.readLine();
069: String tag = dis.readLine();
070: //System.err.println("Repository path is: " + repositoryPath);
071: // services.updateAdminData(localPath, repositoryPath, null);
072: String absPath = services.convertPathname(localPath,
073: repositoryPath);
074:
075: if (services.getGlobalOptions().isExcluded(
076: new File(absPath))) {
077: return;
078: }
079:
080: absPath = absPath + "/CVS"; //NOI18N
081: File absFile = new File(absPath);
082: if (absFile.exists()) {
083: File tagFile = new File(absPath, "Tag"); //NOI18N
084: if ("THEAD".equals(tag) | "NHEAD".equals(tag)) { //NOI18N
085: tagFile.delete();
086: } else {
087: w = new PrintWriter(new BufferedWriter(
088: new FileWriter(tagFile)));
089: // we write out the sticky tag/date
090: w.println(tag);
091: }
092: }
093: } catch (IOException e) {
094: throw new ResponseException(e);
095: } finally {
096: if (w != null) {
097: w.close();
098: }
099: }
100: }
101:
102: /**
103: * Is this a terminal response, i.e. should reading of responses stop
104: * after this response. This is true for responses such as OK or
105: * an error response
106: */
107: public boolean isTerminalResponse() {
108: return false;
109: }
110: }
|