Package org.apache.stanbol.commons.solr.SolrServerAdapter

Examples of org.apache.stanbol.commons.solr.SolrServerAdapter.SolrServerProperties


            }
        } else {
            log.info("   .... managed directory '{}' already present and initialised",managedSolrDir);
        }
        //init the SolrServerProperties and read the other parameters form the config
        SolrServerProperties serverProperties = new SolrServerProperties(managedSolrDir);
        serverProperties.setServerName(serverName);
        value = context.getProperties().get(PROPERTY_SERVER_RANKING);
        if(value instanceof Number){
            serverProperties.setServerRanking(((Number)value).intValue());
        } else if(value != null && !value.toString().isEmpty()){
            try {
                serverProperties.setServerRanking(Integer.parseInt(value.toString()));
                log.info(" > Ranking = {}",serverProperties.getServerRanking());
            }catch (NumberFormatException e) {
               throw new ConfigurationException(PROPERTY_SERVER_RANKING, "The configured Server Ranking '"+
                   value+" can not be converted to an Integer!",e);
            }
        } //else not present or empty string -> do not set a ranking!
        value = context.getProperties().get(PROPERTY_SERVER_PUBLISH_REST);
        if(value == null || value instanceof Boolean) {
            serverProperties.setPublishREST((Boolean)value);
        } else {
            serverProperties.setPublishREST(Boolean.parseBoolean(value.toString()));
        }
        try {
            server = new SolrServerAdapter(context.getBundleContext(), serverProperties);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Unable to initialise the XML parser " +
                    "for parsing the SolrServer Configuration for Server '"+
                    serverProperties.getServerName()+"' (dir="+
                    serverProperties.getServerDir()+")!",e);
        } catch (IOException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                    "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                    "'!",e);
        } catch (SAXException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                "'!",e);
        }
//        dfpServiceRegistration = context.getBundleContext().registerService(
//            DataFileProvider.class.getName(),
//            new ClassPathSolrIndexConfigProvider(
View Full Code Here


     * to generate meaningful error messages
     */
    @Activate
    protected void activate(ComponentContext context) throws ConfigurationException {
        log.info("Activate {}: ",getClass().getSimpleName());
        SolrServerProperties properties = null;
        Object value = context.getProperties().get(PROPERTY_SERVER_DIR);
        if(value == null || value.toString().isEmpty()){
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "The Server directory is a " +
                "required configuration and MUST NOT be NULL nor empty!");
        } else {
            File solrServerDir = new File(value.toString());
            if(solrServerDir.isDirectory()){
                log.info(" > solrDir = {}",solrServerDir);
                properties = new SolrServerProperties(solrServerDir);
            } else {
                throw new ConfigurationException(PROPERTY_SERVER_DIR, "The parsed Solr Server directpry '"+
                    value+"' does not exist or is not a directory!");
            }
        }
        value = context.getProperties().get(PROPERTY_SERVER_NAME);
        if(value == null || value.toString().isEmpty()){
            throw new ConfigurationException(PROPERTY_SERVER_NAME, "The Server Name is a required" +
                "Configuration and MUST NOT be NULL nor empty!");
        } else {
            properties.setServerName(value.toString());
            log.info(" > Name = {}",value.toString());
        }
        value = context.getProperties().get(PROPERTY_SERVER_RANKING);
        if(value instanceof Number){
            properties.setServerRanking(((Number)value).intValue());
        } else if(value != null && !value.toString().isEmpty()){
            try {
                properties.setServerRanking(Integer.parseInt(value.toString()));
                log.info(" > Ranking = {}",properties.getServerRanking());
            }catch (NumberFormatException e) {
               throw new ConfigurationException(PROPERTY_SERVER_RANKING, "The configured Server Ranking '"+
                   value+" can not be converted to an Integer!",e);
            }
        } //else not present or empty string -> do not set a ranking!
        value = properties.get(PROPERTY_SERVER_PUBLISH_REST);
        if(value == null || value instanceof Boolean) {
            properties.setPublishREST((Boolean)value);
        } else {
            properties.setPublishREST(Boolean.parseBoolean(value.toString()));
        }
        log.info(" > publisRest = {}",properties.isPublishREST());
        try {
            server = new SolrServerAdapter(context.getBundleContext(), properties);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Unable to initialise the XML parser " +
                "for parsing the SolrServer Configuration for Server '"+
                properties.getServerName()+"' (dir="+
                properties.getServerDir()+")!",e);
        } catch (IOException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                "a SolrServer based on the Directory '"+properties.getServerDir() +
                "'!",e);
        } catch (SAXException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                "a SolrServer based on the Directory '"+properties.getServerDir() +
                "'!",e);
        }
        log.info(" ... SolrServer successfully initialised!");
    }
