001package org.kuali.common.util.main;
002
003import org.kuali.common.util.Assert;
004import org.kuali.common.util.LocationUtils;
005import org.kuali.common.util.execute.Executable;
006
007/**
008 * Validate <code>String[] args</code> is not null, contains at least one non-blank value and points to a location that exists.
009 */
010public final class ValidatePropertiesLocationExecutable implements Executable {
011
012        public ValidatePropertiesLocationExecutable(MainContext context, String message) {
013                Assert.noNulls(context);
014                Assert.noBlanks(message);
015                this.context = context;
016                this.message = message;
017        }
018
019        private final String message;
020        private final MainContext context;
021
022        @Override
023        public void execute() {
024                String[] args = context.getArgs();
025                Assert.notNull(args, message);
026                Assert.isTrue(args.length > 0, message);
027                String location = args[0];
028                Assert.noBlanks(message, location);
029                LocationUtils.validateLocation(location, message);
030        }
031
032        public String getMessage() {
033                return message;
034        }
035
036        public MainContext getContext() {
037                return context;
038        }
039
040}