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 * 034 */ 035public class SvnChangeSet extends ChangeSet { 036 037 private static final long serialVersionUID = -4454710577968060741L; 038 039 public SvnChangeSet() { 040 super(); 041 } 042 043 public SvnChangeSet(String strDate, String userDatePattern, String comment, String author, List<ChangeFile> files) { 044 super(strDate, userDatePattern, comment, author, files); 045 } 046 047 public SvnChangeSet(Date date, String comment, String author, List<ChangeFile> files) { 048 super(date, comment, author, files); 049 } 050 051 /** {@inheritDoc} */ 052 public boolean containsFilename(String filename, ScmProviderRepository repository) { 053 SvnScmProviderRepository repo = (SvnScmProviderRepository) repository; 054 055 String url = repo.getUrl(); 056 057 if (!url.endsWith("/")) { 058 url += "/"; 059 } 060 061 String currentFile = url + StringUtils.replace(filename, "\\", "/"); 062 063 if (getFiles() != null) { 064 for (Iterator<ChangeFile> i = getFiles().iterator(); i.hasNext(); ) { 065 ChangeFile file = i.next(); 066 067 if (currentFile.endsWith(StringUtils.replace(file.getName(), "\\", "/"))) { 068 return true; 069 } 070 } 071 } 072 073 return false; 074 } 075}