1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.aws.s3;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.common.aws.s3.monitor.BaseCase;
20
21 public class ExternalOnlyBaseCase implements BaseCase {
22
23 String delimiter;
24 String token;
25
26 public boolean isBaseCase(String prefix) {
27 boolean test1 = endsWithVersionNumber(prefix, delimiter);
28 boolean test2 = endsWithToken(prefix, delimiter, token);
29 boolean test3 = !prefix.startsWith("external/");
30 return test1 || test2 || test3;
31 }
32
33 public boolean endsWithVersionNumber(String prefix, String delimiter) {
34 String[] tokens = prefix.split(delimiter);
35 String lastToken = tokens[tokens.length - 1];
36 String firstChar = lastToken.substring(0, 1);
37 return StringUtils.isNumeric(firstChar);
38 }
39
40 public boolean endsWithToken(String prefix, String delimiter, String token) {
41 return prefix.endsWith(delimiter + token + delimiter);
42 }
43
44 public String getDelimiter() {
45 return delimiter;
46 }
47
48 public void setDelimiter(String delimiter) {
49 this.delimiter = delimiter;
50 }
51
52 public String getToken() {
53 return token;
54 }
55
56 public void setToken(String token) {
57 this.token = token;
58 }
59
60 }