/* * * ProLinga-Repository * * Copyright (C) 2002-2010 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Repository. * * ProLinga-Repository is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Repository is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Repository. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RepCommon.h" #include #include "RepConfig.hpp" using namespace DbXml; void Usage(const char *progName) { printf("Usage : %s [ [--version] || [--config file_name] repository_name ] \n", progName); } int main(int argc, char *argv[]) { char *systemPath; char *configFileName = (char *)DEF_CONFIG_FILE; char *repositoryName = NULL; ConfigRepPtr confRepPtr; int i; DB_ENV *env; XmlManager mgr; XmlContainer container; XmlUpdateContext uc; /* Process command line arguments */ if (argc <= 1) { Usage(argv[0]); return 0; } for (i=1;i= argc) { Usage(argv[0]); return 0; } i++; configFileName = argv[i]; } else { if (repositoryName != NULL) { Usage(argv[0]); return 0; } repositoryName = argv[i]; } } /* Return if no repository name given */ if (repositoryName == NULL) { Usage(argv[0]); return 0; } /* Get Config */ confRepPtr = new ConfigRep(configFileName); try { /* Set DB environment */ //env = new DbEnv(0); db_env_create(&env,0); /* Create Repository if not present */ systemPath = confRepPtr->getStringValue("SystemPath", DEF_SYSTEM_PATH); //env->open(env,systemPath, DB_CREATE|DB_INIT_MPOOL, 0); env->open(env, systemPath, DB_CREATE|DB_INIT_MPOOL, 0); mgr = XmlManager(env, DBXML_ADOPT_DBENV); mgr.setDefaultContainerType(XmlContainer::WholedocContainer); container = mgr.createContainer(repositoryName); uc = mgr.createUpdateContext(); /* Declare index for application name */ container.addIndex( "", "Application", "node-attribute-equality-string", uc); container.addIndex( "", "Application", "node-attribute-substring-string", uc); /* Declare index for object type */ container.addIndex( "", "Type", "node-attribute-equality-string", uc); container.addIndex( "", "Type", "node-attribute-substring-string", uc); /* Declare index for object name */ container.addIndex( "", "Name", "node-attribute-equality-string", uc); container.addIndex( "", "Name", "node-attribute-substring-string", uc); /* Flush Repository */ container.sync(); // env->close(env,0); /* Clean up */ delete confRepPtr; } catch(XmlException &e) { std::cerr << e.what() << "\n"; } catch(std::exception &e) { std::cerr << e.what() << "\n"; } return 0; }