View Javadoc
1   /**
2    * Copyright 2010-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.util.main;
17  
18  import org.kuali.common.util.Assert;
19  import org.kuali.common.util.LocationUtils;
20  import org.kuali.common.util.execute.Executable;
21  
22  /**
23   * Validate <code>String[] args</code> is not null, contains at least one non-blank value and points to a location that exists.
24   */
25  public final class ValidatePropertiesLocationExecutable implements Executable {
26  
27  	public ValidatePropertiesLocationExecutable(MainContext context, String message) {
28  		Assert.noNulls(context);
29  		Assert.noBlanks(message);
30  		this.context = context;
31  		this.message = message;
32  	}
33  
34  	private final String message;
35  	private final MainContext context;
36  
37  	@Override
38  	public void execute() {
39  		String[] args = context.getArgs();
40  		Assert.notNull(args, message);
41  		Assert.isTrue(args.length > 0, message);
42  		String location = args[0];
43  		Assert.noBlanks(message, location);
44  		LocationUtils.validateLocation(location, message);
45  	}
46  
47  	public String getMessage() {
48  		return message;
49  	}
50  
51  	public MainContext getContext() {
52  		return context;
53  	}
54  
55  }