Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.Remote


        final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class);

        String remoteName = "myremote";
        String remoteURL = "http://test.com";

        Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call();

        assertEquals(remoteName, remote.getName());
        assertEquals(remoteURL, remote.getFetchURL());
        assertEquals(remoteURL, remote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch());

        final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class);

        Remote deletedRemote = remoteRemove.setName(remoteName).call();

        assertEquals(remoteName, deletedRemote.getName());
        assertEquals(remoteURL, deletedRemote.getFetchURL());
        assertEquals(remoteURL, deletedRemote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", deletedRemote.getFetch());
    }
View Full Code Here


        final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class);

        String remoteName = "myremote";
        String remoteURL = "http://test.com";

        Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call();

        assertEquals(remoteName, remote.getName());
        assertEquals(remoteURL, remote.getFetchURL());
        assertEquals(remoteURL, remote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch());

        String refName = Ref.REMOTES_PREFIX + remoteName + "/branch1";
        geogig.command(UpdateRef.class).setName(refName).setNewValue(ObjectId.NULL).call();

        final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class);

        Remote deletedRemote = remoteRemove.setName(remoteName).call();

        Optional<Ref> remoteRef = geogig.command(RefParse.class).setName(refName).call();

        assertFalse(remoteRef.isPresent());

        assertEquals(remoteName, deletedRemote.getName());
        assertEquals(remoteURL, deletedRemote.getFetchURL());
        assertEquals(remoteURL, deletedRemote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", deletedRemote.getFetch());
    }
View Full Code Here

        final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class);

        String remoteName = "myremote";
        String remoteURL = "http://test.com";

        Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call();

        assertEquals(remoteName, remote.getName());
        assertEquals(remoteURL, remote.getFetchURL());
        assertEquals(remoteURL, remote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch());

        final ConfigOp config = geogig.command(ConfigOp.class);
        config.setAction(ConfigAction.CONFIG_UNSET).setName("remote." + remoteName + ".url").call();

        final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class);

        Remote deletedRemote = remoteRemove.setName(remoteName).call();

        assertEquals(remoteName, deletedRemote.getName());
        assertEquals("", deletedRemote.getFetchURL());
        assertEquals("", deletedRemote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", deletedRemote.getFetch());
    }
View Full Code Here

        final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class);

        String remoteName = "myremote";
        String remoteURL = "http://test.com";

        Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call();

        assertEquals(remoteName, remote.getName());
        assertEquals(remoteURL, remote.getFetchURL());
        assertEquals(remoteURL, remote.getPushURL());
        assertEquals("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch());

        final ConfigOp config = geogig.command(ConfigOp.class);
        config.setAction(ConfigAction.CONFIG_UNSET).setName("remote." + remoteName + ".fetch")
                .call();

        final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class);

        Remote deletedRemote = remoteRemove.setName(remoteName).call();

        assertEquals(remoteName, deletedRemote.getName());
        assertEquals(remoteURL, deletedRemote.getFetchURL());
        assertEquals(remoteURL, deletedRemote.getPushURL());
        assertEquals("", deletedRemote.getFetch());
    }
View Full Code Here

        return transferResult;
    }

    private TransferSummary callInternal(IRemoteRepo remoteRepo) {

        final Remote remote = this.remote;
        @Nullable
        String localRefSpec;
        @Nullable
        String remoteRefSpec;
        boolean force;

        TransferSummary result = new TransferSummary();

        for (TransferableRef ref : this.refsToPush) {
            localRefSpec = ref.getLocalRef();
            remoteRefSpec = ref.getRemoteRef();
            force = ref.isForceUpdate();

            if (ref.isDelete()) {
                Optional<Ref> deleted = remoteRepo.deleteRef(remoteRefSpec);
                if (deleted.isPresent()) {
                    ChangedRef deleteResult = new ChangedRef(deleted.get(), null, REMOVED_REF);
                    result.add(remote.getPushURL(), deleteResult);
                }
            } else {
                Optional<Ref> localRef = refParse(localRefSpec);
                checkState(localRef.isPresent(), "RefSpec %s does not exist", localRefSpec);

                Optional<Ref> newRef = push(remoteRepo, remote, localRef.get(), remoteRefSpec);

                if (newRef.isPresent()) {
                    ChangeTypes changeType = remoteRefSpec == null ? ADDED_REF : CHANGED_REF;
                    ChangedRef deleteResult = new ChangedRef(localRef.get(), newRef.get(),
                            changeType);
                    result.add(remote.getPushURL(), deleteResult);
                }
            }
        }
        return result;
    }
