Package org.locationtech.geogig.api.porcelain

Examples of org.locationtech.geogig.api.porcelain.ConfigException


    public void put(String key, Object value) {
        String[] parsed = parse(key);
        try {
            local.set(parsed[0], parsed[1], stringify(value));
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here


    public void putGlobal(String key, Object value) {
        String[] parsed = parse(key);
        try {
            global.set(parsed[0], parsed[1], stringify(value));
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here

    public void remove(String key) {
        String[] parsed = parse(key);
        try {
            local.remove(parsed[0], parsed[1]);
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here

    public void removeGlobal(String key) {
        String[] parsed = parse(key);
        try {
            global.remove(parsed[0], parsed[1]);
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here

    public void removeSection(String key) {
        try {
            local.removeSection(key);
        } catch (NoSuchElementException e) {
            throw new ConfigException(e, StatusCode.MISSING_SECTION);
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here

    public void removeSectionGlobal(String key) {
        try {
            global.removeSection(key);
        } catch (NoSuchElementException e) {
            throw new ConfigException(e, StatusCode.MISSING_SECTION);
        } catch (StringIndexOutOfBoundsException e) {
            throw new ConfigException(e, StatusCode.SECTION_OR_KEY_INVALID);
        } catch (IllegalArgumentException e) {
            throw new ConfigException(e, null);
        } catch (IOException e) {
            throw new ConfigException(e, null);
        }
    }
View Full Code Here

    Config local() {
        if (local == null || !lastWorkingDir.equals(platform.pwd())) {
            final Optional<URL> url = new ResolveGeogigDir(platform).call();

            if (!url.isPresent()) {
                throw new ConfigException(StatusCode.INVALID_LOCATION);
            }

            URL u = url.get();
            File localFile;
            try {
View Full Code Here

    Config global() {
        if (global == null || !lastUserDir.equals(platform.getUserHome())) {
            File home = platform.getUserHome();

            if (home == null) {
                throw new ConfigException(StatusCode.USERHOME_NOT_SET);
            }

            File globalDir = new File(home.getPath(), ".geogig");
            if (globalDir.exists() && !globalDir.isDirectory()) {
                throw new IllegalStateException(globalDir.getAbsolutePath()
                        + " exists but is not a directory");
            }

            if (!globalDir.exists() && !globalDir.mkdir()) {
                throw new ConfigException(StatusCode.CANNOT_WRITE);
            }

            lastUserDir = home;
            global = new Config(new File(globalDir, "config.db"));
        }
View Full Code Here

    }

    @Test
    public void testListDefaultWithNoLocalRepository() {
        ConfigDatabase database = mock(ConfigDatabase.class);
        when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
        ConfigOp config = new ConfigOp(database);

        config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_LIST).setName(null)
                .setValue(null).call();
    }
View Full Code Here

    }

    @Test
    public void testGetDefaultWithNoLocalRepository() {
        ConfigDatabase database = mock(ConfigDatabase.class);
        when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
        when(database.getGlobal(anyString())).thenReturn(Optional.of("value"));
        ConfigOp config = new ConfigOp(database);

        config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_GET)
                .setName("section.key").setValue(null).call();
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.porcelain.ConfigException

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.