public static URI resolveRepoUriFromString(Platform platform, String repoURI) throws URISyntaxException { URI uri; uri = new URI(repoURI.replace('\\', '/').replaceAll(" ", "%20")); String scheme = uri.getScheme(); if (null == scheme) { Path p = Paths.get(repoURI); if (p.isAbsolute()) { uri = p.toUri(); } else { uri = new File(platform.pwd(), repoURI).toURI(); } } else if ("file".equals(scheme)) { File f = new File(uri); if (!f.isAbsolute()) { uri = new File(platform.pwd(), repoURI).toURI(); } } return uri; }
/** * @return the committer's time stamp */ public long getCommitterTimestamp() { return committerTimestamp == 0L ? platform.currentTimeMillis() : committerTimestamp; }
@Override public File iniFile() { File home = platform.getUserHome(); if (home == null) { throw new ConfigException(StatusCode.USERHOME_NOT_SET); } Preconditions.checkState(home.exists(), "user home does not exist: %s", home); Preconditions.checkState(home.isDirectory(), "user home is not a directory: %s", home); File globalConfig = new File(home, ".geogigconfig"); try { globalConfig.createNewFile(); } catch (IOException e) { throw new ConfigException(e, StatusCode.CANNOT_WRITE); } return globalConfig; } };
private RevPerson resolveTagger() { final String nameKey = "user.name"; final String emailKey = "user.email"; Optional<String> name = command(ConfigGet.class).setName(nameKey).call(); Optional<String> email = command(ConfigGet.class).setName(emailKey).call(); checkState(name.isPresent(), "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", nameKey, nameKey); checkState(email.isPresent(), "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", emailKey, emailKey); String taggerName = name.get(); String taggerEmail = email.get(); Platform platform = platform(); long taggerTimeStamp = platform.currentTimeMillis(); int taggerTimeZoneOffset = platform.timeZoneOffset(taggerTimeStamp); return RevPersonBuilder.build(taggerName, taggerEmail, taggerTimeStamp, taggerTimeZoneOffset); }
boolean globalOnly; if (repoURI == null) { uri = platform.pwd().toURI(); globalOnly = true; } else { globalOnly = false; } catch (URISyntaxException e) { uri = platform.getUserHome().toURI(); globalOnly = true; .resolveConfigDatabase(platform.pwd().toURI(), context, true)) { unaliased = global.getGlobal(configParam); } catch (IOException e) {
this.repositoryURI = repoURI; URI uri = URI.create(repoURI); File pwd = this.platform.pwd(); if (Strings.isNullOrEmpty(uri.getScheme())) { pwd = new File(uri.toString()); pwd = new File(uri); this.platform.setWorkingDir(pwd); String workingDir; Platform platform = getPlatform(); if (platform == null || platform.pwd() == null) { workingDir = "Couln't determine working directory."; } else { workingDir = platform.pwd().getAbsolutePath();
@Override protected ObjectStore createObjectStore() throws IOException { Platform platform = new DefaultPlatform(); platform.setWorkingDir(tmp.getRoot()); tmp.newFolder(".geogig"); Hints hints = Hints.readWrite().platform(platform); try { hints.set(Hints.REPOSITORY_URL, tmp.getRoot().toURI().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } return new RocksdbObjectStore(platform, hints); }
/** * @return the time zone offset to be used for the committer */ public int getCommitterTimeZoneOffset() { if (committerTimeZoneOffset == null) { return platform().timeZoneOffset(getCommitterTimeStamp()); } return committerTimeZoneOffset.intValue(); }
private void setUpGeogig(GeogigCLI cli) throws Exception { final File userhome = tempFolder.newFolder("mockUserHomeDir"); final File workingDir = tempFolder.newFolder("mockWorkingDir"); tempFolder.newFolder("mockWorkingDir", ".geogig"); final Platform platform = mock(Platform.class); when(platform.pwd()).thenReturn(workingDir); when(platform.getUserHome()).thenReturn(userhome); cli.setPlatform(platform); } }
this.repositoryURI = repoURI; URI uri = URI.create(repoURI); File pwd = this.platform.pwd(); if (Strings.isNullOrEmpty(uri.getScheme())) { pwd = new File(uri.toString()); pwd = new File(uri); this.platform.setWorkingDir(pwd); String workingDir; Platform platform = getPlatform(); if (platform == null || platform.pwd() == null) { workingDir = "Couln't determine working directory."; } else { workingDir = platform.pwd().getAbsolutePath();
public RevCommit build() { if (treeId == null) { throw new IllegalStateException("No tree id set"); } if (platform == null) { platform = new DefaultPlatform(); } final long now = platform.currentTimeMillis(); final int tzOffset = platform.timeZoneOffset(now); long committerTs = committerTimestamp == null ? now : committerTimestamp; int committerOffset = committerTimeZoneOffset == null ? tzOffset : committerTimeZoneOffset; long authorTs = authorTimestamp == null ? committerTs : authorTimestamp; int authorOffset = authorTimeZoneOffset == null ? committerOffset : authorTimeZoneOffset; final ObjectId treeId = this.treeId; final ImmutableList<ObjectId> parentIds = this.parentIds == null ? ImmutableList.of() : ImmutableList.copyOf(this.parentIds); final RevPerson author = RevPerson.builder().build(this.author, authorEmail, authorTs, authorOffset); final RevPerson committer = RevPerson.builder().build(this.committer, committerEmail, committerTs, committerOffset); final String commitMessage = this.message == null ? "" : this.message; return build(treeId, parentIds, author, committer, commitMessage); }
@Override protected ObjectStore createObjectStore() throws IOException { Platform platform = new DefaultPlatform(); platform.setWorkingDir(tmp.getRoot()); tmp.newFolder(".geogig"); Hints hints = Hints.readWrite().platform(platform); try { hints.set(Hints.REPOSITORY_URL, tmp.getRoot().toURI().toURL()); } catch (MalformedURLException e) { throw Throwables.propagate(e); } return new RocksdbObjectStore(platform, hints); }
public static URI resolveRepoUriFromString(Platform platform, String repoURI) throws URISyntaxException { URI uri; uri = new URI(repoURI.replace('\\', '/').replaceAll(" ", "%20")); String scheme = uri.getScheme(); if (null == scheme) { Path p = Paths.get(repoURI); if (p.isAbsolute()) { uri = p.toUri(); } else { uri = new File(platform.pwd(), repoURI).toURI(); } } else if ("file".equals(scheme)) { File f = new File(uri); if (!f.isAbsolute()) { uri = new File(platform.pwd(), repoURI).toURI(); } } return uri; }
boolean globalOnly; if (repoURI == null) { uri = platform.pwd().toURI(); globalOnly = true; } else { globalOnly = false; } catch (URISyntaxException e) { uri = platform.getUserHome().toURI(); globalOnly = true; .resolveConfigDatabase(platform.pwd().toURI(), context, true)) { unaliased = global.getGlobal(configParam); } catch (IOException e) {
this.repositoryURI = repoURI; URI uri = URI.create(repoURI); File pwd = this.platform.pwd(); if (Strings.isNullOrEmpty(uri.getScheme())) { pwd = new File(uri.toString()); pwd = new File(uri); this.platform.setWorkingDir(pwd); String workingDir; Platform platform = getPlatform(); if (platform == null || platform.pwd() == null) { workingDir = "Couln't determine working directory."; } else { workingDir = platform.pwd().getAbsolutePath();
public StandardConverter(final LOG_DETAIL detail, final Platform platform) { now = platform.currentTimeMillis(); DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); this.detail = detail; }
private RevPerson resolveTagger() { final String nameKey = "user.name"; final String emailKey = "user.email"; String taggerName = getClientData(nameKey, String.class) .or(command(ConfigGet.class).setName(nameKey).call()).orNull(); String taggerEmail = getClientData(emailKey, String.class) .or(command(ConfigGet.class).setName(emailKey).call()).orNull(); checkState(taggerName != null, "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", nameKey, nameKey); checkState(taggerEmail != null, "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", emailKey, emailKey); Platform platform = platform(); long taggerTimeStamp = platform.currentTimeMillis(); int taggerTimeZoneOffset = platform.timeZoneOffset(taggerTimeStamp); return RevPerson.builder().build(taggerName, taggerEmail, taggerTimeStamp, taggerTimeZoneOffset); }
@Override public File iniFile() { File home = platform.getUserHome(); if (home == null) { throw new ConfigException(StatusCode.USERHOME_NOT_SET); } Preconditions.checkState(home.exists(), "user home does not exist: %s", home); Preconditions.checkState(home.isDirectory(), "user home is not a directory: %s", home); File globalConfig = new File(home, ".geogigconfig"); try { globalConfig.createNewFile(); } catch (IOException e) { throw new ConfigException(e, StatusCode.CANNOT_WRITE); } return globalConfig; } };
@Override public URI buildRootURI(Platform platform) { return platform.pwd().toURI(); } }
boolean globalOnly; if (repoURI == null) { uri = platform.pwd().toURI(); globalOnly = true; } else { globalOnly = false; } catch (URISyntaxException e) { uri = platform.getUserHome().toURI(); globalOnly = true; .resolveConfigDatabase(platform.pwd().toURI(), context, true)) { unaliased = global.getGlobal(configParam); } catch (IOException e) {