Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.GeoGIG


    private boolean dryRun;

    @Override
    public void runInternal(GeogigCLI cli) throws IOException {
        final ConsoleReader console = cli.getConsole();
        final GeoGIG geogig = cli.getGeogig();

        String pathFilter = null;
        if (!path.isEmpty()) {
            pathFilter = path.get(0);
        }

        if (dryRun) {
            if (pathFilter != null) {
                // check that is a valid path
                Repository repository = cli.getGeogig().getRepository();
                NodeRef.checkValidPath(pathFilter);

                Optional<NodeRef> ref = repository.command(FindTreeChild.class).setIndex(true)
                        .setParent(repository.workingTree().getTree()).setChildPath(pathFilter)
                        .call();

                checkParameter(ref.isPresent(), "pathspec '%s' did not match any tree", pathFilter);
                checkParameter(ref.get().getType() == TYPE.TREE,
                        "pathspec '%s' did not resolve to a tree", pathFilter);
            }
            Iterator<DiffEntry> unstaged = geogig.command(DiffWorkTree.class).setFilter(pathFilter)
                    .call();
            while (unstaged.hasNext()) {
                DiffEntry entry = unstaged.next();
                if (entry.changeType() == ChangeType.ADDED) {
                    console.println("Would remove " + entry.newPath());
                }
            }
        } else {
            geogig.command(CleanOp.class).setPath(pathFilter).call();
            console.println("Clean operation completed succesfully.");
        }
    }
View Full Code Here


        super.setContext(context);
        assert context != null;

        Map<String, Object> attributes = context.getAttributes();

        GeoGIG geogig;
        if (attributes.containsKey("geogig")) {
            geogig = (GeoGIG) attributes.get("geogig");
        } else {
            // revisit, not used at all
            // ServletContext sc = (ServletContext) dispatcher.getContext()
View Full Code Here

    static GeoGIG loadGeoGIG(String repo) {
        Platform platform = new DefaultPlatform();
        platform.setWorkingDir(new File(repo));
        Context inj = GlobalContextBuilder.builder.build();
        GeoGIG geogig = new GeoGIG(inj, platform.pwd());

        if (geogig.command(ResolveGeogigDir.class).call().isPresent()) {
            geogig.getRepository();
            return geogig;
        }

        return geogig;
    }
View Full Code Here

        return geogig;
    }

    static void startServer(String repo) throws Exception {
        GeoGIG geogig = loadGeoGIG(repo);
        org.restlet.Context context = new org.restlet.Context();
        Application application = new Main(geogig);
        application.setContext(context);
        Component comp = new Component();
        comp.getDefaultHost().attach(application);
View Full Code Here

            throw Throwables.propagate(e);
        }
        Preconditions.checkArgument("2.0".equals(json.get("jsonrpc").getAsString()));
        Optional<GeoGIG> providedGeogig = RESTUtils.getGeogig(request);
        checkArgument(providedGeogig.isPresent());
        final GeoGIG geogig = providedGeogig.get();
        JsonObject response;
        if (!checkConsoleEnabled(geogig.getContext())) {
            response = serviceDisabled(json);
        } else {
            response = processRequest(json, geogig);
        }
        getResponse().setEntity(response.toString(), MediaType.APPLICATION_JSON);
View Full Code Here

    protected void runInternal(GeogigCLI cli) throws InvalidParameterException,
            CommandFailedException, IOException {

        String loc = repo != null && repo.size() > 0 ? repo.get(0) : ".";

        GeoGIG geogig = loadGeoGIG(loc, cli);
        Application application = new Main(geogig);

        Component comp = new Component();

        comp.getDefaultHost().attach(application);
View Full Code Here

    GeoGIG loadGeoGIG(String repo, GeogigCLI cli) {
        Platform platform = new DefaultPlatform();
        platform.setWorkingDir(new File(repo));

        GeoGIG geogig = new GeoGIG(cli.getGeogigInjector(), platform.pwd());
        if (geogig.command(ResolveGeogigDir.class).call().isPresent()) {
            geogig.getRepository();
        }

        return geogig;
    }
View Full Code Here

            Optional<String> commit = Optional
                    .fromNullable(options.getFirstValue("commitId", null));

            Optional<GeoGIG> geogig = getGeogig(request);
            Preconditions.checkState(geogig.isPresent());
            GeoGIG ggit = geogig.get();

            if (commit.isPresent()) {
                ImmutableList<ObjectId> parents = ggit.getRepository().graphDatabase()
                        .getParents(ObjectId.valueOf(commit.get()));
                for (ObjectId object : parents) {
                    w.write(object.toString() + "\n");
                }
            }
View Full Code Here

        public void write(OutputStream out) throws IOException {
            PrintWriter w = new PrintWriter(out);

            Optional<GeoGIG> geogig = getGeogig(request);
            Preconditions.checkState(geogig.isPresent());
            GeoGIG ggit = geogig.get();

            Form options = request.getResourceRef().getQueryAsForm();

            boolean remotes = Boolean.valueOf(options.getFirstValue("remotes", "false"));

            ImmutableList<Ref> refs = ggit.command(BranchListOp.class).setRemotes(remotes).call();
            ImmutableList<RevTag> tags = ggit.command(TagListOp.class).call();

            // Print out HEAD first
            final Ref currentHead = ggit.command(RefParse.class).setName(Ref.HEAD).call().get();
            if (!currentHead.getObjectId().equals(ObjectId.NULL)) {
                w.write(currentHead.getName() + " ");
                if (currentHead instanceof SymRef) {
                    w.write(((SymRef) currentHead).getTarget());
                }
View Full Code Here

        public void post(Representation entity) {
            InputStream input = null;
            ObjectId newCommitId = ObjectId.NULL;
            try {
                input = getRequest().getEntity().getStream();
                final GeoGIG ggit = getGeogig(getRequest()).get();

                final Repository repository = ggit.getRepository();

                // read in commit object
                final ObjectSerializingFactory factory = DataStreamSerializationFactoryV1.INSTANCE;
                ObjectReader<RevCommit> reader = factory.createCommitReader();
                RevCommit commit = reader.read(ObjectId.NULL, input); // I don't need to know the
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.GeoGIG

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.