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