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

gov.nasa.pds.citool.search.DocWriter Maven / Gradle / Ivy

Go to download

The Legacy Catalog Tool provides functionality for ingesting PDS3 catalog files into the PDS4 infrastructure including the Registry Service.

There is a newer version: 3.1.0
Show newest version
package gov.nasa.pds.citool.search;

import java.io.File;
import java.io.FileWriter;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang.StringEscapeUtils;

public class DocWriter 
{
	private File outDir;
	private FileWriter writer;	
	
	public DocWriter(String outDir, String volumeId) throws Exception
	{
		this.outDir = new File(outDir);
		this.outDir.mkdirs();
		
		File file = new File(this.outDir, volumeId + ".solr.xml");
		writer = new FileWriter(file);
		writer.write("\n");
	}
	
	public void close() throws Exception
	{
		writer.write("\n");
		writer.close();
	}
	
	public void write(Map> fields) throws Exception
	{
		writer.write("\n");
		writer.write("" + UUID.randomUUID().toString() + "\n");
		
		for(Map.Entry> field: fields.entrySet())
		{
			String fieldName = field.getKey();
			for(String value: field.getValue())
			{
				writer.write("");
				StringEscapeUtils.escapeXml(writer, value);
				writer.write("\n");
			}
		}
		
		writer.write("\n");
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy