mirror of https://github.com/apache/archiva.git
Merged /archiva/trunk:r882384-883981
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@883995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
commit
8a0aa76e24
|
@ -67,6 +67,9 @@ Understanding Repository Configuration of Apache Archiva
|
|||
|
||||
* <releases included> - specifies whether there are released artifacts in the repository.
|
||||
|
||||
* <block re-deployment of released artifacts> - specifies whether released artifacts that are already existing in the repository can be overwritten.
|
||||
Note that this only take effects for non-snapshot deployments.
|
||||
|
||||
* <snapshots included> - specifies whether there are snapshot artifacts in the repository.
|
||||
|
||||
* <scannable> - specifies whether the repository can be scanned, meaning it is a local repository which can be indexed, browsed,
|
||||
|
|
|
@ -10,6 +10,9 @@ Deploying to Repository
|
|||
|
||||
* {{{#Web UI} Deploying via the Web UI Form}}
|
||||
|
||||
Starting with Archiva 1.2.3, it is possible to block re-deployment of released artifacts to a specific repository. This can be configured through the
|
||||
repository configuration page by ticking the <<<Block Re-deployment of Released Artifacts>>> checkbox.
|
||||
|
||||
[]
|
||||
|
||||
<<WARNING>> The deployed artifact may not appear immediately in the search results.
|
||||
|
|
|
@ -475,6 +475,13 @@
|
|||
<description>True if this repository contains release versioned artifacts.</description>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>blockRedeployments</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>boolean</type>
|
||||
<description>True if re-deployment of artifacts already in the repository will be blocked.</description>
|
||||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshots</name>
|
||||
<version>1.0.0+</version>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<blockRedeployments>true</blockRedeployments>
|
||||
<scanned>true</scanned>
|
||||
<refreshCronExpression>0 0 * * * ?</refreshCronExpression>
|
||||
<daysOlder>30</daysOlder>
|
||||
|
@ -20,6 +21,7 @@
|
|||
<layout>default</layout>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<blockRedeployments>false</blockRedeployments>
|
||||
<scanned>true</scanned>
|
||||
<refreshCronExpression>0 0\,30 * * * ?</refreshCronExpression>
|
||||
<daysOlder>30</daysOlder>
|
||||
|
|
|
@ -95,3 +95,7 @@ NETWORKPROXY_HOSTNAME=
|
|||
NETWORKPROXY_PORT=8080
|
||||
NETWORKPROXY_USERNAME=admin
|
||||
NETWORKPROXY_PASSWORD=admin123
|
||||
|
||||
# Browse - MRM-1278 test
|
||||
SNAPSHOTS_REPOSITORY=snapshots
|
||||
RELEASES_REPOSITORY=releases
|
||||
|
|
|
@ -88,6 +88,14 @@ public class ArtifactManagementTest
|
|||
addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
|
||||
assertTextPresent( "Artifact 'test:test:1.0' was successfully deployed to repository 'internal'" );
|
||||
}
|
||||
|
||||
//MRM-747
|
||||
@Test(dependsOnMethods = { "testAddArtifactValidValues" } )
|
||||
public void testAddArtifactBlockRedeployments()
|
||||
{
|
||||
addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
|
||||
assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
|
||||
}
|
||||
|
||||
public void testAddArtifactValidValues1()
|
||||
{
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.archiva.web.test;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.archiva.web.test.parent.AbstractBrowseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -42,4 +44,71 @@ public class BrowseTest
|
|||
assertTextPresent( "Artifacts" );
|
||||
}
|
||||
|
||||
// MRM-1278
|
||||
public void testCorrectRepositoryInBrowse()
|
||||
{
|
||||
File artifact =
|
||||
new File( getBasedir(),
|
||||
"/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" );
|
||||
|
||||
String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
|
||||
|
||||
// create releases repository first
|
||||
goToRepositoriesPage();
|
||||
clickLinkWithText( "Add" );
|
||||
addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
|
||||
new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository",
|
||||
"0 0 * * * ?", "", "" );
|
||||
assertTextPresent( "Releases Repository" );
|
||||
|
||||
String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
|
||||
|
||||
// upload a snapshot artifact to repository 'releases'
|
||||
addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(),
|
||||
releasesRepo );
|
||||
assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
|
||||
|
||||
goToBrowsePage();
|
||||
assertBrowsePage();
|
||||
assertGroupsPage( "archiva/" );
|
||||
assertArtifactsPage( "archiva-webapp/" );
|
||||
assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
|
||||
|
||||
// upload a snapshot artifact to repository 'snapshots'
|
||||
addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", artifact.getPath(),
|
||||
snapshotsRepo );
|
||||
assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
|
||||
|
||||
goToBrowsePage();
|
||||
assertBrowsePage();
|
||||
assertGroupsPage( "continuum/" );
|
||||
assertArtifactsPage( "continuum-core/" );
|
||||
assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
|
||||
}
|
||||
|
||||
private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
|
||||
String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
|
||||
{
|
||||
clickLinkWithText( version );
|
||||
assertPage( "Apache Archiva \\ Browse Repository" );
|
||||
assertTextPresent( artifactInfoRepositoryId );
|
||||
assertTextPresent( artifactInfoGroupId );
|
||||
assertTextPresent( artifactInfoArtifactId );
|
||||
assertTextPresent( artifactInfoVersion );
|
||||
assertTextPresent( artifactInfoPackaging );
|
||||
}
|
||||
|
||||
private void assertArtifactsPage( String artifactId )
|
||||
{
|
||||
clickLinkWithText( artifactId );
|
||||
assertPage( "Apache Archiva \\ Browse Repository" );
|
||||
assertTextPresent( "Versions" );
|
||||
}
|
||||
|
||||
private void assertGroupsPage( String groupId )
|
||||
{
|
||||
clickLinkWithText( groupId );
|
||||
assertPage( "Apache Archiva \\ Browse Repository" );
|
||||
assertTextPresent( "Artifacts" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,18 +30,18 @@ public class RepositoryTest
|
|||
public void testAddManagedRepoValidValues()
|
||||
{
|
||||
goToRepositoriesPage();
|
||||
clickLinkWithText( "Add" );
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
|
||||
addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
|
||||
clickButtonWithValue( "Save" );
|
||||
assertTextPresent( "Managed Repository Sample 1" );
|
||||
|
||||
assertTextPresent( "Managed Repository Sample 1" );
|
||||
assertRepositoriesPage();
|
||||
}
|
||||
|
||||
|
||||
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
|
||||
public void testAddManagedRepoInvalidValues()
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
clickLinkWithText( "Add" );
|
||||
{
|
||||
assertRepositoriesPage();
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
|
||||
addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
|
||||
assertTextPresent( "You must enter a repository identifier." );
|
||||
assertTextPresent( "You must enter a repository name." );
|
||||
|
@ -51,8 +51,7 @@ public class RepositoryTest
|
|||
|
||||
@Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
|
||||
public void testAddManagedRepoNoIdentifier()
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
{
|
||||
addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
|
||||
assertTextPresent( "You must enter a repository identifier." );
|
||||
}
|
||||
|
@ -104,11 +103,10 @@ public class RepositoryTest
|
|||
//assertTextNotPresent( "managedrepo" );
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
|
||||
@Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
|
||||
public void testAddRemoteRepoNullValues()
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" );
|
||||
{
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
|
||||
addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
|
||||
assertTextPresent( "You must enter a repository identifier." );
|
||||
assertTextPresent( "You must enter a repository name." );
|
||||
|
@ -136,11 +134,10 @@ public class RepositoryTest
|
|||
assertTextPresent( "You must enter a url." );
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
|
||||
@Test(dependsOnMethods = { "testDeleteManageRepo" } )
|
||||
public void testAddRemoteRepoValidValues()
|
||||
{
|
||||
goToRepositoriesPage();
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" );
|
||||
{
|
||||
clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
|
||||
addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
|
||||
assertTextPresent( "Remote Repository Sample" );
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class VirtualRepositoryTest
|
|||
assertTextPresent( "testing" );
|
||||
}
|
||||
|
||||
//@Test(dependsOnMethods = { "testAddRepositoryValidValue" } )
|
||||
@Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
|
||||
public void testAddRepositoryToRepositoryGroup()
|
||||
{
|
||||
addRepositoryToRepositoryGroup( "testing", "internal" );
|
||||
|
@ -51,15 +51,17 @@ public class VirtualRepositoryTest
|
|||
|
||||
@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
|
||||
public void testDeleteRepositoryOfRepositoryGroup()
|
||||
{
|
||||
{
|
||||
deleteRepositoryInRepositoryGroups();
|
||||
assertTextPresent( "Repository Groups" );
|
||||
assertTextNotPresent( "No Repository Groups Defined." );
|
||||
waitPage();
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
|
||||
public void testDeleteRepositoryGroup()
|
||||
{
|
||||
{
|
||||
assertRepositoryGroupsPage();
|
||||
deleteRepositoryGroup( "testing" );
|
||||
assertTextPresent( "No Repository Groups Defined." );
|
||||
}
|
||||
|
|
|
@ -449,25 +449,86 @@ public abstract class AbstractArchivaTest
|
|||
setFieldValue( "organisationLogo" , logoUrl );
|
||||
clickButtonWithValue( "Save" );
|
||||
}
|
||||
|
||||
//Upload Artifact
|
||||
public void goToUploadArtifactPage()
|
||||
{
|
||||
clickLinkWithText( "Upload Artifact" );
|
||||
assertUploadArtifactPage();
|
||||
}
|
||||
|
||||
public void assertUploadArtifactPage()
|
||||
{
|
||||
//assertPage( "Apache Archiva \\ Upload Artifact" );
|
||||
String uploadArtifact = "Upload Artifact,Group Id*,Artifact Id*,Version*,Packaging*,Classifier,Generate Maven 2 POM,Artifact File*,POM File,Repository Id";
|
||||
String[] arrayUploadArtifact = uploadArtifact.split( "," );
|
||||
for ( String uploadartifact : arrayUploadArtifact )
|
||||
assertTextPresent( uploadartifact );
|
||||
String uploadElements = "groupId,artifactId,version,packaging,classifier,generatePom,artifact,pom,repositoryId";
|
||||
String[] arrayUploadElements = uploadElements.split( "," );
|
||||
for ( String uploadelements : arrayUploadElements )
|
||||
assertElementPresent( uploadelements );
|
||||
assertButtonWithValuePresent( "Submit" );
|
||||
}
|
||||
|
||||
// Upload Artifact
|
||||
public void goToAddArtifactPage()
|
||||
{
|
||||
clickLinkWithText( "Upload Artifact" );
|
||||
assertAddArtifactPage();
|
||||
}
|
||||
|
||||
public void assertAddArtifactPage()
|
||||
{
|
||||
assertPage( "Apache Archiva \\ Upload Artifact" );
|
||||
assertTextPresent( "Upload Artifact" );
|
||||
|
||||
String artifact =
|
||||
"Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
|
||||
String[] arrayArtifact = artifact.split( "," );
|
||||
for ( String arrayartifact : arrayArtifact )
|
||||
assertTextPresent( arrayartifact );
|
||||
|
||||
String artifactElements =
|
||||
"upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
|
||||
String[] arrayArtifactElements = artifactElements.split( "," );
|
||||
for ( String artifactelements : arrayArtifactElements )
|
||||
assertElementPresent( artifactelements );
|
||||
}
|
||||
|
||||
public void addArtifact( String groupId, String artifactId, String version, String packaging,
|
||||
String artifactFilePath, String repositoryId )
|
||||
{
|
||||
addArtifact( groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId );
|
||||
}
|
||||
|
||||
public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom,
|
||||
String artifactFilePath, String repositoryId )
|
||||
{
|
||||
goToAddArtifactPage();
|
||||
setFieldValue( "groupId", groupId );
|
||||
setFieldValue( "artifactId", artifactId );
|
||||
setFieldValue( "version", version );
|
||||
setFieldValue( "packaging", packaging );
|
||||
|
||||
if ( generatePom )
|
||||
{
|
||||
checkField( "generatePom" );
|
||||
}
|
||||
|
||||
setFieldValue( "artifact", artifactFilePath );
|
||||
setFieldValue( "repositoryId", repositoryId );
|
||||
|
||||
clickButtonWithValue( "Submit" );
|
||||
}
|
||||
|
||||
public void goToRepositoriesPage()
|
||||
{
|
||||
clickLinkWithText( "Repositories" );
|
||||
assertRepositoriesPage();
|
||||
}
|
||||
|
||||
public void assertRepositoriesPage()
|
||||
{
|
||||
assertPage( "Apache Archiva \\ Administration - Repositories" );
|
||||
assertTextPresent( "Administration - Repositories" );
|
||||
assertTextPresent( "Managed Repositories" );
|
||||
assertTextPresent( "Remote Repositories" );
|
||||
}
|
||||
|
||||
public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron,
|
||||
String daysOlder, String retentionCount )
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
//clickLinkWithText( "Add" );
|
||||
setFieldValue( "repository.id" , identifier );
|
||||
setFieldValue( "repository.name" , name );
|
||||
setFieldValue( "repository.location" , directory );
|
||||
setFieldValue( "repository.indexDir" , indexDirectory );
|
||||
selectValue( "repository.layout", type );
|
||||
setFieldValue( "repository.refreshCronExpression" , cron );
|
||||
setFieldValue( "repository.daysOlder" , daysOlder );
|
||||
setFieldValue( "repository.retentionCount" , retentionCount );
|
||||
//TODO
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,42 +43,12 @@ public abstract class AbstractArtifactManagementTest
|
|||
return repositoryId;
|
||||
}
|
||||
|
||||
public void goToAddArtifactPage()
|
||||
{
|
||||
clickLinkWithText( "Upload Artifact" );
|
||||
assertAddArtifactPage();
|
||||
}
|
||||
|
||||
public void goToDeleteArtifactPage()
|
||||
{
|
||||
clickLinkWithText( "Delete Artifact" );
|
||||
assertDeleteArtifactPage();
|
||||
}
|
||||
|
||||
public void addArtifact( String groupId, String artifactId, String version, String packaging, String artifactFilePath, String repositoryId )
|
||||
{
|
||||
addArtifact(groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId);
|
||||
}
|
||||
|
||||
public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom, String artifactFilePath, String repositoryId)
|
||||
{
|
||||
goToAddArtifactPage();
|
||||
setFieldValue( "groupId" , groupId );
|
||||
setFieldValue( "artifactId" , artifactId );
|
||||
setFieldValue( "version" , version );
|
||||
setFieldValue( "packaging" , packaging );
|
||||
|
||||
if ( generatePom )
|
||||
{
|
||||
checkField( "generatePom" );
|
||||
}
|
||||
|
||||
setFieldValue( "artifact" , artifactFilePath );
|
||||
setFieldValue( "repositoryId" , repositoryId );
|
||||
|
||||
clickButtonWithValue( "Submit" );
|
||||
}
|
||||
|
||||
public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
|
||||
{
|
||||
goToDeleteArtifactPage();
|
||||
|
@ -89,22 +59,6 @@ public abstract class AbstractArtifactManagementTest
|
|||
clickButtonWithValue( "Submit" ) ;
|
||||
}
|
||||
|
||||
public void assertAddArtifactPage()
|
||||
{
|
||||
assertPage( "Apache Archiva \\ Upload Artifact" );
|
||||
assertTextPresent( "Upload Artifact" );
|
||||
|
||||
String artifact = "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
|
||||
String[] arrayArtifact = artifact.split( "," );
|
||||
for ( String arrayartifact : arrayArtifact )
|
||||
assertTextPresent( arrayartifact );
|
||||
|
||||
String artifactElements = "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
|
||||
String[] arrayArtifactElements = artifactElements.split( "," );
|
||||
for ( String artifactelements : arrayArtifactElements )
|
||||
assertElementPresent( artifactelements );
|
||||
}
|
||||
|
||||
public void assertDeleteArtifactPage()
|
||||
{
|
||||
assertPage( "Apache Archiva \\ Delete Artifact" );
|
||||
|
|
|
@ -212,23 +212,6 @@ public abstract class AbstractRepositoryTest
|
|||
clickButtonWithValue( "Delete" );
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// repositories
|
||||
///////////////////////////////
|
||||
public void goToRepositoriesPage()
|
||||
{
|
||||
clickLinkWithText( "Repositories" );
|
||||
assertRepositoriesPage();
|
||||
}
|
||||
|
||||
public void assertRepositoriesPage()
|
||||
{
|
||||
assertPage( "Apache Archiva \\ Administration - Repositories" );
|
||||
assertTextPresent( "Administration - Repositories" );
|
||||
assertTextPresent( "Managed Repositories" );
|
||||
assertTextPresent( "Remote Repositories" );
|
||||
}
|
||||
|
||||
// remote repositories
|
||||
public void assertAddRemoteRepository()
|
||||
{
|
||||
|
@ -283,23 +266,6 @@ public abstract class AbstractRepositoryTest
|
|||
clickButtonWithValue( "Update Repository" );
|
||||
}
|
||||
|
||||
// managed repositories
|
||||
public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount )
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
//clickLinkWithText( "Add" );
|
||||
setFieldValue( "repository.id" , identifier );
|
||||
setFieldValue( "repository.name" , name );
|
||||
setFieldValue( "repository.location" , directory );
|
||||
setFieldValue( "repository.indexDir" , indexDirectory );
|
||||
selectValue( "repository.layout", type );
|
||||
setFieldValue( "repository.refreshCronExpression" , cron );
|
||||
setFieldValue( "repository.daysOlder" , daysOlder );
|
||||
setFieldValue( "repository.retentionCount" , retentionCount );
|
||||
//TODO
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
}
|
||||
|
||||
public void editManagedRepository( String fieldName, String value )
|
||||
{
|
||||
//goToRepositoriesPage();
|
||||
|
|
|
@ -372,7 +372,7 @@ public class ShowArtifactAction
|
|||
this.snapshotVersions = snapshotVersions;
|
||||
}
|
||||
|
||||
public MetadataResolver getMetadataRepository()
|
||||
public MetadataResolver getMetadataResolver()
|
||||
{
|
||||
return metadataResolver;
|
||||
}
|
||||
|
|
|
@ -349,8 +349,17 @@ public class UploadAction
|
|||
|
||||
try
|
||||
{
|
||||
copyFile( artifactFile, targetPath, filename, fixChecksums );
|
||||
queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) );
|
||||
File targetFile = new File( targetPath, filename );
|
||||
if( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
|
||||
{
|
||||
addActionError( "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." );
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
copyFile( artifactFile, targetPath, filename, fixChecksums );
|
||||
queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) );
|
||||
}
|
||||
}
|
||||
catch ( IOException ie )
|
||||
{
|
||||
|
|
|
@ -52,13 +52,15 @@ public class AddManagedRepositoryAction
|
|||
{
|
||||
this.repository = new ManagedRepositoryConfiguration();
|
||||
this.repository.setReleases( false );
|
||||
this.repository.setScanned( false );
|
||||
this.repository.setScanned( false );
|
||||
this.repository.setBlockRedeployments( false );
|
||||
}
|
||||
|
||||
public String input()
|
||||
{
|
||||
this.repository.setReleases( true );
|
||||
this.repository.setScanned( true );
|
||||
this.repository.setBlockRedeployments( true );
|
||||
|
||||
return INPUT;
|
||||
}
|
||||
|
|
|
@ -25,12 +25,19 @@ import com.opensymphony.xwork2.Validateable;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||
import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
|
||||
import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint;
|
||||
import org.apache.maven.archiva.model.RepositoryContentStatistics;
|
||||
import org.apache.maven.archiva.repository.audit.AuditEvent;
|
||||
import org.codehaus.plexus.redback.role.RoleManagerException;
|
||||
import org.codehaus.plexus.scheduler.CronExpressionValidator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AddManagedRepositoryAction
|
||||
|
@ -52,6 +59,11 @@ public class EditManagedRepositoryAction
|
|||
|
||||
private final String action = "editRepository";
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private ArchivaDAO archivaDAO;
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
if ( StringUtils.isNotBlank( repoid ) )
|
||||
|
@ -78,17 +90,22 @@ public class EditManagedRepositoryAction
|
|||
|
||||
public String confirmUpdate()
|
||||
{
|
||||
return save();
|
||||
// location was changed
|
||||
return save( true );
|
||||
}
|
||||
|
||||
public String commit()
|
||||
{
|
||||
{
|
||||
ManagedRepositoryConfiguration existingConfig =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repository.getId() );
|
||||
|
||||
|
||||
boolean resetStats = false;
|
||||
|
||||
// check if the location was changed
|
||||
if( !StringUtils.equalsIgnoreCase( existingConfig.getLocation().trim(), repository.getLocation().trim() ) )
|
||||
{
|
||||
resetStats = true;
|
||||
|
||||
File dir = new File( repository.getLocation() );
|
||||
if( dir.exists() )
|
||||
{
|
||||
|
@ -96,10 +113,10 @@ public class EditManagedRepositoryAction
|
|||
}
|
||||
}
|
||||
|
||||
return save();
|
||||
return save( resetStats );
|
||||
}
|
||||
|
||||
private String save()
|
||||
|
||||
private String save( boolean resetStats )
|
||||
{
|
||||
// Ensure that the fields are valid.
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
@ -115,6 +132,7 @@ public class EditManagedRepositoryAction
|
|||
triggerAuditEvent( repository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO );
|
||||
addRepositoryRoles( repository );
|
||||
result = saveConfiguration( configuration );
|
||||
resetStatistics( resetStats );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
@ -126,6 +144,16 @@ public class EditManagedRepositoryAction
|
|||
addActionError( "Role Manager Exception: " + e.getMessage() );
|
||||
result = ERROR;
|
||||
}
|
||||
catch ( ObjectNotFoundException e )
|
||||
{
|
||||
addActionError( e.getMessage() );
|
||||
result = ERROR;
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
addActionError( e.getMessage() );
|
||||
result = ERROR;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -141,6 +169,28 @@ public class EditManagedRepositoryAction
|
|||
}
|
||||
}
|
||||
|
||||
private void resetStatistics( boolean reset )
|
||||
throws ObjectNotFoundException, ArchivaDatabaseException
|
||||
{
|
||||
if ( !reset )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RepositoryContentStatisticsDAO repoContentStatsDao = archivaDAO.getRepositoryContentStatisticsDAO();
|
||||
|
||||
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
|
||||
new RepositoryContentStatisticsByRepositoryConstraint( repository.getId() ) );
|
||||
|
||||
if ( contentStats != null )
|
||||
{
|
||||
for ( RepositoryContentStatistics stats : contentStats )
|
||||
{
|
||||
repoContentStatsDao.deleteRepositoryContentStatistics( stats );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getRepoid()
|
||||
{
|
||||
return repoid;
|
||||
|
@ -165,4 +215,11 @@ public class EditManagedRepositoryAction
|
|||
{
|
||||
return action;
|
||||
}
|
||||
|
||||
// for testing
|
||||
|
||||
public void setArchivaDAO( ArchivaDAO archivaDao )
|
||||
{
|
||||
this.archivaDAO = archivaDao;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,14 +30,15 @@
|
|||
<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:application.properties" />
|
||||
</bean>
|
||||
|
||||
<bean name="testXmlRpcService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.PingServiceImpl"/>
|
||||
|
||||
<bean name="xmlRpcUserRepositories" class="org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories">
|
||||
<constructor-arg ref="userRepositories"/>
|
||||
<constructor-arg ref="xmlRpcAuthenticator"/>
|
||||
</bean>
|
||||
|
||||
<!-- Web Service : Ping Service -->
|
||||
<bean name="pingService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.PingServiceImpl"/>
|
||||
|
||||
<!-- Web Services : Search Service -->
|
||||
<bean name="searchService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.SearchServiceImpl">
|
||||
<constructor-arg ref="xmlRpcUserRepositories"/>
|
||||
|
@ -64,6 +65,7 @@
|
|||
<list>
|
||||
<ref bean="administrationService"/>
|
||||
<ref bean="searchService"/>
|
||||
<ref bean="pingService"/>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<s:textfield name="repository.daysOlder" label="Repository Purge By Days Older Than" size="5"/>
|
||||
<s:textfield name="repository.retentionCount" label="Repository Purge By Retention Count" size="5"/>
|
||||
<s:checkbox name="repository.releases" value="repository.releases" label="Releases Included"/>
|
||||
<s:checkbox name="repository.blockRedeployments" value="repository.blockRedeployments" label="Block Re-deployment of Released Artifacts"/>
|
||||
<s:checkbox name="repository.snapshots" value="repository.snapshots" label="Snapshots Included"/>
|
||||
<s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/>
|
||||
<s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots"
|
||||
|
|
|
@ -437,6 +437,6 @@ public class ShowArtifactActionTest
|
|||
{
|
||||
super.setUp();
|
||||
action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT );
|
||||
metadataResolver = (TestMetadataResolver) action.getMetadataRepository();
|
||||
metadataResolver = (TestMetadataResolver) action.getMetadataResolver();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public class UploadActionTest
|
|||
repoConfig.setLayout( "default" );
|
||||
repoConfig.setLocation( testRepo.getPath() );
|
||||
repoConfig.setName( REPOSITORY_ID );
|
||||
repoConfig.setBlockRedeployments( true );
|
||||
config.addManagedRepository( repoConfig );
|
||||
|
||||
RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration();
|
||||
|
@ -335,7 +336,7 @@ public class UploadActionTest
|
|||
|
||||
public void testArtifactUploadFailedRepositoryNotFound()
|
||||
throws Exception
|
||||
{
|
||||
{
|
||||
setUploadParameters( "1.0", null,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
|
||||
|
@ -404,9 +405,9 @@ public class UploadActionTest
|
|||
true );
|
||||
|
||||
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
|
||||
content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
|
||||
|
||||
|
||||
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
|
||||
repoConfig.setBlockRedeployments( false );
|
||||
content.setRepository( repoConfig );
|
||||
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
||||
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
|
||||
|
@ -450,5 +451,81 @@ public class UploadActionTest
|
|||
assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
|
||||
|
||||
verifyChecksums( repoLocation );
|
||||
}
|
||||
}
|
||||
|
||||
public void testUploadArtifactAlreadyExistingRedeploymentsBlocked()
|
||||
throws Exception
|
||||
{
|
||||
setUploadParameters( "1.0", null,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
|
||||
true );
|
||||
|
||||
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
|
||||
content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
|
||||
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
|
||||
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
|
||||
|
||||
archivaConfigControl.replay();
|
||||
repoFactoryControl.replay();
|
||||
|
||||
String returnString = uploadAction.doUpload();
|
||||
assertEquals( Action.SUCCESS, returnString );
|
||||
|
||||
setUploadParameters( "1.0", null,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
|
||||
true );
|
||||
|
||||
returnString = uploadAction.doUpload();
|
||||
assertEquals( Action.ERROR, returnString );
|
||||
|
||||
archivaConfigControl.verify();
|
||||
repoFactoryControl.verify();
|
||||
|
||||
String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
|
||||
assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
|
||||
|
||||
verifyChecksums( repoLocation );
|
||||
}
|
||||
|
||||
public void testUploadArtifactAlreadyExistingRedeploymentsAllowed()
|
||||
throws Exception
|
||||
{
|
||||
setUploadParameters( "1.0", null,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
|
||||
true );
|
||||
|
||||
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
|
||||
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
|
||||
repoConfig.setBlockRedeployments( false );
|
||||
content.setRepository( repoConfig );
|
||||
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
|
||||
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
|
||||
|
||||
archivaConfigControl.replay();
|
||||
repoFactoryControl.replay();
|
||||
|
||||
String returnString = uploadAction.doUpload();
|
||||
assertEquals( Action.SUCCESS, returnString );
|
||||
|
||||
setUploadParameters( "1.0", null,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
|
||||
true );
|
||||
|
||||
returnString = uploadAction.doUpload();
|
||||
assertEquals( Action.SUCCESS, returnString );
|
||||
|
||||
archivaConfigControl.verify();
|
||||
repoFactoryControl.verify();
|
||||
|
||||
String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
|
||||
assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
|
||||
|
||||
verifyChecksums( repoLocation );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ import com.opensymphony.xwork2.Action;
|
|||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
|
||||
import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint;
|
||||
import org.apache.maven.archiva.model.RepositoryContentStatistics;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.redback.role.RoleManager;
|
||||
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
|
||||
|
@ -32,7 +36,10 @@ import org.easymock.MockControl;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EditManagedRepositoryActionTest
|
||||
|
@ -52,6 +59,14 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
private MockControl archivaDaoControl;
|
||||
|
||||
private ArchivaDAO archivaDao;
|
||||
|
||||
private MockControl repoContentStatsDaoControl;
|
||||
|
||||
private RepositoryContentStatisticsDAO repoContentStatsDao;
|
||||
|
||||
private static final String REPO_ID = "repo-ident";
|
||||
|
||||
private File location;
|
||||
|
@ -77,6 +92,13 @@ public class EditManagedRepositoryActionTest
|
|||
roleManager = (RoleManager) roleManagerControl.getMock();
|
||||
action.setRoleManager( roleManager );
|
||||
location = getTestFile( "target/test/location" );
|
||||
|
||||
archivaDaoControl = MockControl.createControl( ArchivaDAO.class );
|
||||
archivaDao = (ArchivaDAO) archivaDaoControl.getMock();
|
||||
action.setArchivaDAO( archivaDao );
|
||||
|
||||
repoContentStatsDaoControl = MockControl.createControl( RepositoryContentStatisticsDAO.class );
|
||||
repoContentStatsDao = (RepositoryContentStatisticsDAO) repoContentStatsDaoControl.getMock();
|
||||
}
|
||||
|
||||
public void testSecureActionBundle()
|
||||
|
@ -157,6 +179,66 @@ public class EditManagedRepositoryActionTest
|
|||
roleManagerControl.verify();
|
||||
archivaConfigurationControl.verify();
|
||||
}
|
||||
|
||||
public void testEditRepositoryLocationChanged()
|
||||
throws Exception
|
||||
{
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
|
||||
roleManagerControl.setVoidCallable();
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
roleManagerControl.replay();
|
||||
|
||||
Configuration configuration = createConfigurationForEditing( createRepository() );
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
archivaDaoControl.expectAndReturn( archivaDao.getRepositoryContentStatisticsDAO(), repoContentStatsDao );
|
||||
|
||||
archivaDaoControl.replay();
|
||||
|
||||
repoContentStatsDao.queryRepositoryContentStatistics(
|
||||
new RepositoryContentStatisticsByRepositoryConstraint( REPO_ID ) );
|
||||
repoContentStatsDaoControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
|
||||
List<RepositoryContentStatistics> repoStats = createRepositoryContentStatisticsList();
|
||||
repoContentStatsDaoControl.setReturnValue( repoStats );
|
||||
|
||||
repoContentStatsDao.deleteRepositoryContentStatistics( repoStats.get( 0 ) );
|
||||
repoContentStatsDaoControl.setVoidCallable();
|
||||
repoContentStatsDao.deleteRepositoryContentStatistics( repoStats.get( 1 ) );
|
||||
repoContentStatsDaoControl.setVoidCallable();
|
||||
|
||||
repoContentStatsDaoControl.replay();
|
||||
|
||||
action.setRepoid( REPO_ID );
|
||||
action.prepare();
|
||||
assertEquals( REPO_ID, action.getRepoid() );
|
||||
|
||||
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
|
||||
populateRepository( repository );
|
||||
repository.setLocation( new File( "target/test/location/new" ).getCanonicalPath() );
|
||||
action.setRepository( repository );
|
||||
String status = action.commit();
|
||||
assertEquals( Action.SUCCESS, status );
|
||||
assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
|
||||
|
||||
roleManagerControl.verify();
|
||||
archivaConfigurationControl.verify();
|
||||
archivaDaoControl.verify();
|
||||
repoContentStatsDaoControl.verify();
|
||||
}
|
||||
|
||||
private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository,
|
||||
ManagedRepositoryConfiguration actualRepository )
|
||||
|
@ -207,4 +289,29 @@ public class EditManagedRepositoryActionTest
|
|||
repository.setDeleteReleasedSnapshots( true );
|
||||
}
|
||||
|
||||
private List<RepositoryContentStatistics> createRepositoryContentStatisticsList()
|
||||
{
|
||||
List<RepositoryContentStatistics> repoStatsList = new ArrayList<RepositoryContentStatistics>();
|
||||
|
||||
repoStatsList.add( createRepositoryContentStatistics() );
|
||||
repoStatsList.add( createRepositoryContentStatistics() );
|
||||
|
||||
return repoStatsList;
|
||||
}
|
||||
|
||||
private RepositoryContentStatistics createRepositoryContentStatistics()
|
||||
{
|
||||
RepositoryContentStatistics repoStats = new RepositoryContentStatistics();
|
||||
repoStats.setRepositoryId( REPO_ID );
|
||||
repoStats.setDuration( 1000 );
|
||||
repoStats.setTotalArtifactCount( 100 );
|
||||
repoStats.setTotalSize( 10 );
|
||||
repoStats.setTotalFileCount( 10 );
|
||||
repoStats.setTotalProjectCount( 2 );
|
||||
repoStats.setTotalGroupCount( 1 );
|
||||
repoStats.setNewFileCount( 3 );
|
||||
repoStats.setWhenGathered( new Date( System.currentTimeMillis() ) );
|
||||
|
||||
return repoStats;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ public class ArchivaDavResourceFactory
|
|||
String resourcePath = logicalResource.getPath();
|
||||
|
||||
// check if target repo is enabled for releases
|
||||
// we suppose that release-artifacts can deployed only to repos enabled for releases
|
||||
// we suppose that release-artifacts can be deployed only to repos enabled for releases
|
||||
if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath ) &&
|
||||
!repositoryRequest.isSupportFile( resourcePath ) )
|
||||
{
|
||||
|
@ -495,10 +495,10 @@ public class ArchivaDavResourceFactory
|
|||
|
||||
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
|
||||
{
|
||||
// check if artifact already exists
|
||||
if ( managedRepository.hasContent( artifact ) )
|
||||
// check if artifact already exists and if artifact re-deployment to the repository is allowed
|
||||
if ( managedRepository.hasContent( artifact ) && managedRepository.getRepository().isBlockRedeployments() )
|
||||
{
|
||||
log.warn( "Overwriting released artifacts is not allowed." );
|
||||
log.warn( "Overwriting released artifacts in repository '" + managedRepository.getId() + "' is not allowed." );
|
||||
throw new DavException( HttpServletResponse.SC_CONFLICT,
|
||||
"Overwriting released artifacts is not allowed." );
|
||||
}
|
||||
|
|
|
@ -119,12 +119,14 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
response.getResponseCode() );
|
||||
}
|
||||
|
||||
protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location )
|
||||
protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location, boolean blockRedeployments )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
|
||||
repo.setId( id );
|
||||
repo.setName( name );
|
||||
repo.setLocation( location.getAbsolutePath() );
|
||||
repo.setBlockRedeployments( blockRedeployments );
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
|
@ -182,7 +184,7 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
repoRootInternal = new File( appserverBase, "data/repositories/internal" );
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
|
||||
config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
|
||||
saveConfiguration( archivaConfiguration );
|
||||
|
||||
CacheManager.getInstance().removeCache( "url-failures-cache" );
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.io.File;
|
|||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.webdav.httpunit.MkColMethodWebRequest;
|
||||
|
||||
|
||||
|
@ -98,6 +100,46 @@ public class RepositoryServletDeployTest
|
|||
assertResponseConflictError( response );
|
||||
}
|
||||
|
||||
public void testReleaseArtifactsRedeploymentIsAllowed()
|
||||
throws Exception
|
||||
{
|
||||
setupCleanRepo( repoRootInternal );
|
||||
|
||||
ManagedRepositoryConfiguration managedRepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( REPOID_INTERNAL );
|
||||
managedRepo.setBlockRedeployments( false );
|
||||
|
||||
saveConfiguration( archivaConfiguration );
|
||||
|
||||
String putUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT;
|
||||
String metadataUrl = "http://machine.com/repository/internal/path/to/artifact/maven-metadata.xml";
|
||||
String checksumUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT + ".sha1";
|
||||
|
||||
InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
|
||||
// verify that the file exists in resources-dir
|
||||
assertNotNull( "artifact.jar inputstream", is );
|
||||
|
||||
// send request #1 and verify it's successful
|
||||
WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
assertResponseCreated( response );
|
||||
|
||||
is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
|
||||
request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
|
||||
response = sc.getResponse( request );
|
||||
assertResponseCreated( response );
|
||||
|
||||
is = getClass().getResourceAsStream( "/maven-metadata.xml" );
|
||||
request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" );
|
||||
response = sc.getResponse( request );
|
||||
assertResponseCreated( response );
|
||||
|
||||
// send request #2 and verify if it's still successful
|
||||
is = getClass().getResourceAsStream( "/artifact.jar" );
|
||||
request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
|
||||
response = sc.getResponse( request );
|
||||
assertResponseNoContent( response );
|
||||
}
|
||||
|
||||
public void testReleaseArtifactsRedeploymentInvalidPath()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -90,8 +90,8 @@ public class RepositoryServletRepositoryGroupTest
|
|||
repoRootFirst = new File( appserverBase, "data/repositories/" + MANAGED_REPO_FIRST );
|
||||
repoRootLast = new File( appserverBase, "data/repositories/" + MANAGED_REPO_LAST );
|
||||
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
List<String> managedRepoIds = new ArrayList<String>();
|
||||
managedRepoIds.add( MANAGED_REPO_FIRST );
|
||||
|
@ -101,11 +101,11 @@ public class RepositoryServletRepositoryGroupTest
|
|||
|
||||
// Create the repository group with an invalid managed repository
|
||||
repoRootInvalid = new File( appserverBase, "data/repositories/" + MANAGED_REPO_INVALID );
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid );
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true );
|
||||
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
configuration.addManagedRepository( managedRepositoryConfiguration );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
List<String> invalidManagedRepoIds = new ArrayList<String>();
|
||||
invalidManagedRepoIds.add( MANAGED_REPO_FIRST );
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.apache.archiva.web.xmlrpc.api;
|
|||
|
||||
import com.atlassian.xmlrpc.ServiceObject;
|
||||
|
||||
@ServiceObject("Test")
|
||||
public interface TestService
|
||||
@ServiceObject("PingService")
|
||||
public interface PingService
|
||||
{
|
||||
public String ping();
|
||||
}
|
|
@ -75,6 +75,11 @@ public class Artifact
|
|||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getRepositoryId()
|
||||
{
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
/*public Date getWhenGathered()
|
||||
{
|
||||
|
@ -104,20 +109,16 @@ public class Artifact
|
|||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ServiceBeanField( "repositoryId" )
|
||||
public void setRepositoryId( String repositoryId )
|
||||
{
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
/*@ServiceBeanField( "whenGathered" )
|
||||
public void setWhenGathered( Date whenGathered )
|
||||
{
|
||||
this.whenGathered = whenGathered;
|
||||
}*/
|
||||
|
||||
public String getRepositoryId()
|
||||
{
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId( String repositoryId )
|
||||
{
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.archiva.web.xmlrpc.api.AdministrationService;
|
||||
import org.apache.archiva.web.xmlrpc.api.PingService;
|
||||
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
||||
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
||||
|
||||
|
@ -55,6 +56,10 @@ public class SampleClient
|
|||
{
|
||||
AuthenticationInfo authnInfo = new AuthenticationInfo( args[1], args[2] );
|
||||
AdministrationService adminService = binder.bind( AdministrationService.class, new URL( args[0] ), authnInfo );
|
||||
PingService pingService = binder.bind( PingService.class, new URL( args[0] ), authnInfo );
|
||||
|
||||
System.out.println( "Ping : " + pingService.ping() );
|
||||
|
||||
List<ManagedRepository> managedRepos = adminService.getAllManagedRepositories();
|
||||
|
||||
System.out.println( "\n******** Managed Repositories ********" );
|
||||
|
|
|
@ -49,5 +49,6 @@ public class ServiceMethodsPermissionsMapping
|
|||
"SearchService.getArtifactVersions", "SearchService.getArtifactVersionsByDate",
|
||||
"SearchService.getDependencies", "SearchService.getDependencyTree",
|
||||
"SearchService.getDependees" );
|
||||
|
||||
|
||||
public static final String PING = "PingService.ping";
|
||||
}
|
||||
|
|
|
@ -132,7 +132,11 @@ public class XmlRpcAuthenticator
|
|||
{
|
||||
throw new XmlRpcException( 401, e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( methodName.equals( ServiceMethodsPermissionsMapping.PING ) )
|
||||
{
|
||||
return new AuthorizationResult( true, username, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return securitySystem.authorize( session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE );
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.apache.archiva.web.xmlrpc.services;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.web.xmlrpc.api.TestService;
|
||||
import org.apache.archiva.web.xmlrpc.api.PingService;
|
||||
|
||||
public class PingServiceImpl implements TestService
|
||||
public class PingServiceImpl implements PingService
|
||||
{
|
||||
public String ping()
|
||||
{
|
||||
|
|
|
@ -104,33 +104,35 @@ public class SearchServiceImpl
|
|||
resultHit.setVersion( null );
|
||||
resultHit.setVersions( filterTimestampedSnapshots( versions ) );
|
||||
}
|
||||
|
||||
|
||||
List<String> resultHitVersions = resultHit.getVersions();
|
||||
if( resultHitVersions != null )
|
||||
{
|
||||
for( String version : resultHitVersions )
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version );
|
||||
|
||||
String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version );
|
||||
|
||||
Artifact artifact = null;
|
||||
if( model == null )
|
||||
{
|
||||
artifact = new Artifact( resultHit.getRepositoryId(), resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" );
|
||||
artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" );
|
||||
}
|
||||
else
|
||||
{
|
||||
artifact = new Artifact( resultHit.getRepositoryId(), model.getGroupId(), model.getArtifactId(), version, model.getPackaging() );
|
||||
artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version, model.getPackaging() );
|
||||
}
|
||||
artifacts.add( artifact );
|
||||
}
|
||||
catch( ObjectNotFoundException e )
|
||||
{
|
||||
{
|
||||
log.debug( "Unable to find pom artifact : " + e.getMessage() );
|
||||
}
|
||||
catch( ArchivaDatabaseException e )
|
||||
{
|
||||
{
|
||||
log.debug( "Error occurred while getting pom artifact from database : " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ public class SearchServiceImplTest
|
|||
SearchResultHit resultHit = new SearchResultHit();
|
||||
resultHit.setGroupId( "org.apache.archiva" );
|
||||
resultHit.setArtifactId( "archiva-webapp" );
|
||||
resultHit.setRepositoryId("repo1.mirror");
|
||||
resultHit.setVersions( versions );
|
||||
resultHit.setRepositoryId( null );
|
||||
|
||||
results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-webapp" ), resultHit );
|
||||
|
||||
|
@ -136,6 +136,8 @@ public class SearchServiceImplTest
|
|||
model.setPackaging( "war" );
|
||||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-webapp", "1.0" ), model );
|
||||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-webapp", "1.0" ), "repo1.mirror" );
|
||||
|
||||
userReposControl.replay();
|
||||
searchControl.replay();
|
||||
|
@ -152,12 +154,13 @@ public class SearchServiceImplTest
|
|||
assertNotNull( artifacts );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
Artifact hit = artifacts.get( 0 );
|
||||
assertEquals( "org.apache.archiva", hit.getGroupId() );
|
||||
assertEquals( "archiva-webapp", hit.getArtifactId() );
|
||||
assertEquals( "1.0", hit.getVersion() );
|
||||
assertEquals( "war", hit.getType() );
|
||||
assertEquals( "repo1.mirror", hit.getRepositoryId() );
|
||||
Artifact artifact = artifacts.get( 0 );
|
||||
assertEquals( "org.apache.archiva", artifact.getGroupId() );
|
||||
assertEquals( "archiva-webapp", artifact.getArtifactId() );
|
||||
assertEquals( "1.0", artifact.getVersion() );
|
||||
assertEquals( "war", artifact.getType() );
|
||||
assertNotNull( "Repository should not be null!", artifact.getRepositoryId() );
|
||||
assertEquals( "repo1.mirror", artifact.getRepositoryId() );
|
||||
}
|
||||
|
||||
// returned model is null!
|
||||
|
@ -175,7 +178,7 @@ public class SearchServiceImplTest
|
|||
versions.add( "1.0" );
|
||||
|
||||
SearchResultHit resultHit = new SearchResultHit();
|
||||
resultHit.setRepositoryId( "repo1.mirror" );
|
||||
resultHit.setRepositoryId( null );
|
||||
resultHit.setGroupId( "org.apache.archiva" );
|
||||
resultHit.setArtifactId( "archiva-test" );
|
||||
resultHit.setVersions( versions );
|
||||
|
@ -191,6 +194,8 @@ public class SearchServiceImplTest
|
|||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), null );
|
||||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), null );
|
||||
|
||||
userReposControl.replay();
|
||||
searchControl.replay();
|
||||
repoBrowsingControl.replay();
|
||||
|
@ -206,12 +211,12 @@ public class SearchServiceImplTest
|
|||
assertNotNull( artifacts );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
Artifact hit = artifacts.get( 0 );
|
||||
assertEquals( "org.apache.archiva", hit.getGroupId() );
|
||||
assertEquals( "archiva-test", hit.getArtifactId() );
|
||||
assertEquals( "1.0", hit.getVersion() );
|
||||
assertEquals( "jar", hit.getType() );
|
||||
assertEquals( "repo1.mirror", hit.getRepositoryId() );
|
||||
Artifact artifact = artifacts.get( 0 );
|
||||
assertEquals( "org.apache.archiva", artifact.getGroupId() );
|
||||
assertEquals( "archiva-test", artifact.getArtifactId() );
|
||||
assertEquals( "1.0", artifact.getVersion() );
|
||||
assertEquals( "jar", artifact.getType() );
|
||||
assertNull( "Repository should be null since the model was not found in the database!", artifact.getRepositoryId() );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -290,7 +295,7 @@ public class SearchServiceImplTest
|
|||
resultHit.setGroupId( "org.apache.archiva" );
|
||||
resultHit.setArtifactId( "archiva-test" );
|
||||
resultHit.setVersions( versions );
|
||||
resultHit.setRepositoryId("repo1.mirror");
|
||||
resultHit.setRepositoryId( null );
|
||||
|
||||
results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit );
|
||||
|
||||
|
@ -309,6 +314,8 @@ public class SearchServiceImplTest
|
|||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), model );
|
||||
|
||||
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), "repo1.mirror" );
|
||||
|
||||
userReposControl.replay();
|
||||
searchControl.replay();
|
||||
archivaDAOControl.replay();
|
||||
|
@ -323,6 +330,14 @@ public class SearchServiceImplTest
|
|||
|
||||
assertNotNull( artifacts );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
Artifact artifact = artifacts.get( 0 );
|
||||
assertEquals( "org.apache.archiva", artifact.getGroupId() );
|
||||
assertEquals( "archiva-test", artifact.getArtifactId() );
|
||||
assertEquals( "1.0", artifact.getVersion() );
|
||||
assertEquals( "jar", artifact.getType() );
|
||||
assertNotNull( "Repository should not be null!", artifact.getRepositoryId() );
|
||||
assertEquals( "repo1.mirror", artifact.getRepositoryId() );
|
||||
}
|
||||
|
||||
public void testQuickSearchNoResults( )
|
||||
|
|
Loading…
Reference in New Issue