Package jeeves.server

Examples of jeeves.server.ServiceConfig


    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    context.info("Creating searcher");

    Element       params = buildParams(par);
    ServiceConfig config = new ServiceConfig();

    SearchManager searchMan = gc.getBean(SearchManager.class);
    MetaSearcher  searcher  = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);

    searcher.search(context, params, config);
View Full Code Here


      response.setAttribute("message", "Schema does not exist");
      return response;
    }

    // fast search to see if any records are present that use this schema
    ServiceConfig config = new ServiceConfig();

    SearchManager searchMan = gc.getBean(SearchManager.class);
    Element searchParams = new Element("parameters")
    searchParams.addContent(new Element("_schema").setText(schema));
View Full Code Here

        new File(getDataDir()).mkdirs();

        // reinitialize data directory so that it uses the defaults
        dataDirectory.setSystemDataDir(null);
        final ArrayList<Element> serviceConfigParameterElements = getServiceConfigParameterElements();
        final ServiceConfig handlerConfig = new ServiceConfig(serviceConfigParameterElements);
        final String webappDir = getWebappDir(getClass());
        dataDirectory.init("geonetwork", webappDir, handlerConfig, null);

        assertEquals(getGeonetworkNodeId(), dataDirectory.getNodeId());
        final String expectedDataDir = getDataDir();
View Full Code Here

                .addContent(new Element("to").setText("50"))
                .addContent(new Element("abstract").setText(""+ _abstractSearchTerm))
                .addContent(new Element("sortOrder").setText("reverse"))
                .addContent(new Element("sortBy").setText("_title"));

        final ServiceConfig config = new ServiceConfig();
        _luceneSearcher.search(_serviceContext, request, config);
        final Element result = _luceneSearcher.present(_serviceContext, request, config);
        return getTitlesFromMetadataElements(_serviceContext, request, result);
    }
