View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.provider.svn.svnexe.command.checkin;
20  
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.scm.ScmFile;
25  import org.apache.maven.scm.ScmFileStatus;
26  import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
27  
28  /**
29   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
30   * @author Olivier Lamy
31   */
32  public class SvnCheckInConsumer extends AbstractFileCheckingConsumer {
33      private static final String SENDING_TOKEN = "Sending        ";
34  
35      private static final String ADDING_TOKEN = "Adding         ";
36  
37      private static final String ADDING_BIN_TOKEN = "Adding  (bin)  ";
38  
39      private static final String DELETING_TOKEN = "Deleting       ";
40  
41      private static final String TRANSMITTING_TOKEN = "Transmitting file data";
42  
43      private static final String COMMITTED_REVISION_TOKEN = "Committed revision";
44  
45      // ----------------------------------------------------------------------
46      //
47      // ----------------------------------------------------------------------
48  
49      public SvnCheckInConsumer(File workingDirectory) {
50          super(workingDirectory);
51      }
52  
53      // ----------------------------------------------------------------------
54      // StreamConsumer Implementation
55      // ----------------------------------------------------------------------
56  
57      /**
58       * {@inheritDoc}
59       */
60      protected void parseLine(String line) {
61          String file;
62  
63          if (line.startsWith(COMMITTED_REVISION_TOKEN)) {
64              String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1);
65  
66              revision = parseInt(revisionString);
67  
68              return;
69          } else if (line.startsWith(SENDING_TOKEN)) {
70              file = line.substring(SENDING_TOKEN.length());
71          } else if (line.startsWith(ADDING_TOKEN)) {
72              file = line.substring(ADDING_TOKEN.length());
73          } else if (line.startsWith(ADDING_BIN_TOKEN)) {
74              file = line.substring(ADDING_BIN_TOKEN.length());
75          } else if (line.startsWith(DELETING_TOKEN)) {
76              file = line.substring(DELETING_TOKEN.length());
77          } else if (line.startsWith(TRANSMITTING_TOKEN)) {
78              // ignore
79              return;
80          } else {
81              if (logger.isInfoEnabled()) {
82                  logger.info("Unknown line: '" + line + "'");
83              }
84  
85              return;
86          }
87  
88          addFile(new ScmFile(file, ScmFileStatus.CHECKED_IN));
89      }
90  
91      public List<ScmFile> getCheckedInFiles() {
92          return getFiles();
93      }
94  }