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  public class SvnChangeSet extends ChangeSet {
35  
36      private static final long serialVersionUID = -4454710577968060741L;
37  
38      public SvnChangeSet() {
39          super();
40      }
41  
42      public SvnChangeSet(String strDate, String userDatePattern, String comment, String author, List<ChangeFile> files) {
43          super(strDate, userDatePattern, comment, author, files);
44      }
45  
46      public SvnChangeSet(Date date, String comment, String author, List<ChangeFile> files) {
47          super(date, comment, author, files);
48      }
49  
50      /**
51       * {@inheritDoc}
52       */
53      public boolean containsFilename(String filename, ScmProviderRepository repository) {
54          SvnScmProviderRepository repo = (SvnScmProviderRepository) repository;
55  
56          String url = repo.getUrl();
57  
58          if (!url.endsWith("/")) {
59              url += "/";
60          }
61  
62          String currentFile = url + StringUtils.replace(filename, "\\", "/");
63  
64          if (getFiles() != null) {
65              for (Iterator<ChangeFile> i = getFiles().iterator(); i.hasNext(); ) {
66                  ChangeFile file = i.next();
67  
68                  if (currentFile.endsWith(StringUtils.replace(file.getName(), "\\", "/"))) {
69                      return true;
70                  }
71              }
72          }
73  
74          return false;
75      }
76  }