// Path: noark-extraction-validator/src/main/java/com/documaster/validator/exceptions/ReportingException.java
// public class ReportingException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public ReportingException(String message) {
// 
// 		super(message);
// 	}
// 
// 	public ReportingException(Throwable throwable) {
// 
// 		super(throwable);
// 	}
// 
// 	public ReportingException(String message, Throwable throwable) {
// 
// 		super(message, throwable);
// 	}
// }
// 
// Path: noark-extraction-validator/src/main/java/com/documaster/validator/storage/core/Storage.java
// public abstract class Storage {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(Storage.class);
// 
// 	private static Storage instance;
// 
// 	private StorageWriter writerThread;
// 
// 	private LinkedBlockingQueue<Persistable> queue = new LinkedBlockingQueue<>();
// 
// 	/**
// 	 * < item definition full name , set of unique field names >
// 	 */
// 	protected Map<String, Set<String>> uniqueFields;
// 
// 	protected Storage() {
// 		// Prevent instantiation
// 	}
// 
// 	/**
// 	 * Creates a new concrete {@link Storage} instance via the {@link StorageFactory}, establishes a connection
// 	 * to the storage provider, and runs a separate thread that listens for actions.
// 	 *
// 	 * @param config
// 	 * 		The {@link StorageConfiguration} with which to instantiate the {@link Storage}.
// 	 * @param uniqueFields
// 	 * 		The name of the unique field in each table
// 	 */
// 	public static void init(StorageConfiguration config, Map<String, Set<String>> uniqueFields) throws Exception {
// 
// 		LOGGER.info("Initializing storage ...");
// 
// 		instance = StorageFactory.createPersistence(config);
// 		instance.uniqueFields = uniqueFields;
// 	}
// 
// 	public static Storage get() {
// 
// 		return instance;
// 	}
// 
// 	/**
// 	 * Starts the {@link Storage}'s writer.
// 	 */
// 	public void startWriter() {
// 
// 		writerThread = new StorageWriter();
// 		writerThread.start();
// 	}
// 
// 	private boolean isWriteAvailable() {
// 
// 		return writerThread != null && writerThread.isAlive();
// 	}
// 
// 	/**
// 	 * Queues the specified {@link Persistable} object for writing.
// 	 * <p/>
// 	 * Writing a {@link StorageWriter#SHUTDOWN_SIGNAL} will send a shutdown signal to the writer.
// 	 */
// 	public void write(Persistable obj) {
// 
// 		if (!isWriteAvailable()) {
// 			throw new StorageException(
// 					"The Storage writer is not listening. Most probably the writer "
// 							+ "thread encountered an unexpected error. Please verify the logs for more information.");
// 		}
// 
// 		queue.offer(obj);
// 	}
// 
// 	Persistable nextInWriteQueue() throws InterruptedException {
// 
// 		return queue.take();
// 	}
// 
// 	/**
// 	 * Sends a shut down signal to the {@link Storage}'s writer, waits for it to exit, and returns its exit status.
// 	 *
// 	 * @return <b>true</b> if the writer exists and no exceptions occurred during execution; <b>false</b> otherwise.
// 	 */
// 	public boolean stopWriter() {
// 
// 		if (writerThread != null && isWriteAvailable()) {
// 			// Send shut down signal to writer
// 			write(StorageWriter.SHUTDOWN_SIGNAL);
// 
// 			// Wait for the listener to exit
// 			try {
// 				writerThread.join();
// 			} catch (InterruptedException ex) {
// 				// Ignore... someone else has interrupted the writer
// 			}
// 		}
// 
// 		return writerThread != null && writerThread.getLastException() == null;
// 	}
// 
// 	public Exception getLastWriterException() {
// 
// 		return writerThread.getLastException();
// 	}
// 
// 	/**
// 	 * Establishes a connection to the implementation's storage provider.
// 	 */
// 	public abstract void connect() throws Exception;
// 
// 	/**
// 	 * Indicates whether a connection is established and {@link Storage#fetch} can be invoked to retrieve data from the
// 	 * {@link Storage} implementation.
// 	 */
// 	public abstract boolean isReadAvailable();
// 
// 	/**
// 	 * Destroys the connection to the implementation's storage provider.
// 	 */
// 	public abstract void destroy();
// 
// 	protected abstract void writeItemDef(ItemDef itemDef) throws Exception;
// 
// 	protected abstract void writeItem(Item item) throws Exception;
// 
// 	/**
// 	 * Fetches the results of the specified query mapped as a list of {@link BaseItem}s.
// 	 */
// 	public abstract List<BaseItem> fetch(String query) throws Exception;
// 
// 	public enum StorageType {
// 
// 		HSQLDB_IN_MEMORY, HSQLDB_FILE, HSQLDB_SERVER
// 	}
// }


