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.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
25  
26  import java.io.File;
27  import java.util.List;
28  
29  /**
30   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
31   * @author Olivier Lamy
32   *
33   */
34  public class SvnCheckInConsumer
35      extends AbstractFileCheckingConsumer
36  {
37      private static final String SENDING_TOKEN = "Sending        ";
38  
39      private static final String ADDING_TOKEN = "Adding         ";
40  
41      private static final String ADDING_BIN_TOKEN = "Adding  (bin)  ";
42  
43      private static final String DELETING_TOKEN = "Deleting       ";
44  
45      private static final String TRANSMITTING_TOKEN = "Transmitting file data";
46  
47      private static final String COMMITTED_REVISION_TOKEN = "Committed revision";
48  
49      // ----------------------------------------------------------------------
50      //
51      // ----------------------------------------------------------------------
52  
53      public SvnCheckInConsumer( File workingDirectory )
54      {
55          super( workingDirectory );
56      }
57  
58      // ----------------------------------------------------------------------
59      // StreamConsumer Implementation
60      // ----------------------------------------------------------------------
61  
62      /** {@inheritDoc} */
63      protected void parseLine( String line )
64      {
65          String file;
66  
67          if ( line.startsWith( COMMITTED_REVISION_TOKEN ) )
68          {
69              String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 );
70  
71              revision = parseInt( revisionString );
72  
73              return;
74          }
75          else if ( line.startsWith( SENDING_TOKEN ) )
76          {
77              file = line.substring( SENDING_TOKEN.length() );
78          }
79          else if ( line.startsWith( ADDING_TOKEN ) )
80          {
81              file = line.substring( ADDING_TOKEN.length() );
82          }
83          else if ( line.startsWith( ADDING_BIN_TOKEN ) )
84          {
85              file = line.substring( ADDING_BIN_TOKEN.length() );
86          }
87          else if ( line.startsWith( DELETING_TOKEN ) )
88          {
89              file = line.substring( DELETING_TOKEN.length() );
90          }
91          else if ( line.startsWith( TRANSMITTING_TOKEN ) )
92          {
93              // ignore
94              return;
95          }
96          else
97          {
98              if ( logger.isInfoEnabled() )
99              {
100                 logger.info( "Unknown line: '" + line + "'" );
101             }
102 
103             return;
104         }
105 
106         addFile( new ScmFile( file, ScmFileStatus.CHECKED_IN ) );
107     }
108 
109     public List<ScmFile> getCheckedInFiles()
110     {
111         return getFiles();
112     }
113 }