View Full Code Here

        logger.info("Initializing GeoNetwork " + version + "." + subVersion + " ...");

        // Get main service config handler
        @SuppressWarnings("unchecked")
        List<Element> serviceConfigElems = config.getChildren();
        ServiceConfig handlerConfig = new ServiceConfig(serviceConfigElems);

        // Init configuration directory
        final GeonetworkDataDirectory dataDirectory = _applicationContext.getBean(GeonetworkDataDirectory.class);
        dataDirectory.init(webappName, appPath, handlerConfig, context.getServlet());

        // Get config handler properties
        String systemDataDir = handlerConfig.getMandatoryValue(Geonet.Config.SYSTEM_DATA_DIR);
        String thesauriDir = handlerConfig.getMandatoryValue(Geonet.Config.CODELIST_DIR);
        String luceneDir = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_DIR);
        String luceneConfigXmlFile = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_CONFIG);

        logger.info("Data directory: " + systemDataDir);

        setProps(appPath, handlerConfig);

        importDatabaseData(context);

        // Status actions class - load it
        String statusActionsClassName = handlerConfig.getMandatoryValue(Geonet.Config.STATUS_ACTIONS_CLASS);
        @SuppressWarnings("unchecked")
        Class<StatusActions> statusActionsClass = (Class<StatusActions>) Class.forName(statusActionsClassName);

        JeevesJCS.setConfigFilename(appPath + "WEB-INF/classes/cache.ccf");

        // force caches to be config'd so shutdown hook works correctly
        JeevesJCS.getInstance(Processor.XLINK_JCS);
        JeevesJCS.getInstance(XmlResolver.XMLRESOLVER_JCS);

        //------------------------------------------------------------------------
        //--- initialize thread pool

        logger.info("  - Thread Pool...");

        threadPool = new ThreadPool();

        //------------------------------------------------------------------------
        //--- initialize settings subsystem

        logger.info("  - Setting manager...");

        SettingManager settingMan = this._applicationContext.getBean(SettingManager.class);

        //--- initialize ThreadUtils with setting manager and rm props
        final DataSource dataSource = context.getBean(DataSource.class);
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
            ThreadUtils.init(conn.getMetaData().getURL(), settingMan);
        } finally {
            if (conn != null) {
                conn.close();
            }
        }


        //------------------------------------------------------------------------
        //--- initialize Z39.50

        logger.info("  - Z39.50...");

        boolean z3950Enable = settingMan.getValueAsBool("system/z3950/enable", false);
        String z3950port = settingMan.getValue("system/z3950/port");

        logger.info("     - Z39.50 is enabled: " + z3950Enable);
        if (z3950Enable) {
            // build Z3950 repositories file first from template
            URL url = getClass().getClassLoader().getResource(Geonet.File.JZKITCONFIG_TEMPLATE);

            if (Repositories.build(url, context)) {
                logger.info("     Repositories file built from template.");

                try {
                    ConfigurableApplicationContext appContext = context.getApplicationContext();

                    // to have access to the GN context in spring-managed objects
                    ContextContainer cc = (ContextContainer) appContext.getBean("ContextGateway");
                    cc.setSrvctx(context);

                    if (!z3950Enable) {
                        logger.info("     Server is Disabled.");
                    } else {
                        logger.info("     Server is Enabled.");

                        Server.init(z3950port, appContext);
                    }
                } catch (Exception e) {
                    logger.error("     Repositories file init FAILED - Z3950 server disabled and Z3950 client services (remote search, " +
                                 "harvesting) may not work. Error is:" + e.getMessage());
                    e.printStackTrace();
                }

            } else {
                logger.error("     Repositories file builder FAILED - Z3950 server disabled and Z3950 client services (remote search, " +
                             "harvesting) may not work.");
            }
        }
        //------------------------------------------------------------------------
        //--- initialize SchemaManager

        logger.info("  - Schema manager...");

        String schemaPluginsDir = dataDirectory.getSchemaPluginsDir().getAbsolutePath();
        String schemaCatalogueFile = dataDirectory.getConfigDir()+File.separator+Geonet.File.SCHEMA_PLUGINS_CATALOG;
        boolean createOrUpdateSchemaCatalog = handlerConfig.getMandatoryValue(Geonet.Config.SCHEMA_PLUGINS_CATALOG_UPDATE).equals("true");
        logger.info("      - Schema plugins directory: " + schemaPluginsDir);
        logger.info("      - Schema Catalog File     : " + schemaCatalogueFile);
        SchemaManager schemaMan = _applicationContext.getBean(SchemaManager.class);
        schemaMan.configure(_applicationContext, appPath, Resources.locateResourcesDir(context), schemaCatalogueFile,
                schemaPluginsDir, context.getLanguage(), handlerConfig.getMandatoryValue(Geonet.Config.PREFERRED_SCHEMA),
                createOrUpdateSchemaCatalog);

        //------------------------------------------------------------------------
        //--- initialize search and editing

        logger.info("  - Search...");

        boolean logSpatialObject = "true".equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_SPATIAL_OBJECTS));
        boolean logAsynch = "true".equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_ASYNCH));
        logger.info("  - Log spatial object: " + logSpatialObject);
        logger.info("  - Log in asynch mode: " + logAsynch);

        String luceneTermsToExclude = "";
        luceneTermsToExclude = handlerConfig.getMandatoryValue(Geonet.Config.STAT_LUCENE_TERMS_EXCLUDE);

        LuceneConfig lc = _applicationContext.getBean(LuceneConfig.class);
        lc.configure(luceneConfigXmlFile);
        logger.info("  - Lucene configuration is:");
        logger.info(lc.toString());

        try {
            _applicationContext.getBean(DataStore.class);
        } catch (NoSuchBeanDefinitionException e) {
            DataStore dataStore = createShapefileDatastore(luceneDir);
            _applicationContext.getBeanFactory().registerSingleton("dataStore", dataStore);
            //--- no datastore for spatial indexing means that we can't continue
            if (dataStore == null) {
                throw new IllegalArgumentException("GeoTools datastore creation failed - check logs for more info/exceptions");
            }
        }

        String maxWritesInTransactionStr = handlerConfig.getMandatoryValue(Geonet.Config.MAX_WRITES_IN_TRANSACTION);
        int maxWritesInTransaction = SpatialIndexWriter.MAX_WRITES_IN_TRANSACTION;
        try {
            maxWritesInTransaction = Integer.parseInt(maxWritesInTransactionStr);
        } catch (NumberFormatException nfe) {
            logger.error("Invalid config parameter: maximum number of writes to spatial index in a transaction (maxWritesInTransaction)"
                         + ", Using " + maxWritesInTransaction + " instead.");
            nfe.printStackTrace();
        }

        SettingInfo settingInfo = context.getBean(SettingInfo.class);
        searchMan = _applicationContext.getBean(SearchManager.class);
        searchMan.init(logAsynch,
                logSpatialObject, luceneTermsToExclude,
                maxWritesInTransaction);


        // if the validator exists the proxyCallbackURL needs to have the external host and
        // servlet name added so that the cas knows where to send the validation notice
        ServerBeanPropertyUpdater.updateURL(settingInfo.getSiteUrl(true) + baseURL, _applicationContext);

        //------------------------------------------------------------------------
        //--- extract intranet ip/mask and initialize AccessManager

        logger.info("  - Access manager...");

        //------------------------------------------------------------------------
        //--- get edit params and initialize DataManager

        logger.info("  - Xml serializer and Data manager...");

        SvnManager svnManager = _applicationContext.getBean(SvnManager.class);
        XmlSerializer xmlSerializer = _applicationContext.getBean(XmlSerializer.class);

        if (xmlSerializer instanceof XmlSerializerSvn && svnManager != null) {
            svnManager.setContext(context);
            String subversionPath = dataDirectory.getMetadataRevisionDir().getCanonicalPath();
            svnManager.setSubversionPath(subversionPath);
            svnManager.init();
        }

        /**
         * Initialize language detector
         */
        LanguageDetector.init(appPath + _applicationContext.getBean(Geonet.Config.LANGUAGE_PROFILES_DIR, String.class));

        //------------------------------------------------------------------------
        //--- Initialize thesaurus

        logger.info("  - Thesaurus...");

        _applicationContext.getBean(ThesaurusManager.class).init(context, appPath, thesauriDir);


        //------------------------------------------------------------------------
        //--- initialize catalogue services for the web

        logger.info("  - Open Archive Initiative (OAI-PMH) server...");

        OaiPmhDispatcher oaipmhDis = new OaiPmhDispatcher(settingMan, schemaMan);


        GeonetContext gnContext = new GeonetContext(_applicationContext, false, statusActionsClass, threadPool);

        //------------------------------------------------------------------------
        //--- return application context

        beanFactory.registerSingleton("serviceHandlerConfig", handlerConfig);
        beanFactory.registerSingleton("oaipmhDisatcher", oaipmhDis);


        _applicationContext.getBean(DataManager.class).init(context, false);
        _applicationContext.getBean(HarvestManager.class).init(context, gnContext.isReadOnly());

        _applicationContext.getBean(ThumbnailMaker.class).init(context);

        logger.info("Site ID is : " + settingMan.getSiteId());

        // Creates a default site logo, only if the logo image doesn't exists
        // This can happen if the application has been updated with a new version preserving the database and
        // images/logos folder is not copied from old application
        createSiteLogo(settingMan.getSiteId(), context, context.getAppPath());


        // Notify unregistered metadata at startup. Needed, for example, when the user enables the notifier config
        // to notify the existing metadata in database
        // TODO: Fix DataManager.getUnregisteredMetadata and uncomment next lines
        metadataNotifierControl = new MetadataNotifierControl(context);
        metadataNotifierControl.runOnce();

        //--- load proxy information from settings into Jeeves for observers such
        //--- as jeeves.utils.XmlResolver to use
        ProxyInfo pi = JeevesProxyInfo.getInstance();
        boolean useProxy = settingMan.getValueAsBool("system/proxy/use", false);
        if (useProxy) {
            String proxyHost = settingMan.getValue("system/proxy/host");
            String proxyPort = settingMan.getValue("system/proxy/port");
            String username = settingMan.getValue("system/proxy/username");
            String password = settingMan.getValue("system/proxy/password");
            pi.setProxyInfo(proxyHost, Integer.valueOf(proxyPort), username, password);
        }

        //
        // db heartbeat configuration -- for failover to readonly database
        //
        boolean dbHeartBeatEnabled = Boolean.parseBoolean(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_ENABLED, "false"));
        if (dbHeartBeatEnabled) {
            Integer dbHeartBeatInitialDelay = Integer.parseInt(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_INITIALDELAYSECONDS,
                    "5"));
            Integer dbHeartBeatFixedDelay = Integer.parseInt(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_FIXEDDELAYSECONDS, "60"));
            createDBHeartBeat(gnContext, dbHeartBeatInitialDelay, dbHeartBeatFixedDelay);
        }
        return gnContext;
    }