import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
import com.documaster.validator.exceptions.ReportingException;
import com.documaster.validator.storage.core.Storage;

	public void setServerLocation(String serverLocation) {

		this.serverLocation = serverLocation;
	}

	@Override
	public void validate() {

		if (storageType == null) {

			throw new ParameterException(STORAGE + " must be specified.");
		}

		switch (storageType) {

			case HSQLDB_SERVER:
				if (serverLocation == null) {
					throw new ParameterException(SERVER_LOCATION + " must be specified");
				}
			case HSQLDB_FILE:
				if (databaseDirLocation == null) {
					throw new ParameterException(DATABASE_DIR_LOCATION + " must be specified");
				}
			case HSQLDB_IN_MEMORY:
				if (databaseName == null) {
					throw new ParameterException(DATABASE_NAME + " must be specified");
				}
				break;
			default:
// Path: noark-extraction-validator/src/main/java/com/documaster/validator/exceptions/ReportingException.java
// public class ReportingException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public ReportingException(String message) {
// 
// 		super(message);
// 	}
// 
// 	public ReportingException(Throwable throwable) {
// 
// 		super(throwable);
// 	}
// 
// 	public ReportingException(String message, Throwable throwable) {
// 
// 		super(message, throwable);
// 	}
// }
// 
// Path: noark-extraction-validator/src/main/java/com/documaster/validator/storage/core/Storage.java
// public abstract class Storage {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(Storage.class);
// 
// 	private static Storage instance;
// 
// 	private StorageWriter writerThread;
// 
// 	private LinkedBlockingQueue<Persistable> queue = new LinkedBlockingQueue<>();
// 
// 	/**
// 	 * < item definition full name , set of unique field names >
// 	 */
// 	protected Map<String, Set<String>> uniqueFields;
// 
// 	protected Storage() {
// 		// Prevent instantiation
// 	}
// 
// 	/**
// 	 * Creates a new concrete {@link Storage} instance via the {@link StorageFactory}, establishes a connection
// 	 * to the storage provider, and runs a separate thread that listens for actions.
// 	 *
// 	 * @param config
// 	 * 		The {@link StorageConfiguration} with which to instantiate the {@link Storage}.
// 	 * @param uniqueFields
// 	 * 		The name of the unique field in each table
// 	 */
// 	public static void init(StorageConfiguration config, Map<String, Set<String>> uniqueFields) throws Exception {
// 
// 		LOGGER.info("Initializing storage ...");
// 
// 		instance = StorageFactory.createPersistence(config);
// 		instance.uniqueFields = uniqueFields;
// 	}
// 
// 	public static Storage get() {
// 
// 		return instance;
// 	}
// 
// 	/**
// 	 * Starts the {@link Storage}'s writer.
// 	 */
// 	public void startWriter() {
// 
// 		writerThread = new StorageWriter();
// 		writerThread.start();
// 	}
// 
// 	private boolean isWriteAvailable() {
// 
// 		return writerThread != null && writerThread.isAlive();
// 	}
// 
// 	/**
// 	 * Queues the specified {@link Persistable} object for writing.
// 	 * <p/>
// 	 * Writing a {@link StorageWriter#SHUTDOWN_SIGNAL} will send a shutdown signal to the writer.
// 	 */
// 	public void write(Persistable obj) {
// 
// 		if (!isWriteAvailable()) {
// 			throw new StorageException(
// 					"The Storage writer is not listening. Most probably the writer "
// 							+ "thread encountered an unexpected error. Please verify the logs for more information.");
// 		}
// 
// 		queue.offer(obj);
// 	}
// 
// 	Persistable nextInWriteQueue() throws InterruptedException {
// 
// 		return queue.take();
// 	}
// 
// 	/**
// 	 * Sends a shut down signal to the {@link Storage}'s writer, waits for it to exit, and returns its exit status.
// 	 *
// 	 * @return <b>true</b> if the writer exists and no exceptions occurred during execution; <b>false</b> otherwise.
// 	 */
// 	public boolean stopWriter() {
// 
// 		if (writerThread != null && isWriteAvailable()) {
// 			// Send shut down signal to writer
// 			write(StorageWriter.SHUTDOWN_SIGNAL);
// 
// 			// Wait for the listener to exit
// 			try {
// 				writerThread.join();
// 			} catch (InterruptedException ex) {
// 				// Ignore... someone else has interrupted the writer
// 			}
// 		}
// 
// 		return writerThread != null && writerThread.getLastException() == null;
// 	}
// 
// 	public Exception getLastWriterException() {
// 
// 		return writerThread.getLastException();
// 	}
// 
// 	/**
// 	 * Establishes a connection to the implementation's storage provider.
// 	 */
// 	public abstract void connect() throws Exception;
// 
// 	/**
// 	 * Indicates whether a connection is established and {@link Storage#fetch} can be invoked to retrieve data from the
// 	 * {@link Storage} implementation.
// 	 */
// 	public abstract boolean isReadAvailable();
// 
// 	/**
// 	 * Destroys the connection to the implementation's storage provider.
// 	 */
// 	public abstract void destroy();
// 
// 	protected abstract void writeItemDef(ItemDef itemDef) throws Exception;
// 
// 	protected abstract void writeItem(Item item) throws Exception;
// 
// 	/**
// 	 * Fetches the results of the specified query mapped as a list of {@link BaseItem}s.
// 	 */
// 	public abstract List<BaseItem> fetch(String query) throws Exception;
// 
// 	public enum StorageType {
// 
// 		HSQLDB_IN_MEMORY, HSQLDB_FILE, HSQLDB_SERVER
// 	}
// }


// Path: noark-extraction-validator/src/main/java/com/documaster/validator/config/delegates/StorageConfiguration.java
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
import com.documaster.validator.exceptions.ReportingException;
import com.documaster.validator.storage.core.Storage;


	public void setServerLocation(String serverLocation) {

		this.serverLocation = serverLocation;
	}

	@Override
	public void validate() {

		if (storageType == null) {

			throw new ParameterException(STORAGE + " must be specified.");
		}

		switch (storageType) {

			case HSQLDB_SERVER:
				if (serverLocation == null) {
					throw new ParameterException(SERVER_LOCATION + " must be specified");
				}
			case HSQLDB_FILE:
				if (databaseDirLocation == null) {
					throw new ParameterException(DATABASE_DIR_LOCATION + " must be specified");
				}
			case HSQLDB_IN_MEMORY:
				if (databaseName == null) {
					throw new ParameterException(DATABASE_NAME + " must be specified");
				}
				break;
			default:
				throw new ReportingException("Unknown storage type: " + storageType);