001/** 002 * Copyright 2010-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.common.util.main; 017 018import org.kuali.common.util.Assert; 019import org.kuali.common.util.LocationUtils; 020import org.kuali.common.util.execute.Executable; 021 022/** 023 * Validate <code>String[] args</code> is not null, contains at least one non-blank value and points to a location that exists. 024 */ 025public final class ValidatePropertiesLocationExecutable implements Executable { 026 027 public ValidatePropertiesLocationExecutable(MainContext context, String message) { 028 Assert.noNulls(context); 029 Assert.noBlanks(message); 030 this.context = context; 031 this.message = message; 032 } 033 034 private final String message; 035 private final MainContext context; 036 037 @Override 038 public void execute() { 039 String[] args = context.getArgs(); 040 Assert.notNull(args, message); 041 Assert.isTrue(args.length > 0, message); 042 String location = args[0]; 043 Assert.noBlanks(message, location); 044 LocationUtils.validateLocation(location, message); 045 } 046 047 public String getMessage() { 048 return message; 049 } 050 051 public MainContext getContext() { 052 return context; 053 } 054 055}