View Full Code Here

     * @return an immutable set of the refs for the given remote
     */
    @Override
    protected  ImmutableSet<Ref> _call() {
        Preconditions.checkState(remote.get().isPresent(), "Remote was not provided");
        final Remote remoteConfig = remote.get().get();

        if (local) {
            return locallyKnownRefs(remoteConfig);
        }
        getProgressListener().setDescription("Obtaining remote " + remoteConfig.getName());
        Optional<IRemoteRepo> remoteRepo = getRemoteRepo(remoteConfig);
        Preconditions.checkState(remoteRepo.isPresent(), "Remote could not be opened.");
        getProgressListener().setDescription("Connecting to remote " + remoteConfig.getName());
        try {
            remoteRepo.get().open();
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
        getProgressListener().setDescription(
                "Connected to remote " + remoteConfig.getName() + ". Retrieving references");
        ImmutableSet<Ref> remoteRefs;
        try {
            remoteRefs = remoteRepo.get().listRefs(getHeads, getTags);
        } finally {
            try {
View Full Code Here

            Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch");
            Optional<String> remoteUserName = config.get(remoteSection + ".username");
            Optional<String> remotePassword = config.get(remoteSection + ".password");
            if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) {
                Optional<String> remotePushURL = config.get(remoteSection + ".pushurl");
                allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL
                        .or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false")
                        .equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(),
                        remotePassword.orNull()));
            }
        }
View Full Code Here

            Optional<String> remoteUserName = config.get(remoteSection + ".username");
            Optional<String> remotePassword = config.get(remoteSection + ".password");
            if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) {
                Optional<String> remotePushURL = config.get(remoteSection + ".pushurl");

                Remote remote = new Remote(name, remoteFetchURL.get(),
                        remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or(
                                "false").equals("true"), remoteMappedBranch.orNull(),
                        remoteUserName.orNull(), remotePassword.orNull());
                result = Optional.of(remote);
            }
View Full Code Here

        if (password != null) {
            password = Remote.encryptPassword(password);
            config.put(configSection + ".password", password);
        }

        return new Remote(name, url, url, fetch, mapped, branch, username, password);
    }
View Full Code Here

        List<String> allRemotes = config.getAllSubsections("remote");
        if (!allRemotes.contains(name)) {
            throw new RemoteException(StatusCode.REMOTE_NOT_FOUND);
        }

        Remote remote = null;
        String remoteSection = "remote." + name;
        Optional<String> remoteFetchURL = config.get(remoteSection + ".url");
        Optional<String> remoteFetch = config.get(remoteSection + ".fetch");
        Optional<String> remotePushURL = Optional.absent();
        Optional<String> remoteMapped = config.get(remoteSection + ".mapped");
        Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch");
        Optional<String> remoteUserName = config.get(remoteSection + ".username");
        Optional<String> remotePassword = config.get(remoteSection + ".password");
        if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) {
            remotePushURL = config.get(remoteSection + ".pushurl");
        }

        remote = new Remote(name, remoteFetchURL.or(""), remotePushURL.or(remoteFetchURL.or("")),
                remoteFetch.or(""), remoteMapped.or("false").equals("true"),
                remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull());

        config.removeSection(remoteSection);
View Full Code Here

TOP

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

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.