View Full Code Here

    protected void assertSuccessfulAdd(Element result) {
        assertEquals("success", result.getChildText("status"));
    }

    public void init(AbstractSchematronService service, SchematronServiceAction action) throws Exception {
        ServiceConfig params = new ServiceConfig(Arrays.asList(createServiceConfigParam(Params.ACTION, action.toString())));
        service.init(getWebappDir(AbstractSchematronServiceIntegrationTest.class), params);
    }
View Full Code Here

        final SyncReport syncReport = synchronizeDataDirectory(
                new File(webappDir, "WEB-INF/data"));

        final ArrayList<Element> params = getServiceConfigParameterElements();

        final ServiceConfig serviceConfig = new ServiceConfig(params);

        try {
            _applicationContext.getBean(initializedString);
        } catch (NoSuchBeanDefinitionException e) {
            SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
View Full Code Here

                .addContent(new Element("from").setText("1"))
                .addContent(new Element("to").setText("50"))
                .addContent(new Element("abstract").setText(""+ _abstractSearchTerm))
                .addContent(new Element("sortOrder").setText("reverse"))
                .addContent(new Element("sortBy").setText("_title"));
        final ServiceConfig config = new ServiceConfig();
        _luceneSearcher.search(_serviceContext, request, config);
        final Element result = _luceneSearcher.present(_serviceContext, request, config);
        final List<Element> nodes = (List<Element>) Xml.selectNodes(result, "metadata/title");
        String[] titles = new String[nodes.size()];
        for (int i = 0; i < titles.length; i++) {
View Full Code Here

                .addContent(new Element("from").setText("1"))
                .addContent(new Element("to").setText("50"))
                .addContent(new Element("abstract").setText(""+ _abstractSearchTerm))
                .addContent(new Element("sortOrder").setText("reverse"))
                .addContent(new Element("sortBy").setText("_title"));
        final ServiceConfig config = new ServiceConfig();
        _luceneSearcher.search(_serviceContext, request, config);
        final Element result = _luceneSearcher.present(_serviceContext, request, config);
        final List<Element> nodes = (List<Element>) Xml.selectNodes(result, "metadata/geonet:info/id", Arrays.asList(Edit.NAMESPACE));
        String[] titles = new String[nodes.size()];
        for (int i = 0; i < titles.length; i++) {
View Full Code Here

        //--- create instance

        Service service = (Service) Class.forName(name).newInstance();

        service.init(appPath, new ServiceConfig(clas.getChildren(ConfigFile.Class.Child.PARAM)));

        return service;
    }
View Full Code Here

TOP

Related Classes of jeeves.server.ServiceConfig

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.