package de.hsadmin.core.qserv;

import java.util.Map;

public class CreateFileProcessor extends AbstractProcessor {

	private static final long serialVersionUID = -2947609532975712444L;

	private CompoundProcessor compoundProcessor;
	
	public CreateFileProcessor(String templateName, Map<String, String> templateValues, String targetPath, String owner, String group, String modeMask) throws ProcessorException {
		TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, targetPath, false);
		ShellProcessor shellProcessor = 
			new ShellProcessor(
				"chown " + owner + ":" + group + " " + targetPath + " && " +
				"chmod " + modeMask + " " + targetPath);
		compoundProcessor = new CompoundProcessor(templateProcessor, shellProcessor);
	}
	
	@Override
	public Object process() throws ProcessorException {
		return compoundProcessor.process();
	}

}
