/** * Create a folder on the server (as a subfolder of this folder) * * @param folderName name of the folder to be created. * @throws IOException in case of an error. */ public void createFolder(String folderName) throws IOException { createFolder(folderName, false); }
/** * Helper to create a base url in case a folder is given * @param folder the folder or {@code null} * @return The created base url. */ public static String toBaseUrl(final FolderJob folder) { return folder == null ? "/" : folder.getUrl(); }
public Optional<FolderJob> getFolderJob(Job job) throws IOException { try { FolderJob folder = client.get(job.getUrl(), FolderJob.class); if (!folder.isFolder()) { return Optional.absent(); } folder.setClient(client); return Optional.of(folder); } catch (HttpResponseException e) { LOGGER.debug("getForlderJob(job={}) status={}", job, e.getStatusCode()); if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { // TODO: Check if this is a good idea ? What about // Optional.absent() ? return null; } throw e; } }
/** * Helper to create a base url in case a folder is given * @param folder the folder or {@code null} * @return The created base url. */ public static String toBaseUrl(final FolderJob folder) { return folder == null ? "/" : folder.getUrl(); }
/** * Create a folder on the server (as a subfolder of this folder) * * @param folderName name of the folder to be created. * @throws IOException in case of an error. */ public void createFolder(String folderName) throws IOException { createFolder(folderName, false); }
/** * Create a folder on the server (as a subfolder of this folder) * * @param folderName name of the folder to be created. * @param crumbFlag true/false. * @throws IOException in case of an error. */ public void createFolder(String folderName, Boolean crumbFlag) throws IOException { // https://gist.github.com/stuart-warren/7786892 was slightly helpful // here ImmutableMap<String, String> params = ImmutableMap.of("mode", "com.cloudbees.hudson.plugins.folder.Folder", "name", EncodingUtils.encodeParam(folderName), "from", "", "Submit", "OK"); client.post_form(this.getUrl() + "/createItem?", params, crumbFlag); }
/** * Create a folder on the server (as a subfolder of this folder) * * @param folderName name of the folder to be created. * @param crumbFlag true/false. * @throws IOException in case of an error. */ public void createFolder(String folderName, Boolean crumbFlag) throws IOException { // https://gist.github.com/stuart-warren/7786892 was slightly helpful // here ImmutableMap<String, String> params = ImmutableMap.of("mode", "com.cloudbees.hudson.plugins.folder.Folder", "name", EncodingUtils.encodeParam(folderName), "from", "", "Submit", "OK"); client.post_form(this.getUrl() + "/createItem?", params, crumbFlag); }