View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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 KualiMavenBucketBaseCase implements BaseCase {
22  
23  	String delimiter;
24  	String token;
25  
26  	public boolean isBaseCase(String prefix) {
27  		boolean baseCase1 = endsWithVersionNumber(prefix, delimiter);
28  		boolean baseCase2 = endsWithToken(prefix, delimiter, token);
29  		return baseCase1 || baseCase2;
30  	}
31  
32  	public boolean endsWithVersionNumber(String prefix, String delimiter) {
33  		String[] tokens = prefix.split(delimiter);
34  		String lastToken = tokens[tokens.length - 1];
35  		String firstChar = lastToken.substring(0, 1);
36  		return StringUtils.isNumeric(firstChar);
37  	}
38  
39  	public boolean endsWithToken(String prefix, String delimiter, String token) {
40  		return prefix.endsWith(delimiter + token + delimiter);
41  	}
42  
43  	public String getDelimiter() {
44  		return delimiter;
45  	}
46  
47  	public void setDelimiter(String delimiter) {
48  		this.delimiter = delimiter;
49  	}
50  
51  	public String getToken() {
52  		return token;
53  	}
54  
55  	public void setToken(String token) {
56  		this.token = token;
57  	}
58  
59  }