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; 020 021import java.util.Date; 022import java.util.Iterator; 023import java.util.List; 024 025import org.apache.commons.lang3.StringUtils; 026import org.apache.maven.scm.ChangeFile; 027import org.apache.maven.scm.ChangeSet; 028import org.apache.maven.scm.provider.ScmProviderRepository; 029import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; 030 031/** 032 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 033 */ 034public class SvnChangeSet extends ChangeSet { 035 036 private static final long serialVersionUID = -4454710577968060741L; 037 038 public SvnChangeSet() { 039 super(); 040 } 041 042 public SvnChangeSet(String strDate, String userDatePattern, String comment, String author, List<ChangeFile> files) { 043 super(strDate, userDatePattern, comment, author, files); 044 } 045 046 public SvnChangeSet(Date date, String comment, String author, List<ChangeFile> files) { 047 super(date, comment, author, files); 048 } 049 050 /** 051 * {@inheritDoc} 052 */ 053 public boolean containsFilename(String filename, ScmProviderRepository repository) { 054 SvnScmProviderRepository repo = (SvnScmProviderRepository) repository; 055 056 String url = repo.getUrl(); 057 058 if (!url.endsWith("/")) { 059 url += "/"; 060 } 061 062 String currentFile = url + StringUtils.replace(filename, "\\", "/"); 063 064 if (getFiles() != null) { 065 for (Iterator<ChangeFile> i = getFiles().iterator(); i.hasNext(); ) { 066 ChangeFile file = i.next(); 067 068 if (currentFile.endsWith(StringUtils.replace(file.getName(), "\\", "/"))) { 069 return true; 070 } 071 } 072 } 073 074 return false; 075 } 076}