// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
// 
// 	private String name;
// 
// 	private boolean isFile;
// 
// 	public Resource(final String name, final boolean isFile) {
// 		this.name = name;
// 		this.isFile = isFile;
// 	}
// 
// 	public String getName() {
// 		return this.name;
// 	}
// 
// 	public void setName(final String name) {
// 		this.name = name;
// 	}
// 
// 	public boolean isFile() {
// 		return this.isFile;
// 	}
// 
// 	public void setFile(final boolean isFile) {
// 		this.isFile = isFile;
// 	}
// }
// 
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// 	private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
// 
// 	/** The dao. */
// 	@Autowired
// 	private ProjectRepository dao;
// 
// 	@Autowired
// 	private GlobalProperties prop;
// 
// 	/**
// 	 * Creates the resource.
// 	 *
// 	 * @param projectId the project id
// 	 * @param name the name
// 	 * @param content the content
// 	 * @throws IOException Signals that an I/O exception has occurred.
// 	 */
// 	public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// 		if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// 			Files.createFile(path);
// 			final FileWriter fileWriter = new FileWriter(path.toFile());
// 			fileWriter.write(content);
// 			fileWriter.flush();
// 			fileWriter.close();
// 		} else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// 			Files.createDirectory(path);
// 		}
// 		LOG.debug("Create {}.", path);
// 	}
// 
// 	public List<Resource> findAllResources(final String projectId, final String subpath) {
// 		List<Resource> result = new ArrayList<>();
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		if (project != null) {
// 			try {
// 				result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// 			} catch (final IOException e) {
// 				LOG.error("Unable to get resources.", e);
// 			}
// 		}
// 		return result;
// 	}
// 
// 	public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// 		final byte[] bytes = Files.readAllBytes(path);
// 		return new String(bytes);
// 	}
// 
// }


import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;
package com.glitterlabs.terraformui.controller;





@RestController
public class ResourceController {

	private ResourceService resourceService;

	@Autowired
// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
// 
// 	private String name;
// 
// 	private boolean isFile;
// 
// 	public Resource(final String name, final boolean isFile) {
// 		this.name = name;
// 		this.isFile = isFile;
// 	}
// 
// 	public String getName() {
// 		return this.name;
// 	}
// 
// 	public void setName(final String name) {
// 		this.name = name;
// 	}
// 
// 	public boolean isFile() {
// 		return this.isFile;
// 	}
// 
// 	public void setFile(final boolean isFile) {
// 		this.isFile = isFile;
// 	}
// }
// 
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// 	private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
// 
// 	/** The dao. */
// 	@Autowired
// 	private ProjectRepository dao;
// 
// 	@Autowired
// 	private GlobalProperties prop;
// 
// 	/**
// 	 * Creates the resource.
// 	 *
// 	 * @param projectId the project id
// 	 * @param name the name
// 	 * @param content the content
// 	 * @throws IOException Signals that an I/O exception has occurred.
// 	 */
// 	public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// 		if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// 			Files.createFile(path);
// 			final FileWriter fileWriter = new FileWriter(path.toFile());
// 			fileWriter.write(content);
// 			fileWriter.flush();
// 			fileWriter.close();
// 		} else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// 			Files.createDirectory(path);
// 		}
// 		LOG.debug("Create {}.", path);
// 	}
// 
// 	public List<Resource> findAllResources(final String projectId, final String subpath) {
// 		List<Resource> result = new ArrayList<>();
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		if (project != null) {
// 			try {
// 				result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// 			} catch (final IOException e) {
// 				LOG.error("Unable to get resources.", e);
// 			}
// 		}
// 		return result;
// 	}
// 
// 	public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// 		final Project project = this.dao.findOne(Long.valueOf(projectId));
// 		final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// 		final byte[] bytes = Files.readAllBytes(path);
// 		return new String(bytes);
// 	}
// 
// }


// Path: src/main/java/com/glitterlabs/terraformui/controller/ResourceController.java
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;

package com.glitterlabs.terraformui.controller;





@RestController
public class ResourceController {

	private ResourceService resourceService;

	@Autowired
	public void setProjectService(final ResourceService resourceService) {