Package org.locationtech.geogig.web.api

Examples of org.locationtech.geogig.web.api.CommandSpecException


                + " * bbox: Mandatory if {@code filter} is not given. The bounding box to use as filter, in WGS84 coordinates. Format: {@code <S>,<W>,<N>,<E>}.\n"
                + " * message: Message for the commit to create.\n"
                + " * update: Boolean. Default: false. Update the OSM data currently in the geogig repository.\n"
                + " * rebase: Boolean. Default: false. Use rebase instead of merge when updating. Can only be true of update is true.\n"
                + " * mapping: The file that contains the data mapping to use\n";
        throw new CommandSpecException(msg);
    }
View Full Code Here


                    + " * add: Optional. true|false. Default: false. If true, do not remove previous data before importing.\n"
                    + " * mapping: Optional. Location of mapping file in the server filesystem\n"
                    + " * noRaw: Optional. true|false. Default: false. If true, do not import raw data when using a mapping\n"
                    + " * message: Optional. Message for the commit to create.";

            throw new CommandSpecException(msg);
        }

        OSMImportOp command = context.command(OSMImportOp.class);
        command.setAdd(add);
        command.setDataSource(urlOrFilepath);
View Full Code Here

        }

        Representation getRepresentation(MediaType format, String callback) {
            if (streamContent != null) {
                if (format != CSV_MEDIA_TYPE) {
                    throw new CommandSpecException(
                            "Unsupported Media Type: This response is only compatible with text/csv.");
                }
                return new StreamWriterRepresentation(format, streamContent);
            }
            if (format != MediaType.APPLICATION_JSON && format != MediaType.APPLICATION_XML) {
                throw new CommandSpecException(
                        "Unsupported Media Type: This response is only compatible with application/json and application/xml.");
            }
            return new JettisonRepresentation(format, responseContent, callback);
        }
View Full Code Here

                .call();
        RevCommit commit = null;
        if (object.isPresent() && object.get() instanceof RevCommit) {
            commit = (RevCommit) object.get();
        } else {
            throw new CommandSpecException("Couldn't resolve id: " + commitId.toString()
                    + " to a commit");
        }

        object = geogig.command(RevObjectParse.class).setObjectId(commit.getTreeId()).call();

        if (object.isPresent()) {
            RevTree tree = (RevTree) object.get();
            return geogig.command(FindTreeChild.class).setParent(tree).setChildPath(path).call();
        } else {
            throw new CommandSpecException("Couldn't resolve commit's treeId");
        }
    }
View Full Code Here

        }
    }

    private void remoteAdd(CommandContext context, final Context geogig) {
        if (remoteName == null || remoteName.trim().isEmpty()) {
            throw new CommandSpecException("No remote was specified.");
        } else if (remoteURL == null || remoteURL.trim().isEmpty()) {
            throw new CommandSpecException("No URL was specified.");
        }
        final Remote remote;
        try {
            remote = geogig.command(RemoteAddOp.class).setName(remoteName).setURL(remoteURL)
                    .setUserName(username).setPassword(password).call();
View Full Code Here

        }
    }

    private void remoteUpdate(CommandContext context, final Context geogig) {
        if (remoteName == null || remoteName.trim().isEmpty()) {
            throw new CommandSpecException("No remote was specified.");
        } else if (remoteURL == null || remoteURL.trim().isEmpty()) {
            throw new CommandSpecException("No URL was specified.");
        }
        final Remote newRemote;
        try {
            if (newName != null && !newName.trim().isEmpty() && !newName.equals(remoteName)) {
                newRemote = geogig.command(RemoteAddOp.class).setName(newName).setURL(remoteURL)
View Full Code Here

        }
    }

    private void remoteRemove(CommandContext context, final Context geogig) {
        if (remoteName == null || remoteName.trim().isEmpty()) {
            throw new CommandSpecException("No remote was specified.");
        }
        final Remote remote;
        try {
            remote = geogig.command(RemoteRemoveOp.class).setName(remoteName).call();
        } catch (RemoteException e) {
View Full Code Here

     * @throws CommandSpecException
     */
    @Override
    public void run(CommandContext context) {
        if (this.getTransactionId() == null) {
            throw new CommandSpecException(
                    "No transaction was specified, add requires a transaction to preserve the stability of the repository.");
        }
        final Context geogig = this.getCommandLocator(context);

        AddOp command = geogig.command(AddOp.class);
View Full Code Here

     * @throws CommandSpecException
     */
    @Override
    public void run(CommandContext context) {
        if (this.getTransactionId() == null) {
            throw new CommandSpecException(
                    "No transaction was specified, remove requires a transaction to preserve the stability of the repository.");
        }
        if (this.path == null) {
            throw new CommandSpecException("No path was specified for removal.");
        }

        final Context geogig = this.getCommandLocator(context);
        RemoveOp command = geogig.command(RemoveOp.class);

        NodeRef.checkValidPath(path);

        Optional<NodeRef> node = geogig.command(FindTreeChild.class)
                .setParent(geogig.workingTree().getTree()).setIndex(true).setChildPath(path)
                .call();
        if (node.isPresent()) {
            NodeRef nodeRef = node.get();
            if (nodeRef.getType() == TYPE.TREE) {
                if (!recursive) {
                    throw new CommandSpecException(
                            "Recursive option must be used to remove a tree.");
                }
            }
        }

View Full Code Here

        Optional<ObjectId> commit = Optional.absent();
        if (branchOrCommit != null) {
            commit = geogig.command(RevParse.class).setRefSpec(branchOrCommit).call();
            if (!commit.isPresent()) {
                throw new CommandSpecException("Could not resolve branch or commit");
            }
        }

        try {
            final BlameReport report = geogig.command(BlameOp.class).setPath(path)
                    .setCommit(commit.orNull()).call();

            context.setResponseContent(new CommandResponse() {
                @Override
                public void write(ResponseWriter out) throws Exception {
                    out.start();
                    try {
                        out.writeBlameReport(report);
                    } catch (XMLStreamException e) {
                        throw new CommandSpecException("Error writing stream.");
                    }
                    out.finish();
                }
            });
        } catch (BlameException e) {
            switch (e.statusCode) {
            case PATH_NOT_FEATURE:
                throw new CommandSpecException("The supplied path does not resolve to a feature");
            case FEATURE_NOT_FOUND:
                throw new CommandSpecException("The supplied path does not exist");
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.web.api.CommandSpecException

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.