Package org.locationtech.geogig.api.plumbing

Examples of org.locationtech.geogig.api.plumbing.ResolveGeogigDir


    private File parentDir;

    private MappedIndex index;

    public MappedPointCache(Platform platform) {
        final Optional<File> geogigDir = new ResolveGeogigDir(platform).getFile();
        checkState(geogigDir.isPresent());
        this.parentDir = new File(new File(geogigDir.get(), "tmp"), "pointcache_"
                + Math.abs(RANDOM.nextInt()));
        checkState(parentDir.exists() || parentDir.mkdirs());
        this.parentDir.deleteOnExit();
View Full Code Here


        return System.nanoTime();
    }

    @Override
    public File getTempDir() {
        Optional<URL> url = new ResolveGeogigDir(this).call();
        final File tmpDir;
        if (url.isPresent()) {
            try {
                URI uri = url.get().toURI();
                tmpDir = new File(new File(uri), "tmp");
View Full Code Here

    }

    private Repository callInternal() {
        final Platform platform = platform();
        final File workingDirectory = platform.pwd();
        final Optional<URL> repoUrl = new ResolveGeogigDir(platform).call();

        final boolean repoExisted = repoUrl.isPresent();
        final File envHome;
        if (repoExisted) {
            // we're at either the repo working dir or a subdirectory of it
            try {
                envHome = new File(repoUrl.get().toURI());
            } catch (URISyntaxException e) {
                throw Throwables.propagate(e);
            }
        } else {
            envHome = new File(workingDirectory, ".geogig");
            if (!envHome.mkdirs()) {
                throw new RuntimeException("Unable to create geogig environment at '"
                        + envHome.getAbsolutePath() + "'");
            }
        }

        Map<String, String> effectiveConfigBuilder = Maps.newTreeMap();
        addDefaults(defaults, effectiveConfigBuilder);
        if (config != null) {
            effectiveConfigBuilder.putAll(config);
        }

        if (filterFile != null) {
            try {
                final String FILTER_FILE = "filter.ini";

                File oldFilterFile = new File(filterFile);
                if (!oldFilterFile.exists()) {
                    throw new FileNotFoundException("No filter file found at " + filterFile + ".");
                }

                Optional<URL> envHomeURL = new ResolveGeogigDir(platform).call();
                Preconditions.checkState(envHomeURL.isPresent(), "Not inside a geogig directory");
                final URL url = envHomeURL.get();
                if (!"file".equals(url.getProtocol())) {
                    throw new UnsupportedOperationException(
                            "Sparse clone works only against file system repositories. "
                                    + "Repository location: " + url.toExternalForm());
                }

                File repoDir;
                try {
                    repoDir = new File(url.toURI());
                } catch (URISyntaxException e) {
                    throw new IllegalStateException("Unable to access directory "
                            + url.toExternalForm(), e);
                }

                File newFilterFile = new File(repoDir, FILTER_FILE);

                Files.copy(oldFilterFile, newFilterFile);
                effectiveConfigBuilder.put("sparse.filter", FILTER_FILE);
            } catch (Exception e) {
                throw new IllegalStateException("Unable to copy filter file at path " + filterFile
                        + " to the new repository.", e);
            }
        }

        try {
            Preconditions.checkState(envHome.toURI().toURL()
                    .equals(new ResolveGeogigDir(platform).call().get()));
        } catch (MalformedURLException e) {
            Throwables.propagate(e);
        }

        Repository repository;
View Full Code Here

     * @see com.google.inject.Provider#get()
     */
    @Override
    public synchronized Environment get() {

        final Optional<URL> repoUrl = new ResolveGeogigDir(platform).call();
        if (!repoUrl.isPresent() && absolutePath == null) {
            throw new IllegalStateException("Can't find geogig repository home");
        }
        final File storeDirectory;

View Full Code Here

    public void open() {
        if (isOpen()) {
            return;
        }

        Optional<URL> url = new ResolveGeogigDir(platform).call();
        if (url.isPresent()) {
            synchronized (graphs) {
                URL key = url.get();
                if (!graphs.containsKey(key)) {
                    graphs.put(key, new Ref(new Graph()));
View Full Code Here

    public void close() {
        if (!isOpen()) {
            return;
        }
        graph = null;
        Optional<URL> url = new ResolveGeogigDir(platform).call();
        if (url.isPresent()) {
            synchronized (graphs) {
                URL key = url.get();
                Ref ref = graphs.get(key);
                if (ref != null && ref.release() <= -1) {
View Full Code Here

        return this;
    }

    @Override
    protected Void _call() {
        URL envHome = new ResolveGeogigDir(platform()).call().get();
        try {
            File file = new File(envHome.toURI());
            file = new File(file, "MERGE_MSG");
            Files.write(message, file, Charsets.UTF_8);
        } catch (Exception e) {
View Full Code Here

public class ReadMergeCommitMessageOp extends AbstractGeoGigOp<String> {

    @Override
    protected String _call() {
        URL envHome = new ResolveGeogigDir(platform()).call().get();
        try {
            File file = new File(envHome.toURI());
            file = new File(file, "MERGE_MSG");
            if (!file.exists()) {
                return "";
View Full Code Here

    /**
     * Creates the reference database.
     */
    @Override
    public void create() {
        Optional<URL> envHome = new ResolveGeogigDir(platform).call();
        checkState(envHome.isPresent(), "Not inside a geogig directory");

        final URL envURL = envHome.get();
        if (!"file".equals(envURL.getProtocol())) {
            throw new UnsupportedOperationException(
View Full Code Here

    /**
     * @param refPath
     * @return
     */
    private File toFile(String refPath) {
        Optional<URL> envHome = new ResolveGeogigDir(platform).call();

        String[] path = refPath.split("/");

        try {
            File file = new File(envHome.get().toURI());
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.plumbing.ResolveGeogigDir

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.