package com.platform.modules.plm.util;

import javax.servlet.ServletContext;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

@ConfigurationProperties(prefix = "materia")
@Component
public class MateriaFileProperties implements ServletContextAware{
	public String materiaPath;
	private String mediaPath;
	private String SPT;
    private String basePath;

	public String getMateriaPath() {
		return materiaPath;
	}

	public void setMateriaPath(String materiaPath) {
		this.materiaPath = materiaPath;
	}

	public String getMediaPath() {
		return mediaPath;
	}

	public void setMediaPath(String mediaPath) {
		this.mediaPath = mediaPath;
	}

	public String getSPT() {
		return SPT;
	}

	public void setSPT(String sPT) {
		SPT = sPT;
	}

	public String getBasePath() {
		return basePath;
	}

	public void setBasePath(String basePath) {
		this.basePath = basePath;
	}

	public String getRealPath(String name){
		String realpath=ctx.getRealPath(name);
		if(realpath==null){
			realpath=ctx.getRealPath("/")+name;
		}
		return realpath;
	}

	private ServletContext ctx;

	public void setServletContext(ServletContext servletContext) {
		this.ctx = servletContext;
	}
	
}
