001package org.apache.maven.scm.provider.svn.svnexe.command.checkin; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.ScmFile; 023import org.apache.maven.scm.ScmFileStatus; 024import org.apache.maven.scm.log.ScmLogger; 025import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; 026 027import java.io.File; 028import java.util.List; 029 030/** 031 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> 032 * @author Olivier Lamy 033 * 034 */ 035public class SvnCheckInConsumer 036 extends AbstractFileCheckingConsumer 037{ 038 private static final String SENDING_TOKEN = "Sending "; 039 040 private static final String ADDING_TOKEN = "Adding "; 041 042 private static final String ADDING_BIN_TOKEN = "Adding (bin) "; 043 044 private static final String DELETING_TOKEN = "Deleting "; 045 046 private static final String TRANSMITTING_TOKEN = "Transmitting file data"; 047 048 private static final String COMMITTED_REVISION_TOKEN = "Committed revision"; 049 050 // ---------------------------------------------------------------------- 051 // 052 // ---------------------------------------------------------------------- 053 054 public SvnCheckInConsumer( ScmLogger logger, File workingDirectory ) 055 { 056 super( logger, workingDirectory ); 057 } 058 059 // ---------------------------------------------------------------------- 060 // StreamConsumer Implementation 061 // ---------------------------------------------------------------------- 062 063 /** {@inheritDoc} */ 064 protected void parseLine( String line ) 065 { 066 String file; 067 068 if ( line.startsWith( COMMITTED_REVISION_TOKEN ) ) 069 { 070 String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 ); 071 072 revision = parseInt( revisionString ); 073 074 return; 075 } 076 else if ( line.startsWith( SENDING_TOKEN ) ) 077 { 078 file = line.substring( SENDING_TOKEN.length() ); 079 } 080 else if ( line.startsWith( ADDING_TOKEN ) ) 081 { 082 file = line.substring( ADDING_TOKEN.length() ); 083 } 084 else if ( line.startsWith( ADDING_BIN_TOKEN ) ) 085 { 086 file = line.substring( ADDING_BIN_TOKEN.length() ); 087 } 088 else if ( line.startsWith( DELETING_TOKEN ) ) 089 { 090 file = line.substring( DELETING_TOKEN.length() ); 091 } 092 else if ( line.startsWith( TRANSMITTING_TOKEN ) ) 093 { 094 // ignore 095 return; 096 } 097 else 098 { 099 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}