static String getBaseDirectory(Repository repository) { StringBuilder sb = new StringBuilder(repository.getBasedir()).deleteCharAt(0); if ((sb.length() != 0) && (sb.charAt(sb.length() - 1) != '/')) { sb.append('/'); } return sb.toString(); }
public String resolve(Repository repository) { StringBuilder stringBuilder = new StringBuilder(repository.getBasedir()).deleteCharAt(0); if ((stringBuilder.length() != 0) && (stringBuilder.charAt(stringBuilder.length() - 1) != '/')) { stringBuilder.append('/'); } return stringBuilder.toString(); } }
static String getBaseDirectory(Repository repository) { StringBuilder sb = new StringBuilder(repository.getBasedir()).deleteCharAt(0); if ((sb.length() != 0) && (sb.charAt(sb.length() - 1) != '/')) { sb.append('/'); } return sb.toString(); }
PackagecloudRepository(Repository wagonRepository) { String baseDir = wagonRepository.getBasedir(); String[] strings = baseDir.split("/"); if(strings[1] != null){ this.userName = strings[1]; } else { throw new IllegalArgumentException(String.format("Cant parse userName from %s", baseDir)); } if(strings[2] != null){ this.repoName = strings[2]; } else { throw new IllegalArgumentException(String.format("Cant parse repoName from %s", baseDir)); } }
/** * Convert "/" -> ""<br> * Convert "/snapshot/" -> "snapshot/"<br> * Convert "/snapshot" -> "snapshot/"<br> */ protected String getBaseDir(final Repository source) { StringBuilder sb = new StringBuilder(source.getBasedir()); sb.deleteCharAt(0); if (sb.length() == 0) { return ""; } if (sb.charAt(sb.length() - 1) != '/') { sb.append('/'); } return sb.toString(); }
protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) { return new File( repository.getBasedir(), resource.getName() ).lastModified(); }
private static void chmod(final Wagon wagon, final Repository repository, final String chmodOptions, final String chmodMode) throws MojoExecutionException { try { if (wagon instanceof CommandExecutor) { CommandExecutor exec = (CommandExecutor) wagon; exec.executeCommand("chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir()); } // else ? silently ignore, FileWagon is not a CommandExecutor! } catch (CommandExecutionException e) { throw new MojoExecutionException("Error uploading site", e); } }
protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) { return new File( repository.getBasedir(), resource.getName() ).lastModified(); }
protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) { return new File( repository.getBasedir(), resource.getName() ).lastModified(); }
protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) { return new File( repository.getBasedir(), resource.getName() ).lastModified(); }
private File resolveDestinationPath( String destinationPath ) { String basedir = getRepository().getBasedir(); destinationPath = destinationPath.replace( "\\", "/" ); File path; if ( destinationPath.equals( "." ) ) { path = new File( basedir ); } else { path = new File( basedir, destinationPath ); } return path; }
private File resolveDestinationPath( String destinationPath ) { String basedir = getRepository().getBasedir(); destinationPath = destinationPath.replace( "\\", "/" ); File path; if ( destinationPath.equals( "." ) ) { path = new File( basedir ); } else { path = new File( basedir, destinationPath ); } return path; }
private static void chmod( final Wagon wagon, final Repository repository, final String chmodOptions, final String chmodMode ) throws MojoExecutionException { try { if ( wagon instanceof CommandExecutor ) { CommandExecutor exec = (CommandExecutor) wagon; exec.executeCommand( "chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir() ); } // else ? silently ignore, FileWagon is not a CommandExecutor! } catch ( CommandExecutionException e ) { throw new MojoExecutionException( "Error uploading site", e ); } }
public boolean resourceExists( String resourceName ) throws TransferFailedException, AuthorizationException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to getFileList() with a null basedir." ); } File file = resolveDestinationPath( resourceName ); if ( resourceName.endsWith( "/" ) ) { return file.isDirectory(); } return file.exists(); } }
public boolean resourceExists( String resourceName ) throws TransferFailedException, AuthorizationException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to getFileList() with a null basedir." ); } File file = resolveDestinationPath( resourceName ); if ( resourceName.endsWith( "/" ) ) { return file.isDirectory(); } return file.exists(); } }
public boolean resourceExists( String resourceName, Repository repository ) throws TransferFailedException, AuthorizationException { try { String path = getPath( repository.getBasedir(), resourceName ); //executor.executeCommand( "ls " + path, false ); executor.executeCommand( "ls \"" + path + "\"" ); // Parsing of output not really needed. As a failed ls results in a // CommandExectionException on the 'ls' command. return true; } catch ( CommandExecutionException e ) { // Error? Then the 'ls' command failed. No such file found. return false; } }
public boolean resourceExists( String resourceName, Repository repository ) throws TransferFailedException, AuthorizationException { try { String path = getPath( repository.getBasedir(), resourceName ); //executor.executeCommand( "ls " + path, false ); executor.executeCommand( "ls \"" + path + "\"" ); // Parsing of output not really needed. As a failed ls results in a // CommandExectionException on the 'ls' command. return true; } catch ( CommandExecutionException e ) { // Error? Then the 'ls' command failed. No such file found. return false; } }
public void fillOutputData( OutputData outputData ) throws TransferFailedException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to operate with a null basedir." ); } Resource resource = outputData.getResource(); File file = new File( getRepository().getBasedir(), resource.getName() ); createParentDirectories( file ); OutputStream outputStream = new BufferedOutputStream( new LazyFileOutputStream( file ) ); outputData.setOutputStream( outputStream ); }
public void fillOutputData( OutputData outputData ) throws TransferFailedException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to operate with a null basedir." ); } Resource resource = outputData.getResource(); File file = new File( getRepository().getBasedir(), resource.getName() ); createParentDirectories( file ); OutputStream outputStream = new BufferedOutputStream( new LazyFileOutputStream( file ) ); outputData.setOutputStream( outputStream ); }
private void ftpChangeDirectory( Resource resource ) throws IOException, TransferFailedException, ResourceDoesNotExistException { if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) ) { throw new ResourceDoesNotExistException( "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" ); } String[] dirs = PathUtils.dirnames( resource.getName() ); for ( String dir : dirs ) { boolean dirChanged = ftp.changeWorkingDirectory( dir ); if ( !dirChanged ) { String msg = "Resource " + resource + " not found. Directory " + dir + " does not exist"; throw new ResourceDoesNotExistException( msg ); } } }