import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.TreeMap;
/**
- * Browse the repository.
- *
+ * Browse the repository.
+ *
* TODO change name to ShowVersionedAction to conform to terminology.
- *
- * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="showArtifactAction" instantiation-strategy="per-lookup"
+ *
+ * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="showArtifactAction"
+ * instantiation-strategy="per-lookup"
*/
public class ShowArtifactAction
extends AbstractRepositoryBasedAction
private boolean dependencyTree = false;
private ProjectVersionMetadata projectMetadata;
-
+
private String deleteItem;
-
+
private String itemValue;
-
+
private Map<String, String> genericMetadata;
-
+
private String propertyName;
private String propertyValue;
-
-
+
/**
- * Show the versioned project information tab.
- * TODO: Change name to 'project' - we are showing project versions here, not specific artifact information (though
- * that is rendered in the download box).
+ * Show the versioned project information tab. TODO: Change name to 'project' - we are showing project versions
+ * here, not specific artifact information (though that is rendered in the download box).
*/
public String artifact()
{
{
ProjectVersionMetadata versionMetadata = null;
artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
-
+
List<String> repos = getObservableRepos();
for ( String repoId : repos )
{
repositoryId = repoId;
- List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(
- metadataResolver.getArtifacts( repoId, groupId, artifactId, version ) );
+ List<ArtifactMetadata> artifacts =
+ new ArrayList<ArtifactMetadata>( metadataResolver.getArtifacts( repoId, groupId, artifactId,
+ version ) );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{
public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
{
// sort by version (reverse), then ID
// TODO: move version sorting into repository handling (maven2 specific), and perhaps add a
- // way to get latest instead
- int result = new DefaultArtifactVersion( o2.getVersion() ).compareTo(
- new DefaultArtifactVersion( o1.getVersion() ) );
+ // way to get latest instead
+ int result =
+ new DefaultArtifactVersion( o2.getVersion() ).compareTo( new DefaultArtifactVersion(
+ o1.getVersion() ) );
return result != 0 ? result : o1.getId().compareTo( o2.getId() );
}
} );
this.dependees = references;
- // TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet stored in the content repository
+ // TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet
+ // stored in the content repository
// (especially in the case of pre-population import)
return artifact();
// temporarily use this as we only need the model for the tag to perform, but we should be resolving the
// graph here instead
- // TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in the content repository
+ // TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in
+ // the content repository
// (especially in the case of pre-population import)
// TODO: a bit ugly, should really be mapping all these results differently now
public String projectMetadata()
{
String result = artifact();
-
- if( model.getFacet( GenericMetadataFacet.FACET_ID ) != null )
+
+ if ( model.getFacet( GenericMetadataFacet.FACET_ID ) != null )
{
genericMetadata = model.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
}
-
- if( genericMetadata == null )
+
+ if ( genericMetadata == null )
{
genericMetadata = new HashMap<String, String>();
}
return result;
}
-
+
public String addMetadataProperty()
{
String errorMsg = null;
-
+
ProjectVersionMetadata projectMetadata = getProjectVersionMetadata();
- if( projectMetadata == null )
+ if ( projectMetadata == null )
{
addActionError( errorMsg != null ? errorMsg : "Artifact not found" );
return ERROR;
}
-
- if( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
+
+ if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
{
genericMetadata = new HashMap<String, String>();
}
{
genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
}
-
- if( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null || "".equals( propertyValue.trim() ) )
+
+ if ( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null ||
+ "".equals( propertyValue.trim() ) )
{
- model = projectMetadata;
+ model = projectMetadata;
addActionError( errorMsg != null ? errorMsg : "Property Name and Property Value are required." );
return INPUT;
}
-
+
genericMetadata.put( propertyName, propertyValue );
-
+
GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
genericMetadataFacet.fromProperties( genericMetadata );
-
+
// add updated facet
projectMetadata.addFacet( genericMetadataFacet );
-
+
metadataRepository.updateProjectVersion( repositoryId, groupId, artifactId, projectMetadata );
-
+
projectMetadata = getProjectVersionMetadata();
-
+
genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-
+
model = projectMetadata;
-
+
propertyName = "";
propertyValue = "";
-
+
return SUCCESS;
}
-
+
public String updateProjectMetadata()
{
metadataRepository.updateProjectVersion( repositoryId, groupId, artifactId, projectMetadata );
return SUCCESS;
}
-
+
public String deleteMetadataEntry()
- {
+ {
projectMetadata = getProjectVersionMetadata();
-
+
if ( !StringUtils.isEmpty( deleteItem ) && !StringUtils.isEmpty( itemValue ) )
{
if ( "dependency".equals( deleteItem ) )
{
removeLicense();
}
-
+
deleteItem = "";
itemValue = "";
}
-
+
return updateProjectMetadata();
}
-
+
private void removeDependency()
{
List<Dependency> dependencies = projectMetadata.getDependencies();
List<Dependency> newDependencies = new ArrayList<Dependency>();
-
+
if ( dependencies != null )
{
for ( Dependency dependency : dependencies )
}
}
}
-
+
projectMetadata.setDependencies( newDependencies );
}
-
+
private void removeMailingList()
{
List<MailingList> mailingLists = projectMetadata.getMailingLists();
List<MailingList> newMailingLists = new ArrayList<MailingList>();
-
+
if ( mailingLists != null )
{
for ( MailingList mailingList : mailingLists )
}
}
}
-
+
projectMetadata.setMailingLists( newMailingLists );
}
-
+
private void removeLicense()
{
List<License> licenses = projectMetadata.getLicenses();
List<License> newLicenses = new ArrayList<License>();
-
+
if ( licenses != null )
{
for ( License license : licenses )
}
}
}
-
+
projectMetadata.setLicenses( newLicenses );
}
-
+
@Override
public void validate()
{
public void setDeleteItem( String deleteItem )
{
- this.deleteItem = deleteItem;
+ this.deleteItem = deleteItem;
}
-
+
public void setItemValue( String itemValue )
{
this.itemValue = itemValue;
}
-
+
public Map<String, String> getGenericMetadata()
{
return genericMetadata;
{
this.genericMetadata = genericMetadata;
}
-
+
public String getPropertyName()
{
return propertyName;
repositoryId = artifact.getRepositoryId();
// TODO: use metadata resolver capability instead - maybe the storage path could be stored in the metadata
- // though keep in mind the request may not necessarily need to reflect the storage
+ // though keep in mind the request may not necessarily need to reflect the storage
ManagedRepositoryContent repo;
try
{
path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
// TODO: need to accommodate Maven 1 layout too. Non-maven repository formats will need to generate this
- // facet (perhaps on the fly) if wanting to display the Maven 2 elements on the Archiva pages
+ // facet (perhaps on the fly) if wanting to display the Maven 2 elements on the Archiva pages
String type = null;
MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
if ( facet != null )