View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.provider.svn;
20  
21  import java.util.Date;
22  import java.util.Iterator;
23  import java.util.List;
24  
25  import org.apache.commons.lang3.StringUtils;
26  import org.apache.maven.scm.ChangeFile;
27  import org.apache.maven.scm.ChangeSet;
28  import org.apache.maven.scm.provider.ScmProviderRepository;
29  import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
30  
31  /**
32   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
33   *
34   */
35  public class SvnChangeSet extends ChangeSet {
36  
37      private static final long serialVersionUID = -4454710577968060741L;
38  
39      public SvnChangeSet() {
40          super();
41      }
42  
43      public SvnChangeSet(String strDate, String userDatePattern, String comment, String author, List<ChangeFile> files) {
44          super(strDate, userDatePattern, comment, author, files);
45      }
46  
47      public SvnChangeSet(Date date, String comment, String author, List<ChangeFile> files) {
48          super(date, comment, author, files);
49      }
50  
51      /** {@inheritDoc} */
52      public boolean containsFilename(String filename, ScmProviderRepository repository) {
53          SvnScmProviderRepository repo = (SvnScmProviderRepository) repository;
54  
55          String url = repo.getUrl();
56  
57          if (!url.endsWith("/")) {
58              url += "/";
59          }
60  
61          String currentFile = url + StringUtils.replace(filename, "\\", "/");
62  
63          if (getFiles() != null) {
64              for (Iterator<ChangeFile> i = getFiles().iterator(); i.hasNext(); ) {
65                  ChangeFile file = i.next();
66  
67                  if (currentFile.endsWith(StringUtils.replace(file.getName(), "\\", "/"))) {
68                      return true;
69                  }
70              }
71          }
72  
73          return false;
74      }
75  }