View Full Code Here

            }
        } else {
            log.info("   .... managed directory '{}' already present and initialised",managedSolrDir);
        }
        //init the SolrServerProperties and read the other parameters form the config
        SolrServerProperties serverProperties = new SolrServerProperties(managedSolrDir);
        serverProperties.setServerName(serverName);
        value = context.getProperties().get(PROPERTY_SERVER_RANKING);
        if(value instanceof Number){
            serverProperties.setServerRanking(((Number)value).intValue());
        } else if(value != null && !value.toString().isEmpty()){
            try {
                serverProperties.setServerRanking(Integer.parseInt(value.toString()));
                log.info(" > Ranking = {}",serverProperties.getServerRanking());
            }catch (NumberFormatException e) {
               throw new ConfigurationException(PROPERTY_SERVER_RANKING, "The configured Server Ranking '"+
                   value+" can not be converted to an Integer!",e);
            }
        } //else not present or empty string -> do not set a ranking!
        value = context.getProperties().get(PROPERTY_SERVER_PUBLISH_REST);
        if(value == null || value instanceof Boolean) {
            serverProperties.setPublishREST((Boolean)value);
        } else {
            serverProperties.setPublishREST(Boolean.parseBoolean(value.toString()));
        }
        try {
            server = new SolrServerAdapter(context.getBundleContext(), serverProperties);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Unable to initialise the XML parser " +
                    "for parsing the SolrServer Configuration for Server '"+
                    serverProperties.getServerName()+"' (dir="+
                    serverProperties.getServerDir()+")!",e);
        } catch (IOException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                    "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                    "'!",e);
        } catch (SAXException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                "'!",e);
        }
//        dfpServiceRegistration = context.getBundleContext().registerService(
//            DataFileProvider.class.getName(),
//            new ClassPathSolrIndexConfigProvider(
View Full Code Here

            }
        } else {
            log.info("   .... managed directory '{}' already present and initialised",managedSolrDir);
        }
        //init the SolrServerProperties and read the other parameters form the config
        SolrServerProperties serverProperties = new SolrServerProperties(managedSolrDir);
        serverProperties.setServerName(serverName);
        value = context.getProperties().get(PROPERTY_SERVER_RANKING);
        if(value instanceof Number){
            serverProperties.setServerRanking(((Number)value).intValue());
        } else if(value != null && !value.toString().isEmpty()){
            try {
                serverProperties.setServerRanking(Integer.parseInt(value.toString()));
                log.info(" > Ranking = {}",serverProperties.getServerRanking());
            }catch (NumberFormatException e) {
               throw new ConfigurationException(PROPERTY_SERVER_RANKING, "The configured Server Ranking '"+
                   value+" can not be converted to an Integer!",e);
            }
        } //else not present or empty string -> do not set a ranking!
        value = context.getProperties().get(PROPERTY_SERVER_PUBLISH_REST);
        if(value == null || value instanceof Boolean) {
            serverProperties.setPublishREST((Boolean)value);
        } else {
            serverProperties.setPublishREST(Boolean.parseBoolean(value.toString()));
        }
        try {
            server = new SolrServerAdapter(context.getBundleContext(), serverProperties);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Unable to initialise the XML parser " +
                    "for parsing the SolrServer Configuration for Server '"+
                    serverProperties.getServerName()+"' (dir="+
                    serverProperties.getServerDir()+")!",e);
        } catch (IOException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                    "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                    "'!",e);
        } catch (SAXException e) {
            throw new ConfigurationException(PROPERTY_SERVER_DIR, "Unable to initialise " +
                "a SolrServer based on the Directory '"+serverProperties.getServerDir() +
                "'!",e);
        }
//        dfpServiceRegistration = context.getBundleContext().registerService(
//            DataFileProvider.class.getName(),
//            new ClassPathSolrIndexConfigProvider(
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.solr.SolrServerAdapter.SolrServerProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.