org.apache.archiva.repository.metadata
Class MetadataTools

java.lang.Object
  extended by org.apache.archiva.repository.metadata.MetadataTools
All Implemented Interfaces:
org.apache.archiva.redback.components.registry.RegistryListener

@Service(value="metadataTools#default")
public class MetadataTools
extends Object
implements org.apache.archiva.redback.components.registry.RegistryListener

MetadataTools


Field Summary
private  ChecksumAlgorithm[] algorithms
           
private  List<String> artifactPatterns
           
private  ArchivaConfiguration configuration
           
private  FileTypes filetypes
           
private static char GROUP_SEPARATOR
           
private  SimpleDateFormat lastUpdatedFormat
           
private  org.slf4j.Logger log
           
static String MAVEN_ARCHETYPE_CATALOG
           
static String MAVEN_METADATA
           
private static char[] NUMS
           
private static char PATH_SEPARATOR
           
private  Map<String,Set<String>> proxies
           
 
Constructor Summary
MetadataTools()
           
 
Method Summary
 void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
           
 void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
           
private  Set<String> findPossibleVersions(Set<String> versions, File metadataParentDirectory)
          Skims the parent directory of a metadata in vain hope of finding subdirectories that contain poms.
private  String formatAsDirectory(String directory)
           
 Set<String> gatherSnapshotVersions(ManagedRepositoryContent managedRepository, VersionedReference reference)
          Gather the set of snapshot versions found in a particular versioned reference.
 ArchivaConfiguration getConfiguration()
           
private  long getExistingLastUpdated(File metadataFile)
           
 FileTypes getFiletypes()
           
 ArtifactReference getFirstArtifact(ManagedRepositoryContent managedRepository, VersionedReference reference)
          Get the first Artifact found in the provided VersionedReference location.
private  long getLastUpdated(ArchivaRepositoryMetadata metadata)
           
private  List<ArchivaRepositoryMetadata> getMetadatasForManagedRepository(ManagedRepositoryContent managedRepository, String logicalResource)
           
 String getRepositorySpecificName(RemoteRepositoryContent repository, String path)
          Adjusts a path for a metadata.xml file to its repository specific path.
 String getRepositorySpecificName(String proxyId, String path)
          Adjusts a path for a metadata.xml file to its repository specific path.
private  boolean hasNumberAnywhere(String version)
           
private  void initConfigVariables()
           
 void initialize()
           
 ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository, ProjectReference reference, String proxyId)
           
 ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository, String logicalResource, String proxyId)
           
 ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository, VersionedReference reference, String proxyId)
           
 void setConfiguration(ArchivaConfiguration configuration)
           
 void setFiletypes(FileTypes filetypes)
           
private  Date toLastUpdatedDate(long lastUpdated)
           
private  long toLastUpdatedLong(String timestampString)
           
 String toPath(ProjectReference reference)
           
 String toPath(VersionedReference reference)
           
 ProjectReference toProjectReference(String path)
           
 VersionedReference toVersionedReference(String path)
          Take a path to a maven-metadata.xml, and attempt to translate it to a VersionedReference.
 void updateMetadata(ManagedRepositoryContent managedRepository, ProjectReference reference)
          Deprecated.  
 void updateMetadata(ManagedRepositoryContent managedRepository, String logicalResource)
           
 void updateMetadata(ManagedRepositoryContent managedRepository, VersionedReference reference)
          Deprecated.  
private  void updateMetadataVersions(Collection<String> allVersions, ArchivaRepositoryMetadata metadata)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.slf4j.Logger log

MAVEN_METADATA

public static final String MAVEN_METADATA
See Also:
Constant Field Values

MAVEN_ARCHETYPE_CATALOG

public static final String MAVEN_ARCHETYPE_CATALOG
See Also:
Constant Field Values

PATH_SEPARATOR

private static final char PATH_SEPARATOR
See Also:
Constant Field Values

GROUP_SEPARATOR

private static final char GROUP_SEPARATOR
See Also:
Constant Field Values

configuration

@Inject
@Named(value="archivaConfiguration#default")
private ArchivaConfiguration configuration

filetypes

@Inject
@Named(value="fileTypes")
private FileTypes filetypes

algorithms

private ChecksumAlgorithm[] algorithms

artifactPatterns

private List<String> artifactPatterns

proxies

private Map<String,Set<String>> proxies

NUMS

private static final char[] NUMS

lastUpdatedFormat

private SimpleDateFormat lastUpdatedFormat
Constructor Detail

MetadataTools

public MetadataTools()
Method Detail

afterConfigurationChange

public void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
                                     String propertyName,
                                     Object propertyValue)
Specified by:
afterConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListener

beforeConfigurationChange

public void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
                                      String propertyName,
                                      Object propertyValue)
Specified by:
beforeConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListener

gatherSnapshotVersions

public Set<String> gatherSnapshotVersions(ManagedRepositoryContent managedRepository,
                                          VersionedReference reference)
                                   throws LayoutException,
                                          IOException,
                                          ContentNotFoundException
Gather the set of snapshot versions found in a particular versioned reference.

Returns:
the Set of snapshot artifact versions found.
Throws:
LayoutException
ContentNotFoundException
IOException

