public FormValidation doCheckUrl(@QueryParameter String value) { if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.url_required()); } else { return FormValidation.ok(); } }
public static String prepareLocalSvnRepo(String sourceDir, String checkoutDir) throws Exception { File sourceDirFile = new File(sourceDir); sourceDirFile.mkdirs(); File local = new File(checkoutDir); if (local.exists()) { FileUtils.delete(local, FileUtils.RECURSIVE); } local.mkdirs(); FileSystemUtils.copyRecursively(sourceDirFile, local); return StringUtils.cleanPath("file:///" + local.getAbsolutePath()); }
private void determineAtomicFileCreationSupport() { // @TODO: enhance SystemReader to support this without copying code AtomicFileCreation ret = getAtomicFileCreationSupportOption( SystemReader.getInstance().openUserConfig(null, this)); if (ret == AtomicFileCreation.UNDEFINED && StringUtils.isEmptyOrNull(SystemReader.getInstance() .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))) { ret = getAtomicFileCreationSupportOption( SystemReader.getInstance().openSystemConfig(null, this)); } supportsAtomicCreateNewFile = ret; }
private static byte[] readFully(InputStream is) throws IOException { try (TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE)) { b.copy(is); return b.toByteArray(); } }
/** * Auto-detects the GSSManager factory to use based on system. * * @return detected GSSManager factory */ public static GSSManagerFactory detect() { return (SunGSSManagerFactory.isSupported()) ? new SunGSSManagerFactory() : new DefaultGSSManagerFactory(); }
@Override protected Session createSession(Host hc, String user, String host, int port, FS fs) throws JSchException { if (sshKeysByHostname.containsKey(host)) { JGitEnvironmentProperties sshUriProperties = sshKeysByHostname.get(host); jSch.addIdentity(host, sshUriProperties.getPrivateKey().getBytes(), null, null); if (sshUriProperties.getKnownHostsFile() != null) { jSch.setKnownHosts(sshUriProperties.getKnownHostsFile()); } if (sshUriProperties.getHostKey() != null) { HostKey hostkey = new HostKey(host, Base64.decode(sshUriProperties.getHostKey())); jSch.getHostKeyRepository().add(hostkey, null); } return jSch.getSession(user, host, port); } throw new JSchException("no keys configured for hostname " + host); }
/** * Get the currently used path to the system-wide Git configuration file. * * @return the currently used path to the system-wide Git configuration file * or {@code null} if none has been set. * @since 4.0 */ public File getGitSystemConfig() { if (gitSystemConfig == null) { gitSystemConfig = new Holder<>(discoverGitSystemConfig()); } return gitSystemConfig.value; }
private void deleteBaseDirIfExists() { if (getBasedir().exists()) { for (File file : getBasedir().listFiles()) { try { FileUtils.delete(file, FileUtils.RECURSIVE); } catch (IOException e) { throw new IllegalStateException("Failed to initialize base directory", e); } } } }
public FormValidation doCheckApiTokenId(@QueryParameter String value) { if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.apiToken_required()); } else { return FormValidation.ok(); } }
File dest = new File(buildDir + repoPath); if (dest.exists()) { FileUtils.delete(dest, FileUtils.RECURSIVE | FileUtils.RETRY); if (git.exists()) { if (dotGit.exists()) { FileUtils.delete(dotGit, FileUtils.RECURSIVE); File local = new File(checkoutDir); if (local.exists()) { FileUtils.delete(local, FileUtils.RECURSIVE);
public FormValidation doCheckName(@QueryParameter String id, @QueryParameter String value) { if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.name_required()); } else if (connectionMap.containsKey(value) && !connectionMap.get(value).toString().equals(id)) { return FormValidation.error(Messages.name_exists(value)); } else { return FormValidation.ok(); } }
private String retrievePushedBy(final PushHook hook) { final String userName = hook.getUserName(); if (!StringUtils.isEmptyOrNull(userName)) { return userName; } final List<Commit> commits = hook.getCommits(); if (commits != null && !commits.isEmpty()) { return commits.get(commits.size() - 1).getAuthor().getName(); } return null; }