View Javadoc
1   package org.kuali.common.util.main;
2   
3   import org.kuali.common.util.Assert;
4   import org.kuali.common.util.LocationUtils;
5   import org.kuali.common.util.execute.Executable;
6   
7   /**
8    * Validate <code>String[] args</code> is not null, contains at least one non-blank value and points to a location that exists.
9    */
10  public final class ValidatePropertiesLocationExecutable implements Executable {
11  
12  	public ValidatePropertiesLocationExecutable(MainContext context, String message) {
13  		Assert.noNulls(context);
14  		Assert.noBlanks(message);
15  		this.context = context;
16  		this.message = message;
17  	}
18  
19  	private final String message;
20  	private final MainContext context;
21  
22  	@Override
23  	public void execute() {
24  		String[] args = context.getArgs();
25  		Assert.notNull(args, message);
26  		Assert.isTrue(args.length > 0, message);
27  		String location = args[0];
28  		Assert.noBlanks(message, location);
29  		LocationUtils.validateLocation(location, message);
30  	}
31  
32  	public String getMessage() {
33  		return message;
34  	}
35  
36  	public MainContext getContext() {
37  		return context;
38  	}
39  
40  }