Package org.apache.xindice.util

Examples of org.apache.xindice.util.Configuration


         colEle.appendChild(filEle);
      }
     
      CollectionManager colman = getCollection((String) message.get(COLLECTION));

      Configuration config = new Configuration(doc.getDocumentElement(),false);    
      colman.createCollection( (String) message.get(NAME), config );

      Hashtable result = new Hashtable();
      result.put(RESULT, (String) message.get(NAME));
      return result;
View Full Code Here


         throw new ServletException("Could not load database configuration", e);
      }

      // The configuration is wrapped in a <xindice> element so we need to get
      // the "root-collection" configuration.
      Configuration conf = new Configuration(configuration, false);
      try {
         conf = conf.getChild("root-collection", false);
         if (conf != null) {
           
            // We need to ensure that the database points to a place where it makes
            // sense. If the path in the system.xml file is an absolute path, then
            // honor it. If it's not, we first check for the system property "xindice.db.home"
            // and if the lookup is successful we use it as the database root parent. If
            // the property is not set, we use /WEB-INF relative to the servlet context, unless
            // the war has not been unpacked. In this case, we throw an exception and
            // ask the user to specify the location of database root
           
            String dbRoot = conf.getAttribute(Database.DBROOT, "./db/");
            File dbRootDir = new File(dbRoot);
           
            if (dbRootDir.isAbsolute()) {
              db.setConfig(conf)
            } else {             
        // OK, no absolute path. We have to perform some checks.
       
                // Stupid hack but spec compliant. If getRealPath() returns null
                // the war archive has not been unpacked.
                String realPath = config.getServletContext().getRealPath("/WEB-INF");
       
        // Let's see if the property was specified.
        String home = System.getProperty("xindice.db.home");             
             
              if (home != null) {               
                conf.setAttribute(Database.DBROOT, home + System.getProperty("file.separator") + dbRoot);
              } else if (realPath != null) {
                if (log.isWarnEnabled())
                  log.warn("The database root directory has been set to "
                    + realPath + System.getProperty("file.separator") + dbRoot
                    + ". Keep in mind that if a war upgrade will take place the database"
                    + " will be lost.");
                conf.setAttribute(Database.DBROOT, realPath + System.getProperty("file.separator") + dbRoot)
              } else {    
                log.fatal("The database configuration points to a relative path, "
                  + "but there was no xindice.home property set. "
                  + "Furthermore, the war was not unpacked by the application server "
                  + "so Xindice was unable to find a database location "
View Full Code Here

   }

   protected void initFiler()
         throws Exception {
      filer.setLocation(new File(FilerTestCase.TEST_COLLECTION_NAME), FilerTestCase.TEST_COLLECTION_NAME);
      filer.setConfig(new Configuration(DOMParser.toDocument("<filer location=\"tests\"/>")));
      if (!filer.exists()) {
         filer.create();
      }

      filer.open();
View Full Code Here

      if ( config.getBooleanAttribute(CACHE, true) )
         documentCache = getDatabase().getDocumentCache();

      // If no Filer is defined, skip Symbols and Indexes
      Configuration filerConfig = config.getChild(FILER);
      if ( filerConfig != null ) {

         // Symbol Table Setup
         Configuration symConfig = config.getChild(SYMBOLS);
         internalSymbols = (symConfig != null);
         if ( internalSymbols ) {
            try {
               symbols = new SymbolTable(symConfig.getElement());
            }
            catch ( Exception e ) {
               if (log.isDebugEnabled()) {
                  log.debug("No message", e);
               }
            }
         }
         else {
            try {
               symbols = getSystemCollection().loadSymbols(this);
            }
            catch ( Exception e ) {
               if (log.isDebugEnabled()) {
                  log.debug("No message", e);
               }
            }
         }

         String className = filerConfig.getAttribute(CLASS);
         try {
            filer = (Filer)Class.forName(className).newInstance();
//            filer.setCollection(this);
            filer.setLocation(getCollectionRoot(), getName());
            filer.setConfig(filerConfig);
            if ( !filer.exists() )
               filer.create();
            filer.open();
         }
         catch ( Exception e ) {
            if (log.isWarnEnabled()) {
               log.warn("Filer '"+className+"' not available", e);
            }
         }

         // Index Manager
         try {
            indexManager = new IndexManager(this);
            Configuration idxConfig = config.getChild(INDEXES, true);
            indexManager.setConfig(idxConfig);
         }
         catch ( Exception e ) {
            if (log.isDebugEnabled()) {
               log.debug("No message", e);
View Full Code Here

      if (log.isInfoEnabled()) {
         log.info("Database points to " + dbrootDir.getAbsolutePath());
      }

      try {
         Configuration queryCfg = config.getChild(QUERYENGINE);
         if ( queryCfg != null )
            engine.setConfig(queryCfg);
      }
      catch ( Exception e ) {
         if (log.isDebugEnabled()) {
            log.debug("No message", e);
         }
      }

      if ( !sysInit ) {
         sysCol = new SystemCollection(this);

         try {
            sysCol.init();
         }
         catch ( XindiceException e ) {
            if (log.isDebugEnabled()) {
               log.debug("No message", e);
            }
         }

         collections.put(sysCol.getName(), sysCol);
         sysInit = true;
      }

      try {
         // Bootstrap from the database itself...  This is accomplished
         // by intercepting the setConfig call and using a Configuration
         // retrieved from the database instead of the standard config
         Document colDoc = sysCol.getCollection(SystemCollection.CONFIGS).getDocument(COLKEY);
         if ( colDoc == null ) {
            DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            colDoc = db.newDocument();
            Element root = colDoc.createElement(DATABASE);
            root.setAttribute(NAME, name);
            colDoc.appendChild(root);
            sysCol.getCollection(SystemCollection.CONFIGS).setDocument(COLKEY, colDoc);
         }

         super.setConfig(new Configuration(colDoc.getDocumentElement(), false));
      }
      catch ( Exception e ) {
         if (log.isDebugEnabled()) {
            log.debug("No message", e);
         }
View Full Code Here

       + "   </collections>"
       + "</collection>";

      try {
         Document sysDoc = DOMParser.toDocument(SysCol);
         Configuration sysCfg = new Configuration(sysDoc, false);
         setConfig(sysCfg);
      }
      catch ( Exception e ) {
         if (log.isFatalEnabled()) {
            log.fatal("FATAL ERROR: Generating System Collection '"+SYSCOL+"'", e);
View Full Code Here

        super(name);
    }

    public void setUp() throws Exception {
        db = new Database();
        db.setConfig(new Configuration(DOMParser.toDocument(DATABASE)));
        configurationA = new Configuration(DOMParser.toDocument(COLLECTIONA));
        configurationB = new Configuration(DOMParser.toDocument(COLLECTIONB));
        configurationC = new Configuration(DOMParser.toDocument(COLLECTIONC));
    }
View Full Code Here

  }

    public void setUp() throws Exception {
        String name = getClass().getName();
        db = new Database();
        db.setConfig(new Configuration(DOMParser.toDocument(DatabaseTest.DATABASE)));
        collection = db.createCollection(name, new Configuration(
                DOMParser.toDocument(
                        "<collection compressed=\"true\" name=\"" + name + "\" inline-metadata=\"true\">" +
                            "<filer class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"true\"/>" +
                        "</collection>"), false
        ));
View Full Code Here

            if (getCollection(n) != null) {
                throw new DBException(FaultCodes.COL_DUPLICATE_COLLECTION,
                                      "Duplicate Collection '" + n + "'");
            }

            Configuration colConfig = this.config.getChild(COLLECTIONS, true);
            colConfig.add(cfg);

            collection.setConfig(cfg);
            collection.create();
            collections.put(n, collection);
            if (log.isInfoEnabled()) {
View Full Code Here

     *
     * @throws IOException
     * @throws XindiceException
     */
    private void init() throws IOException, XindiceException {
        Configuration config = loadConfiguration();

        this.database = Database.getDatabase(config);
        if (null == this.database) {
            log.fatal("Unable to configure database");
            throw new XindiceException("Unable to configure database");
View Full Code Here

TOP

Related Classes of org.apache.xindice.util.Configuration

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.