1
package org.apache.maven.wagon;
4
* Licensed to the Apache Software Foundation (ASF) under one
5
* or more contributor license agreements. See the NOTICE file
6
* distributed with this work for additional information
7
* regarding copyright ownership. The ASF licenses this file
8
* to you under the Apache License, Version 2.0 (the
9
* "License"); you may not use this file except in compliance
10
* with the License. You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing,
15
* software distributed under the License is distributed on an
16
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
* KIND, either express or implied. See the License for the
18
* specific language governing permissions and limitations
22
import org.apache.maven.wagon.authorization.AuthorizationException;
23
import org.codehaus.plexus.util.FileUtils;
26
import java.io.IOException;
27
import java.util.LinkedList;
30
* @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a>
31
* @version $Id: WagonUtils.java 1133935 2011-06-09 15:30:14Z struberg $
34
public final class WagonUtils
40
public static String toString( String resource, Wagon wagon )
41
throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
48
file = File.createTempFile( "wagon", "tmp" );
50
wagon.get( resource, file );
52
return FileUtils.fileRead( file );
58
boolean deleted = file.delete();
70
public static void putDirectory( File dir, Wagon wagon, boolean includeBasdir )
71
throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
74
LinkedList queue = new LinkedList();
78
queue.add( dir.getName() );
85
while ( !queue.isEmpty() )
87
String path = (String) queue.removeFirst();
89
File currentDir = new File( dir, path );
91
File[] files = currentDir.listFiles();
93
for ( int i = 0; i < files.length; i++ )
99
if ( path.length() > 0 )
101
resource = path + "/" + file.getName();
105
resource = file.getName();
108
if ( file.isDirectory() )
110
queue.add( resource );
114
wagon.put( file, resource );