public RepositoryScanning getRepositoryScanning()
throws RepositoryAdminException
{
- return new BeanReplicator().replicateBean( getArchivaConfiguration().getConfiguration().getRepositoryScanning(),
- RepositoryScanning.class );
+
+ RepositoryScanning repositoryScanning =
+ new BeanReplicator().replicateBean( getArchivaConfiguration().getConfiguration().getRepositoryScanning(),
+ RepositoryScanning.class )
+
+ return repositoryScanning;
}
public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
* under the License.
*/
+import net.sf.beanlib.provider.BeanTransformer;
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
{
try
{
- return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(),
- RepositoryScanning.class );
+ BeanTransformer beanTransformer = new BeanTransformer()
+ {
+ @Override
+ protected <T> T createToInstance( Object from, Class<T> toClass )
+ throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
+ {
+ if ( from.getClass().equals( org.apache.maven.archiva.configuration.FileType.class ) )
+ {
+ return (T) new FileType();
+ }
+ return super.createToInstance( from, toClass );
+ }
+ };
+ BeanReplicator beanReplicator = new BeanReplicator( beanTransformer );
+
+ RepositoryScanning repositoryScanning =
+ beanReplicator.replicateBean( archivaAdministration.getRepositoryScanning(), RepositoryScanning.class );
+
+ return repositoryScanning;
}
catch ( RepositoryAdminException e )
{
* under the License.
*/
+import org.apache.archiva.rest.api.model.FileType;
+import org.apache.archiva.rest.api.model.LegacyArtifactPath;
import org.junit.Test;
+import java.util.Arrays;
+
/**
* @author Olivier Lamy
*/
assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
}
+
+ @Test
+ public void addAndDeleteLegacyPath()
+ throws Exception
+ {
+ int initialSize = getArchivaAdministrationService().getLegacyArtifactPaths().size();
+ LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
+ legacyArtifactPath.setArtifact( "foo" );
+ legacyArtifactPath.setPath( "bar" );
+ getArchivaAdministrationService().addLegacyArtifactPath( legacyArtifactPath );
+ assertEquals( initialSize + 1, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
+
+ getArchivaAdministrationService().deleteLegacyArtifactPath( "bar" );
+ assertEquals( initialSize, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
+ }
+
+ @Test
+ public void addAndDeleteFileType()
+ throws Exception
+ {
+ int initialSize = getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size();
+ FileType fileType = new FileType();
+ fileType.setId( "foo" );
+ fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
+ getArchivaAdministrationService().addFileType( fileType );
+ assertEquals( initialSize + 1,
+ getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size() );
+
+ assertNotNull( getArchivaAdministrationService().getFileType( "foo" ) );
+ assertEquals( Arrays.asList( "foo", "bar" ),
+ getArchivaAdministrationService().getFileType( "foo" ).getPatterns() );
+ }
}