<commit_before>/*
 *  eXist Open Source Native XML Database
 *  Copyright (C) 2001-07 The eXist Project
 *  http://exist-db.org
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 *  $Id$
 */

package org.exist;

import org.exist.security.User;
import org.exist.xmldb.DatabaseInstanceManager;
import org.exist.xmldb.UserManagementService;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.XMLDBException;

/**
 * Initial database setup: called from the installer to set the admin password.
 */
public class Setup {

    private final static String DRIVER = "org.exist.xmldb.DatabaseImpl";
    private final static String URI = "xmldb:exist:///db";

    public static void main(String[] args) {
        if (args.length < 1 || args[0].length() == 0) {
            System.err.println("No password specified. Aborting.");
            return;
        }
        initDb(args[0]);
        shutdown(args[0]);
    }

    private static void initDb(String adminPass) {
        System.out.println("--- Starting embedded database instance ---");
        try {
            Class cl = Class.forName(DRIVER);
            Database database = (Database) cl.newInstance();
            database.setProperty("create-database", "true");
            DatabaseManager.registerDatabase(database);
            Collection root = DatabaseManager.getCollection(URI, "admin", "");
            UserManagementService service =
                    (UserManagementService) root.getService("UserManagementService", "1.0");
            User admin = service.getUser("admin");
            admin.setPassword(<PASSWORD>);
            System.out.println("Setting admin user password...");
            service.updateUser(admin);
        } catch (Exception e) {<commit_msg>[ignore] changed irritating installer message if no password was specified for the admin user.<commit_after>/*
 *  eXist Open Source Native XML Database
 *  Copyright (C) 2001-07 The eXist Project
 *  http://exist-db.org
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 *  $Id$
 */

package org.exist;

import org.exist.security.User;
import org.exist.xmldb.DatabaseInstanceManager;
import org.exist.xmldb.UserManagementService;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.XMLDBException;

/**
 * Initial database setup: called from the installer to set the admin password.
 */
public class Setup {

    private final static String DRIVER = "org.exist.xmldb.DatabaseImpl";
    private final static String URI = "xmldb:exist:///db";

    public static void main(String[] args) {
        if (args.length < 1 || args[0].length() == 0) {
            System.err.println("No password specified. Admin password will be empty.");
            return;
        }
        initDb(args[0]);
        shutdown(args[0]);
    }

    private static void initDb(String adminPass) {
        System.out.println("--- Starting embedded database instance ---");
        try {
            Class cl = Class.forName(DRIVER);
            Database database = (Database) cl.newInstance();
            database.setProperty("create-database", "true");
            DatabaseManager.registerDatabase(database);
            Collection root = DatabaseManager.getCollection(URI, "admin", "");
            UserManagementService service =
                    (UserManagementService) root.getService("UserManagementService", "1.0");
            User admin = service.getUser("admin");
            admin.setPassword(<PASSWORD>);
            System.out.println("Setting admin user password...");
            service.updateUser(admin);
        } catch (Exception e) {
{'fraction_non_alphanumeric': 0.09889255877210025, 'fraction_numerical': 0.009714396735962697, 'mean_word_length': 2.9630484988452657, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1518627', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1360, 'n_words': 483}