package com.libreecm.db.controllers;

import java.io.IOException;

//import org.springframework.security.authentication.AnonymousAuthenticationToken;
//import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.libreecm.commonAPI.configuration.ComponentConfig;
import com.libreecm.commonAPI.configuration.Config;
//import com.LibreECM.DB.configuration.security.IAuthenticationFacade;

@RestController
public class ConfigController extends BaseController{
    
    @RequestMapping(value="/config", method = RequestMethod.POST)
    /**
     * A class that saves a Config to the LibreECMDDBB
     * @param config
     * @return
     */
    public @ResponseBody Config saveConfig(@RequestBody Config config) throws IOException {
    	//validateUser();
    	ComponentConfig.setConfig(config);
    	return config;
    }

    /**
     * A class that returns a Config from the LibreECMDDBB
     * @param id
     * @return
     */
	    @RequestMapping(value="/config", method = RequestMethod.GET)
	    public Config config() {
	    	//validateUser();
			return ComponentConfig.getConfig();
	    }
	    
}
