All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.tno.bim.nmd.controller.BaseNMDController Maven / Gradle / Ivy

The newest version!
package nl.tno.bim.nmd.controller;

import java.io.FileNotFoundException;

import org.apache.http.ProtocolVersion;
import org.apache.http.message.BasicStatusLine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import nl.tno.bim.nmd.services.Nmd2DataService;
import nl.tno.bim.nmd.services.Nmd3DataService;
import nl.tno.bim.nmd.services.NmdDataService;

public class BaseNMDController {
	
	private final static Logger logger = LoggerFactory.getLogger(BaseNMDController.class);
	
	protected Logger getLogger() {
		return logger;
	}
	
	protected void logMessage(String message) {
        if (getLogger().isDebugEnabled()) {
        	getLogger().debug(message);
        }
	}
	
	protected BasicStatusLine success = new BasicStatusLine(new ProtocolVersion("http", 1,1), 200, "");
	protected BasicStatusLine failure = new BasicStatusLine(new ProtocolVersion("http", 1, 1), 404, "");
	protected NmdDataService nmd2Service = null;
	protected NmdDataService nmd3Service = null;
    private NmdDataService defaultService;
    
    public BaseNMDController() {
    	try {
    		nmd2Service = new Nmd2DataService();
    		nmd3Service = Nmd3DataService.getInstance();
    		
    	} catch (FileNotFoundException e) {
    		this.getLogger().error("Could not initialize NMDController due to missing config file.");
    	}
    	
    	defaultService = nmd3Service;
    }

    public NmdDataService getService(Integer versionId) {
    	switch (versionId) {
		case 2:
			return nmd2Service;
		case 3:
			return nmd3Service;
		default:
			getLogger().warn("could not find version for nmd interface. fall back to default service.");
			return defaultService;
		}
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy