View Javadoc

1   /**
2    * Copyright 2010-2012 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.BaseCase;
20  
21  public class JavaxServletOnlyBaseCase 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  		boolean test4 = !prefix.equals("external/") && !prefix.equals("external/javax/") && !prefix.startsWith("external/javax/servlet/");
31  		return test1 || test2 || test3 || test4;
32  	}
33  
34  	public boolean endsWithVersionNumber(String prefix, String delimiter) {
35  		String[] tokens = prefix.split(delimiter);
36  		String lastToken = tokens[tokens.length - 1];
37  		String firstChar = lastToken.substring(0, 1);
38  		return StringUtils.isNumeric(firstChar);
39  	}
40  
41  	public boolean endsWithToken(String prefix, String delimiter, String token) {
42  		return prefix.endsWith(delimiter + token + delimiter);
43  	}
44  
45  	public String getDelimiter() {
46  		return delimiter;
47  	}
48  
49  	public void setDelimiter(String delimiter) {
50  		this.delimiter = delimiter;
51  	}
52  
53  	public String getToken() {
54  		return token;
55  	}
56  
57  	public void setToken(String token) {
58  		this.token = token;
59  	}
60  
61  }