Package com.kolich.havalo.exceptions

Examples of com.kolich.havalo.exceptions.BootstrapException


            if(adminUUID == null) {
                final String msg = "Config property '" +
                    HAVALO_ADMIN_API_UUID_PROPERTY + "' not set. Cannot " +
                    "start until this property contains a valid UUID.";
                logger__.error(msg);
                throw new BootstrapException(msg);
            } else {
                try {
                    UUID.fromString(adminUUID);
                } catch (Exception e) {
                    logger__.error("Config property '" +
                        HAVALO_ADMIN_API_UUID_PROPERTY + "' was set, but " +
                        "did not contain a valid UUID. Cannot " +
                        "start until this property contains a well " +
                        "formed UUID.", e);
                    throw new BootstrapException(e);
                }
            }
            // Verify a proper admin API accout secret is set.
            final String adminSecret = getHavaloAdminSecret();
            if(adminSecret == null) {
                final String msg = "Config property '" +
                    HAVALO_ADMIN_API_SECRET_PROPERTY + "' not set. Cannot " +
                    "start until this property contains a valid secret.";
                logger__.error(msg);
                throw new BootstrapException(msg);
            }
            logger__.debug("Admin API account initialized (uuid=" + adminUUID +
                ", secret=" + abbreviate(adminSecret, 8) + ")");
            // Create a new keypair for the default ADMIN level user.
            final KeyPair adminKeyPair = new KeyPair(new HavaloUUID(adminUUID),
                adminSecret, Arrays.asList(new UserRole[]{ADMIN}));
            // Actually attempt to create a new Repository for the Admin user.
            // This should work, if not, bail the whole app.
            repoManager.createRepository(adminKeyPair.getKey(), adminKeyPair);
            return repoManager;
        } catch (RepositoryCreationException e) {
            // Log in TRACE and continue silently.  This is a normal case,
            // when the admin repo has already been created on firstboot
            // but Havalo is being re-started.
            logger__.trace("Failed to create ADMIN user repository -- " +
                "repository already exists.", e);
        } catch (Exception e) {
            // Hm, something else went wrong on startup, need to log
            // and then bail.  The application cannot continue at this point.
            logger__.error("Failed to create ADMIN user repository -- " +
                "cannot continue, giving up.", e);
            throw new BootstrapException(e);
        }
        return repoManager;
    }
View Full Code Here

TOP

Related Classes of com.kolich.havalo.exceptions.BootstrapException

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.