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