All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lumongo.admin.FetchAssociated Maven / Gradle / Ivy

The newest version!
package org.lumongo.admin;

import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.lumongo.LumongoConstants;
import org.lumongo.admin.help.LumongoHelpFormatter;
import org.lumongo.client.LumongoRestClient;
import org.lumongo.util.LogUtil;

import java.io.File;

public class FetchAssociated {

	public static void main(String[] args) throws Exception {
		LogUtil.loadLogConfig();

		OptionParser parser = new OptionParser();
		OptionSpec addressArg = parser.accepts(AdminConstants.ADDRESS).withRequiredArg().defaultsTo("localhost").describedAs("Lumongo server address");
		OptionSpec restPortArg = parser.accepts(AdminConstants.REST_PORT).withRequiredArg().ofType(Integer.class)
						.defaultsTo(LumongoConstants.DEFAULT_REST_SERVICE_PORT).describedAs("Lumongo rest port");
		OptionSpec idArg = parser.accepts(AdminConstants.ID).withRequiredArg().required().describedAs("Doc Id");
		OptionSpec indexArg = parser.accepts(AdminConstants.INDEX).withRequiredArg().required().describedAs("Index");
		OptionSpec fileNameArg = parser.accepts(AdminConstants.FILE_NAME).withRequiredArg().required().describedAs("Associated File Name");
		OptionSpec outputFileArg = parser.accepts(AdminConstants.OUTPUT_FILE).withRequiredArg().ofType(File.class).required()
						.describedAs("Location to write associated file");

		try {
			OptionSet options = parser.parse(args);

			String address = options.valueOf(addressArg);
			int restPort = options.valueOf(restPortArg);
			String id = options.valueOf(idArg);
			String indexName = options.valueOf(indexArg);
			String fileName = options.valueOf(fileNameArg);
			File outputFile = options.valueOf(outputFileArg);

			LumongoRestClient client = new LumongoRestClient(address, restPort);
			client.fetchAssociated(id, indexName, fileName, outputFile);

		}
		catch (OptionException e) {
			System.err.println("ERROR: " + e.getMessage());
			parser.formatHelpWith(new LumongoHelpFormatter());
			parser.printHelpOn(System.out);
			System.exit(2);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy