Package org.locationtech.geogig.cli

Examples of org.locationtech.geogig.cli.CommandFailedException


            try {
                repository = geogig.command(InitOp.class).setConfig(suppliedConfiguration)
                        .setTarget(targetDirectory).call();
            } catch (IllegalArgumentException e) {
                throw new CommandFailedException(e.getMessage(), e);
            } finally {
                geogig.close();
            }
        }

        File repoDirectory;
        try {
            repoDirectory = new File(repository.getLocation().toURI());
        } catch (URISyntaxException e) {
            throw new CommandFailedException("Environment home can't be resolved to a directory", e);
        }
        String message;
        if (repoExisted) {
            message = "Reinitialized existing Geogig repository in "
                    + repoDirectory.getAbsolutePath();
View Full Code Here


                commitOp.setCommit(geogig.getRepository().getCommit(commitId.get()));
            }
            commit = commitOp.setPathFilters(pathFilters)
                    .setProgressListener(cli.getProgressListener()).call();
        } catch (NothingToCommitException noChanges) {
            throw new CommandFailedException(noChanges.getMessage(), noChanges);
        }
        final ObjectId parentId = commit.parentN(0).or(ObjectId.NULL);

        console.println("[" + commit.getId() + "] " + commit.getMessage());
View Full Code Here

        Ansi ansi = newAnsi(console.getTerminal());

        if (abort) {
            Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
            if (!ref.isPresent()) {
                throw new CommandFailedException("There is no merge to abort <ORIG_HEAD missing>.");
            }

            geogig.command(ResetOp.class).setMode(ResetMode.HARD)
                    .setCommit(Suppliers.ofInstance(ref.get().getObjectId())).call();
            console.println("Merge aborted successfully.");
            return;
        }

        RevCommit commit;
        try {
            MergeOp merge = geogig.command(MergeOp.class);
            merge.setOurs(ours).setTheirs(theirs).setNoCommit(noCommit);
            merge.setMessage(message).setProgressListener(cli.getProgressListener());
            for (String commitish : commits) {
                Optional<ObjectId> commitId;
                commitId = geogig.command(RevParse.class).setRefSpec(commitish).call();
                checkParameter(commitId.isPresent(), "Commit not found '%s'", commitish);
                merge.addCommit(Suppliers.ofInstance(commitId.get()));
            }
            MergeReport report = merge.call();
            commit = report.getMergeCommit();
        } catch (RuntimeException e) {
            if (e instanceof NothingToCommitException || e instanceof IllegalArgumentException
                    || e instanceof IllegalStateException) {
                throw new CommandFailedException(e.getMessage(), e);
            }
            throw e;
        }
        final ObjectId parentId = commit.parentN(0).or(ObjectId.NULL);
View Full Code Here

                cli.getConsole().println("Nothing to push.");
            }
        } catch (SynchronizationException e) {
            switch (e.statusCode) {
            case REMOTE_HAS_CHANGES:
                throw new CommandFailedException(
                        "Push failed: The remote repository has changes that would be lost in the event of a push.",
                        e);
            case HISTORY_TOO_SHALLOW:
                throw new CommandFailedException(
                        "Push failed: There is not enough local history to complete the push.", e);
            case CANNOT_PUSH_TO_SYMBOLIC_REF:
                throw new CommandFailedException(
                        "Push failed: Cannot push to a symbolic reference", e);
            default:
                break;
            }
        }
View Full Code Here

     */
    @Override
    public void runInternal(GeogigCLI cli) {
        if (params == null || params.size() != 2) {
            printUsage(cli);
            throw new CommandFailedException();
        }

        try {
            cli.getGeogig().command(RemoteAddOp.class).setName(params.get(0)).setURL(params.get(1))
                    .setBranch(branch).setUserName(username).setPassword(password).call();
        } catch (RemoteException e) {
            switch (e.statusCode) {
            case REMOTE_ALREADY_EXISTS:
                throw new CommandFailedException("Could not add, a remote called '" + params.get(0)
                        + "' already exists.", e);
            default:
                throw new CommandFailedException(e);
            }
        }

    }
View Full Code Here

            } else {
                String[] sp = repoURL.split("/");
                repoDir = new File(currDir, sp[sp.length - 1]).getCanonicalFile();
            }
            if (!repoDir.exists() && !repoDir.mkdirs()) {
                throw new CommandFailedException("Can't create directory "
                        + repoDir.getAbsolutePath());
            }
        }

        GeoGIG geogig = new GeoGIG(cli.getGeogigInjector(), repoDir);
View Full Code Here

            cli.getConsole().println("Import successful.");

        } catch (GeoToolsOpException e) {
            switch (e.statusCode) {
            case TABLE_NOT_DEFINED:
                throw new CommandFailedException(
                        "No tables specified for import. Specify --all or --table <table>.", e);
            case ALL_AND_TABLE_DEFINED:
                throw new CommandFailedException(
                        "Specify --all or --table <table>, both cannot be set.", e);
            case NO_FEATURES_FOUND:
                throw new CommandFailedException("No features were found in the database.", e);
            case TABLE_NOT_FOUND:
                throw new CommandFailedException("Could not find the specified table.", e);
            case UNABLE_TO_GET_NAMES:
                throw new CommandFailedException("Unable to get feature types from the database.",
                        e);
            case UNABLE_TO_GET_FEATURES:
                throw new CommandFailedException("Unable to get features from the database.", e);
            case UNABLE_TO_INSERT:
                throw new CommandFailedException(
                        "Unable to insert features into the working tree.", e);
            case ALTER_AND_ALL_DEFINED:
                throw new CommandFailedException(
                        "Alter cannot be used with --all option and more than one table.", e);
            case INCOMPATIBLE_FEATURE_TYPE:
                throw new CommandFailedException(
                        "The feature type of the data to import does not match the feature type of the destination tree and cannot be imported\n"
                                + "USe the --force-featuretype switch to import using the original featuretype and crete a mixed type tree",
                        e);
            default:
                throw new CommandFailedException("Import failed with exception: "
                        + e.statusCode.name(), e);
            }
        } finally {
            dataStore.dispose();
            cli.getConsole().flush();
View Full Code Here

            cli.getConsole().println("Fetching table...");

            Optional<Map<String, String>> propertyMap = cli.getGeogig().command(DescribeOp.class)
                    .setTable(table).setDataStore(dataStore).call();
            if (!propertyMap.isPresent()) {
                throw new CommandFailedException("Could not find the specified table.");
            }
            cli.getConsole().println("Table : " + table);
            cli.getConsole().println("----------------------------------------");
            for (Entry<String, String> entry : propertyMap.get().entrySet()) {
                cli.getConsole().println("\tProperty  : " + entry.getKey());
                cli.getConsole().println("\tType      : " + entry.getValue());
                cli.getConsole().println("----------------------------------------");
            }
        } catch (GeoToolsOpException e) {
            switch (e.statusCode) {
            case TABLE_NOT_DEFINED:
                throw new CommandFailedException("No table supplied.", e);
            case UNABLE_TO_GET_FEATURES:
                throw new CommandFailedException("Unable to read the feature source.", e);
            case UNABLE_TO_GET_NAMES:
                throw new CommandFailedException("Unable to read feature types.", e);
            default:
                throw new CommandFailedException("Exception: " + e.statusCode.name(), e);
            }

        } finally {
            dataStore.dispose();
            cli.getConsole().flush();
View Full Code Here

                    cli.getConsole().println("\tProperty  : " + entry.getKey());
                    cli.getConsole().println("\tType      : " + entry.getValue());
                    cli.getConsole().println("----------------------------------------");
                }
            } else {
                throw new CommandFailedException("Could not find the specified table.");
            }
        } catch (GeoToolsOpException e) {
            switch (e.statusCode) {
            case TABLE_NOT_DEFINED:
                throw new CommandFailedException("No table supplied.", e);
            case UNABLE_TO_GET_FEATURES:
                throw new CommandFailedException("Unable to read the feature source.", e);
            case UNABLE_TO_GET_NAMES:
                throw new CommandFailedException("Unable to read feature types.", e);
            default:
                throw new CommandFailedException("Exception: " + e.statusCode.name(), e);
            }

        } finally {
            dataStore.dispose();
            cli.getConsole().flush();
View Full Code Here

            result = fetch.call();
        } catch (SynchronizationException e) {
            switch (e.statusCode) {
            case HISTORY_TOO_SHALLOW:
            default:
                throw new CommandFailedException("Unable to fetch, the remote history is shallow.",
                        e);
            }
        } catch (IllegalArgumentException iae) {
            throw new CommandFailedException(iae.getMessage(), iae);
        } catch (IllegalStateException ise) {
            throw new CommandFailedException(ise.getMessage(), ise);
        }

        ConsoleReader console = cli.getConsole();
        if (result.getChangedRefs().isEmpty()) {
            console.println("Already up to date.");
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.cli.CommandFailedException

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.