toVersionedReference

public VersionedReference toVersionedReference(String path)
                                        throws RepositoryMetadataException
Take a path to a maven-metadata.xml, and attempt to translate it to a VersionedReference.

Parameters:
path -
Returns:
Throws:
RepositoryMetadataException

hasNumberAnywhere

private boolean hasNumberAnywhere(String version)

toProjectReference

public ProjectReference toProjectReference(String path)
                                    throws RepositoryMetadataException
Throws:
RepositoryMetadataException

toPath

public String toPath(ProjectReference reference)

toPath

public String toPath(VersionedReference reference)

formatAsDirectory

private String formatAsDirectory(String directory)

getRepositorySpecificName

public String getRepositorySpecificName(RemoteRepositoryContent repository,
                                        String path)
Adjusts a path for a metadata.xml file to its repository specific path.

Parameters:
repository - the repository to base new path off of.
path - the path to the metadata.xml file to adjust the name of.
Returns:
the newly adjusted path reference to the repository specific metadata path.

getRepositorySpecificName

public String getRepositorySpecificName(String proxyId,
                                        String path)
Adjusts a path for a metadata.xml file to its repository specific path.

Parameters:
proxyId - the repository id to base new path off of.
path - the path to the metadata.xml file to adjust the name of.
Returns:
the newly adjusted path reference to the repository specific metadata path.

initialize

@PostConstruct
public void initialize()

readProxyMetadata

public ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository,
                                                   ProjectReference reference,
                                                   String proxyId)

readProxyMetadata

public ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository,
                                                   String logicalResource,
                                                   String proxyId)

readProxyMetadata

public ArchivaRepositoryMetadata readProxyMetadata(ManagedRepositoryContent managedRepository,
                                                   VersionedReference reference,
                                                   String proxyId)

updateMetadata

public void updateMetadata(ManagedRepositoryContent managedRepository,
                           String logicalResource)
                    throws RepositoryMetadataException
Throws:
RepositoryMetadataException

findPossibleVersions

private Set<String> findPossibleVersions(Set<String> versions,
                                         File metadataParentDirectory)
Skims the parent directory of a metadata in vain hope of finding subdirectories that contain poms.

Parameters:
metadataParentDirectory -
Returns:
origional set plus newley found versions

getMetadatasForManagedRepository

private List<ArchivaRepositoryMetadata> getMetadatasForManagedRepository(ManagedRepositoryContent managedRepository,
                                                                         String logicalResource)

updateMetadata

public void updateMetadata(ManagedRepositoryContent managedRepository,
                           ProjectReference reference)
                    throws LayoutException,
                           RepositoryMetadataException,
                           IOException,
                           ContentNotFoundException
Deprecated. 

Update the metadata to represent the all versions/plugins of the provided groupId:artifactId project or group reference, based off of information present in the repository, the maven-metadata.xml files, and the proxy/repository specific metadata file contents.

We must treat this as a group or a project metadata file as there is no way to know in advance

Parameters:
managedRepository - the managed repository where the metadata is kept.
reference - the reference to update.
Throws:
LayoutException
RepositoryMetadataException
IOException
ContentNotFoundException

updateMetadataVersions

private void updateMetadataVersions(Collection<String> allVersions,
                                    ArchivaRepositoryMetadata metadata)

toLastUpdatedDate

private Date toLastUpdatedDate(long lastUpdated)

toLastUpdatedLong

private long toLastUpdatedLong(String timestampString)

getLastUpdated

private long getLastUpdated(ArchivaRepositoryMetadata metadata)

getExistingLastUpdated

private long getExistingLastUpdated(File metadataFile)

updateMetadata

public void updateMetadata(ManagedRepositoryContent managedRepository,
                           VersionedReference reference)
                    throws LayoutException,
                           RepositoryMetadataException,
                           IOException,
                           ContentNotFoundException
Deprecated. 

Update the metadata based on the following rules.

1) If this is a SNAPSHOT reference, then utilize the proxy/repository specific metadata files to represent the current / latest SNAPSHOT available. 2) If this is a RELEASE reference, and the metadata file does not exist, then create the metadata file with contents required of the VersionedReference

Parameters:
managedRepository - the managed repository where the metadata is kept.
reference - the versioned reference to update
Throws:
LayoutException
RepositoryMetadataException
IOException
ContentNotFoundException

initConfigVariables

private void initConfigVariables()

getFirstArtifact

public ArtifactReference getFirstArtifact(ManagedRepositoryContent managedRepository,
                                          VersionedReference reference)
                                   throws LayoutException,
                                          IOException
Get the first Artifact found in the provided VersionedReference location.

Parameters:
managedRepository - the repository to search within.
reference - the reference to the versioned reference to search within
Returns:
the ArtifactReference to the first artifact located within the versioned reference. or null if no artifact was found within the versioned reference.
Throws:
IOException - if the versioned reference is invalid (example: doesn't exist, or isn't a directory)
LayoutException

getConfiguration

public ArchivaConfiguration getConfiguration()

setConfiguration

public void setConfiguration(ArchivaConfiguration configuration)

getFiletypes

public FileTypes getFiletypes()

setFiletypes

public void setFiletypes(FileTypes filetypes)


Copyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.