import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
}
private void doConversion( String properties )
- throws FileNotFoundException, IOException, RepositoryConversionException, PlexusSisuBridgeException
+ throws IOException, RepositoryConversionException, PlexusSisuBridgeException
{
LegacyRepositoryConverter legacyRepositoryConverter = lookup( LegacyRepositoryConverter.class );
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
private Metadata readMetadata( File file )
throws ArtifactConversionException
{
- Metadata metadata;
MetadataXpp3Reader reader = new MetadataXpp3Reader();
- try (FileReader fileReader = new FileReader( file ))
+ try (Reader fileReader = Files.newBufferedReader( file.toPath(), Charset.defaultCharset() ))
{
return reader.read( fileReader );
}
- catch ( FileNotFoundException e )
- {
- throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
- e ); //$NON-NLS-1$
- }
- catch ( IOException e )
- {
- throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
- e ); //$NON-NLS-1$
- }
- catch ( XmlPullParserException e )
+ catch ( IOException | XmlPullParserException e )
{
throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
e ); //$NON-NLS-1$
private static final String CHECKSUM_IO_ERROR = "checksum-io-error";
- /**
- * default-value="validate-checksums"
- */
private String id = "validate-checksums";
- /**
- * default-value="Validate checksums against file."
- */
private String description = "Validate checksums against file.";
- /**
- *
- */
private ChecksumFile checksum;
- /**
- *
- */
private List<Digester> allDigesters;
@Inject
import org.slf4j.LoggerFactory;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
wagon.get( addParameters( name, this.remoteRepository ), file );
return Files.newInputStream( file.toPath() );
}
- catch ( AuthorizationException e )
- {
- throw new IOException( e.getMessage(), e );
- }
- catch ( TransferFailedException e )
+ catch ( AuthorizationException | TransferFailedException e )
{
throw new IOException( e.getMessage(), e );
}
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
try
{
// MavenXpp3Reader leaves the file open, so we need to close it ourselves.
- FileReader reader = new FileReader( pom );
+
Model model = null;
- try
+ try (Reader reader = Files.newBufferedReader( pom.toPath(), Charset.defaultCharset() ))
{
model = MAVEN_XPP_3_READER.read( reader );
}
- finally
- {
- if ( reader != null )
- {
- reader.close();
- }
- }
DistributionManagement dist = model.getDistributionManagement();
if ( dist != null )
}
}
}
- catch ( FileNotFoundException e )
- {
- // Artifact has no POM in repo : ignore
- }
catch ( IOException e )
{
// Unable to read POM : ignore.
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
{
return readProperties( directory, propertiesKey );
}
- catch ( FileNotFoundException e )
+ catch ( FileNotFoundException | NoSuchFileException e )
{
// ignore and return new properties
}
import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.archiva.consumers.ConsumerException;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Matchers;
import org.springframework.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
-import java.io.FileNotFoundException;
import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.Date;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import static org.mockito.Mockito.*;
-import org.springframework.test.annotation.DirtiesContext;
@SuppressWarnings( { "ThrowableInstanceNeverThrown" } )
@RunWith( ArchivaSpringJUnit4ClassRunner.class )