View Javadoc

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