package com.github.aureliano.achmed.os.fs;

import com.github.aureliano.achmed.command.CommandFacade;
import com.github.aureliano.achmed.command.CommandResponse;
import com.github.aureliano.achmed.exception.FileResourceException;
import com.github.aureliano.achmed.resources.properties.FileProperties;

public class PosixFileProvider implements IFileProvider {

	private FileProperties properties;
	
	public PosixFileProvider() {
		super();
	}

	@Override
	public void setFileMode() {
		CommandResponse res = CommandFacade.executeCommand(
			"chmod", this.properties.getMode(), this.properties.getPath());
		
		if (!res.isOK()) {
			throw new FileResourceException(res);
		}
	}

	@Override
	public void setFileOwner() {
		throw new UnsupportedOperationException("Not implemented yet.");
	}

	@Override
	public void copyFile() {
		throw new UnsupportedOperationException("Not implemented yet.");
	}

	@Override
	public void copyFolder() {
		throw new UnsupportedOperationException("Not implemented yet.");
	}

	@Override
	public void setFileProperties(FileProperties properties) {
		this.properties = properties;
	}

	@Override
	public FileProperties getFileProperties() {
		return this.properties;
	}
}
@@ -37,16 +37,101 @@
 os.fs;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.apache.log4j.Logger;%0A%0A
 import c
@@ -180,16 +180,16 @@
 Facade;%0A
-
 import c
@@ -308,16 +308,72 @@
 eption;%0A
+import com.github.aureliano.achmed.helper.StringHelper;%0A
 import c
@@ -496,16 +496,99 @@
 ider %7B%0A%0A
+%09private static final Logger logger = Logger.getLogger(PosixFileProvider.class);%0A%09%0A
 %09private
@@ -943,72 +943,778 @@
 %7B%0A%09%09
-throw new UnsupportedOperationException(%22Not implemented yet.%22);
+List%3CString%3E ownerAndGroup = new ArrayList%3CString%3E();%0A%09%09if (!StringHelper.isEmpty(this.properties.getOwner())) %7B%0A%09%09%09ownerAndGroup.add(this.properties.getOwner());%0A%09%09%7D%0A%09%09%0A%09%09if ((!StringHelper.isEmpty(this.properties.getOwner())) && (!StringHelper.isEmpty(this.properties.getGroup()))) %7B%0A%09%09%09ownerAndGroup.add(%22:%22);%0A%09%09%7D%0A%09%09%0A%09%09if (!StringHelper.isEmpty(this.properties.getGroup())) %7B%0A%09%09%09ownerAndGroup.add(this.properties.getOwner());%0A%09%09%7D%0A%09%09%0A%09%09if (ownerAndGroup.isEmpty()) %7B%0A%09%09%09logger.warn(%22Ignore setting file owner because no owner neither group was provided.%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09ownerAndGroup.add(0, %22chown%22);%0A%09%09CommandResponse res = CommandFacade.executeCommand(ownerAndGroup.toArray(new String%5B0%5D));%0A%09%09%0A%09%09if (!res.isOK()) %7B%0A%09%09%09throw new FileResourceException(res);%0A%09%09%7D
 %0A%09%7D%0A

Implement set file owner.