1 package org.apache.continuum.purge.repository.utils;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.codehaus.plexus.util.SelectorUtils;
23
24 import java.util.Arrays;
25 import java.util.List;
26
27
28
29
30 public class FileTypes
31 {
32 private List<String> artifactFileTypePatterns;
33
34 private List<String> ignoredFileTypePatterns;
35
36 public static final List<String> DEFAULT_EXCLUSIONS = Arrays.asList( "**/maven-metadata.xml",
37 "**/maven-metadata-*.xml", "**/*.sha1",
38 "**/*.asc", "**/*.md5", "**/*.pgp" );
39
40 public List<String> getIgnoredFileTypePatterns()
41 {
42 if ( ignoredFileTypePatterns == null )
43 {
44 ignoredFileTypePatterns = DEFAULT_EXCLUSIONS;
45 }
46
47 return ignoredFileTypePatterns;
48 }
49
50 public List<String> getArtifactFileTypePatterns()
51 {
52 return artifactFileTypePatterns;
53 }
54
55 public synchronized boolean matchesArtifactPattern( String relativePath )
56 {
57
58 relativePath = relativePath.replace( '\\', '/' );
59
60 if ( artifactFileTypePatterns == null )
61 {
62 return false;
63 }
64
65 for ( String pattern : artifactFileTypePatterns )
66 {
67 if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
68 {
69
70 return true;
71 }
72 }
73
74
75 return false;
76 }
77
78 public boolean matchesDefaultExclusions( String relativePath )
79 {
80
81 relativePath = relativePath.replace( '\\', '/' );
82
83 for ( String pattern : DEFAULT_EXCLUSIONS )
84 {
85 if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
86 {
87
88 return true;
89 }
90 }
91
92
93 return false;
94 }
95 }