public void initializeMetaCollection(Configuration configuration) throws CatalogException { Admin admin = configuration.getAdmin(); admin.setPassword(CatalogAuthenticationManager.cypherPassword(admin.getPassword())); Metadata metadata = new Metadata().setIdCounter(configuration.getCatalog().getOffset()).setVersion(VERSION); Document metadataObject = getMongoDBDocument(metadata, "Metadata"); metadataObject.put(PRIVATE_ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID); Document adminDocument = getMongoDBDocument(admin, "Admin"); metadataObject.put("admin", adminDocument); metaCollection.insert(metadataObject, null); }
public void installCatalogDB(String secretKey, String password) throws CatalogException { if (existsCatalogDB()) { throw new CatalogException("Nothing to install. There already exists a catalog database"); } ParamUtils.checkParameter(secretKey, "secretKey"); ParamUtils.checkParameter(password, "password"); configuration.getAdmin().setPassword(password); configuration.getAdmin().setSecretKey(secretKey); // Check jobs folder is empty URI jobsURI; try { jobsURI = UriUtils.createDirectoryUri(configuration.getTempJobsDir()); } catch (URISyntaxException e) { throw new CatalogException("Failed to create a directory URI from " + configuration.getTempJobsDir()); } CatalogIOManager ioManager = getCatalogIOManagerFactory().get(jobsURI); if (!ioManager.isDirectory(jobsURI) || CollectionUtils.isNotEmpty(ioManager.listFiles(jobsURI))) { throw new CatalogException("Cannot install openCGA. Jobs folder is not empty.\nPlease, empty it first."); } catalogDBAdaptorFactory.installCatalogDB(configuration); }