@@ -0,0 +1,3219 @@
+package com.ajah.rest.api.controller;%0A%0Aimport com.ajah.rest.api.error.EmailFormatException;%0Aimport com.ajah.rest.api.error.RequiredRequestParameterException;%0Aimport com.ajah.util.StringUtils;%0Aimport com.ajah.util.Validate;%0A%0A/**%0A * A Controller Base is a %22just add mapping%22 Spring MVC controller. The mappings%0A * are omitted so that the URLs don't register on a component/classpath scan.%0A * AjahControllerBase serves as a superclass to the other base controllers,%0A * which should be included as properties of application-specific controllers.%0A * AjahControllerBase can also serve as a superclass for application-specific%0A * controllers depending on the preferred method of accessing the utility%0A * methods contained here.%0A * %0A * @author Eric F. Savage%0A *         %3Ca href=%22mailto:code@efsavage.com%22%3Ecode@efsavage.com%3C/a%3E,%0A *         %3Ca href=%22https://github.com/efsavage%22%3Egithub.com/efsavage%3C/a%3E.%0A *%0A */%0A@SuppressWarnings(%22static-method%22)%0Apublic class AjahControllerBase %7B%0A%0A%09/**%0A%09 * Require a parameter, either on the request or as part of a submitted%0A%09 * model.%0A%09 * %0A%09 * @param name%0A%09 *            The property name, this is for human messaging only and is not%0A%09 *            used for any introspection.%0A%09 * @param value%0A%09 *            The current value, may be null.%0A%09 * @throws RequiredRequestParameterException%0A%09 *             If the value is null, or if the value is an empty string.%0A%09 */%0A%09protected void requireParameter(final String name, final Object value) throws RequiredRequestParameterException %7B%0A%09%09if (value == null) %7B%0A%09%09%09throw new RequiredRequestParameterException(name);%0A%09%09%7D%0A%09%09if (String.class.isAssignableFrom(value.getClass())) %7B%0A%09%09%09requireParameter(name, (String) value);%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Require a string parameter, either on the request or as part of a%0A%09 * submitted model.%0A%09 * %0A%09 * @param name%0A%09 *            The property name, this is for human messaging only and is not%0A%09 *            used for any introspection.%0A%09 * @param value%0A%09 *            The current value, may be empty or null.%0A%09 * @throws RequiredRequestParameterException%0A%09 *             If the value is null, or if the value is an empty string.%0A%09 */%0A%09public void requireParameter(final String name, final String value) throws RequiredRequestParameterException %7B%0A%09%09if (StringUtils.isBlank(value)) %7B%0A%09%09%09throw new RequiredRequestParameterException(name);%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Require a string parameter to be a valid email format, either on the%0A%09 * request or as part of a submitted model.%0A%09 * %0A%09 * @param name%0A%09 *            The property name, this is for human messaging only and is not%0A%09 *            used for any introspection.%0A%09 * @param value%0A%09 *            The current value, may be empty or null.%0A%09 * @throws RequiredRequestParameterException%0A%09 *             If the value is null, an empty string.%0A%09 * @throws EmailFormatException%0A%09 *             If the value is not-null, and not an empty string, but is not%0A%09 *             a valid email format.%0A%09 * @see Validate#isEmail(String)%0A%09 */%0A%09protected void requireEmail(final String name, final String value) throws RequiredRequestParameterException, EmailFormatException %7B%0A%09%09requireParameter(name, value);%0A%09%09if (!Validate.isEmail(value)) %7B%0A%09%09%09throw new EmailFormatException(name);%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add controller base