Subversion Repositories SmartDukaan

Rev

Rev 323 | Rev 341 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.util;

import in.shop2020.config.ConfigException;
import in.shop2020.thrift.clients.config.ConfigClient;

import java.util.logging.Logger;

/**
 * Utility functions and wrappers 
 * 
 * @author naveen
 *
 */
public class Utils {
        
                
                
        public static String CONTENT_DB_PATH, DEFINITIONS_DB_PATH, MEDIA_DB_PATH, ENTITIES_DB_PATH, COMPARISONS_DB_PATH;
        public static String currentDir = System.getProperty("user.dir");
        
        static{

                ConfigClient configClient = ConfigClient.getClient();
                
                try {  
                        /**
                         * Path to DB... will have lot of references
                         */
                        CONTENT_DB_PATH = configClient.get("CONTENT_DB_PATH");
                        MEDIA_DB_PATH = configClient.get("MEDIA_DB_PATH");
                        DEFINITIONS_DB_PATH = configClient.get("DEFINITIONS_DB_PATH");
                        ENTITIES_DB_PATH = configClient.get("ENTITIES_DB_PATH");
                        COMPARISONS_DB_PATH = configClient.get("COMPARISIONS_DB_PATH");
                        
                }catch(ConfigException ex){
                        ex.printStackTrace();
                        CONTENT_DB_PATH = "/var/lib/tomcat6/webapps/db/entities/";
                        MEDIA_DB_PATH = "/var/lib/tomcat6/webapps/db/media/";
                        DEFINITIONS_DB_PATH =   "/var/lib/tomcat6/webapps/db/definitions/";
                        ENTITIES_DB_PATH =  "/var/lib/tomcat6/webapps/db/entities/";
                        COMPARISONS_DB_PATH = "/var/lib/tomcat6/webapps/db/comparisons/";
                        }
                }
        
        
        //Next some paths are somewhat hardcoded need to check when gets time. But they will be used only first time and in utility classes.
        /**
         * Path to XML definitions
         */
        public static final String DEFINITIONS_SRC_PATH = currentDir +  "/src/xml/model/";
        /**
         * Path to where PPT files will be picked
         */
        public static final String CONTENT_SRC_PPT_PATH = currentDir + "/content/ppt/";
        /**
         * Path where exported HTML files are kept
         */
        public static final String CONTENT_SRC_HTML_PATH =      currentDir + "/content/html/";
        /**
         * IR XML export path
         */
        public static final String EXPORT_IR_PATH = currentDir + "/export/ir/";
        public static final String EXPORT_ENTITIES_PATH =       currentDir + "/export/html/entities/";
        public static final String EXPORT_DEFINITIONS_PATH =    currentDir + "/export/html/definitions/";
        public static final String EXPORT_CATEGORY_HOMES_PATH = currentDir + "/export/html/category_homes/";
        public static final String EXPORT_DIFF_PATH =   currentDir + "/export/html/diff/";
        
        
        public static String VTL_SRC_PATH = "src/velocity/";
        
        /**
         * Jython source path
         */
        public static String JYTHON_SRC_PATH = "src/jython/";
        
        public static long SNIPPETS_FEATURE_DEFINITIONID = 120081;
        
        
        /**
         * Brand's feature definition, is not referred directly by content models
         */
        public static final long BRAND_FEATURE_DEFINITION_ID = 120080;
        
        /**
         * Brand's facet definition
         */
        public static final long BRAND_FACET_DEFINITION_ID = 50001;
        
        /**
         * Singleton Logger instance
         */
        public static Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);

        /**
         * INFO type message
         * 
         * @param obj
         */
        public static void info(Object obj) {
                System.out.println("INFO: " + obj.toString());
        }
        
        /**
         * SEVERE type message
         * 
         * @param obj
         */
        public static void severe(Object obj) {
                System.out.println("SEVERE: " + obj.toString());
        }

        /**
         * MANDATORY type message
         * 
         * @param obj
         */
        public static void warning(Object obj) {
                System.out.println("WARNING: " + obj.toString());
        }
}