* under the License.
*/
-import com.google.common.io.Files;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.admin.model.beans.ProxyConnectorRuleType;
import javax.inject.Named;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
/**
* DefaultRepositoryProxyConnectors
- *
+ * <p/>
* TODO exception handling needs work - "not modified" is not really an exceptional case, and it has more layers than
* your average brown onion
*/
private NetworkProxyAdmin networkProxyAdmin;
@Inject
- @Named( value = "fileLockManager#default" )
+ @Named(value = "fileLockManager#default")
private FileLockManager fileLockManager;
@PostConstruct
String targetRepository,
List<ProxyConnectorRuleConfiguration> all )
{
- List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
- new ArrayList<>();
+ List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations = new ArrayList<>();
for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : all )
{
log.debug( MarkerFactory.getDetachedMarker( "transfer.error" ),
"Transfer error from repository \"" + targetRepository.getRepository().getId()
+ "\" for resource " + path + ", continuing to next repository. Error message: {}",
- e.getMessage(), e );
+ e.getMessage(), e
+ );
}
catch ( RepositoryAdminException e )
{
*/
private File createWorkingDirectory( ManagedRepositoryContent repository )
{
- return Files.createTempDir();
+ try
+ {
+ return Files.createTempDirectory( "temp" ).toFile();
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+
}
/**
FileUtils.deleteQuietly( temp );
}
}
- } catch( FileLockException e)
+ }
+ catch ( FileLockException e )
{
throw new ProxyException( e.getMessage(), e );
- } catch (FileLockTimeoutException e)
+ }
+ catch ( FileLockTimeoutException e )
{
throw new ProxyException( e.getMessage(), e );
}
* under the License.
*/
-import com.google.common.io.Files;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.rest.api.services.RemoteRepositoriesService;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.File;
+import java.nio.file.Files;
import static org.assertj.core.api.Assertions.assertThat;
throws Exception
{
- File tmpDir = Files.createTempDir();
+ File tmpDir = Files.createTempDirectory( "test" ).toFile();
Server repoServer = buildStaticServer( tmpDir );
repoServer.start();
* under the License.
*/
-import com.google.common.io.Files;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
repositoryGroupConfiguration.getId(), authzRepos );
- File tempRepoFile = Files.createTempDir();
+ File tempRepoFile = Files.createTempDirectory("temp").toFile();
tempRepoFile.deleteOnExit();
IndexMergerRequest indexMergerRequest =
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
catch ( IndexMergerException e )
+ {
+ throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ } catch ( IOException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.WebRequest;
-import com.gargoylesoftware.htmlunit.WebResponse;
-import com.google.common.io.Files;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.policies.CachedFailuresPolicy;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Before;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.nio.charset.Charset;
+import java.nio.file.Files;
+
+import static org.assertj.core.api.Assertions.assertThat;
/**
* AbstractRepositoryServletProxiedTestCase
- *
*/
public abstract class AbstractRepositoryServletProxiedTestCase
extends AbstractRepositoryServletTestCase
RemoteRepoInfo repo = new RemoteRepoInfo();
repo.id = id;
repo.context = "/" + id;
- repo.root = Files.createTempDir();// new File( System.getProperty( "basedir" ) + "target/remote-repos/" + id + "/" );
+ repo.root = Files.createTempDirectory(
+ "temp" ).toFile();// new File( System.getProperty( "basedir" ) + "target/remote-repos/" + id + "/" );
// Remove exising root contents.
if ( repo.root.exists() )
throws Exception
{
File destFile = new File( remoteRepo.root, path );
- if (destFile.exists())
+ if ( destFile.exists() )
{
destFile.delete();
}
destFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( destFile, contents, Charset.defaultCharset() );
+ FileUtils.writeStringToFile( destFile, contents, Charset.defaultCharset() );
return destFile;
}
{
remoteSnapshots = createServer( "snapshots" );
-
assertServerSetupCorrectly( remoteSnapshots );
RemoteRepositoryConfiguration remoteRepositoryConfiguration =
archivaConfiguration.getConfiguration().getRemoteRepositoriesAsMap().get( remoteSnapshots.id );
* under the License.
*/
-import com.google.common.io.Files;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.List;
import java.util.Map;
int buildNumber = snapshotVersion.getBuildNumber();
String snapshotPath =
StringUtils.replaceChars( groupId, '.', '/' ) + '/' + artifactId + '/' + version + '/'
- + artifactId + '-' + StringUtils.remove( version, "-" + VersionUtil.SNAPSHOT )
- + '-' + lastVersion + '-' + buildNumber + ".pom";
+ + artifactId + '-' + StringUtils.remove( version, "-" + VersionUtil.SNAPSHOT ) + '-'
+ + lastVersion + '-' + buildNumber + ".pom";
log.debug( "use snapshot path {} for maven coordinate {}:{}:{}", snapshotPath, groupId, artifactId,
version );
private boolean getModelFromProxy( RemoteRepository remoteRepository, String groupId, String artifactId,
String version, String filename )
throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException, WagonFactoryException,
- XMLException
+ XMLException, IOException
{
boolean success = false;
File tmpMd5 = null;
wagon = wagonFactory.getWagon(
new WagonFactoryRequest( "wagon#" + protocol, remoteRepository.getExtraHeaders() ).networkProxy(
- networkProxy ) );
+ networkProxy )
+ );
if ( wagon == null )
{
}
private File createWorkingDirectory( String targetRepository )
+ throws IOException
{
- return Files.createTempDir();
+ return Files.createTempDirectory( "temp" ).toFile();
}
private void moveFileIfExists( File fileToMove, File directory )