package org.apache.archiva.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.configuration.RepositoryGroupConfiguration; import org.apache.archiva.event.EventSource; import org.apache.archiva.indexer.ArchivaIndexManager; import org.apache.archiva.indexer.IndexUpdateFailedException; import org.apache.archiva.repository.metadata.MetadataReader; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.archiva.repository.validation.CheckedResult; import org.apache.archiva.repository.validation.ValidationError; import org.apache.archiva.repository.validation.ValidationResponse; import java.util.Collection; import java.util.List; import java.util.Map; /** * Registry for repositories. This is the central entry point for repositories. It provides methods for * retrieving, adding and removing repositories. *
* The modification methods putXX and removeXX without configuration object persist the changes immediately to the archiva configuration. If the * configuration save fails the changes are rolled back. *
** The modification methods with configuration object do only update the given configuration. The configuration is not saved. *
* @author Martin Stockhammernull
if no repository with this ID is registered.
*/
Repository getRepository( String repoId );
/**
* Returns the managed repository with the given id
* @param repoId the id of the repository
* @return the managed repository instance or null
, if no managed repository with this ID is registered.
*/
ManagedRepository getManagedRepository( String repoId );
/**
* Returns the remote repository with the given id
* @param repoId the id of the repository
* @return the remote repository instance or null
, if no remote repository with this ID is registered.
*/
RemoteRepository getRemoteRepository( String repoId );
/**
* Returns the repository group with the given id
* @param groupId the id of the repository group
* @return the repository group instance or null
, if no repository group with this ID is registered.
*/
RepositoryGroup getRepositoryGroup( String groupId );
/**
* Returns true
, if a repository with the given ID is registered, otherwise false
* @param repoId the ID of the repository
* @return true
, if a repository with the given ID is registered, otherwise false
*/
boolean hasRepository(String repoId);
/**
* Returns true
, if a managed repository with the given ID is registered, otherwise false
* @param repoId the id of the managed repository
* @return true
, if a managed repository with the given ID is registered, otherwise false
*/
boolean hasManagedRepository(String repoId);
/**
* Returns true
, if a remote repository with the given ID is registered, otherwise false
* @param repoId the id of the remote repository
* @return true
, if a remote repository with the given ID is registered, otherwise false
*/
boolean hasRemoteRepository(String repoId);
/**
* Returns true
, if a repository group with the given ID is registered, otherwise false
* @param groupId the id of the repository group
* @return true
, if a repository group with the given ID is registered, otherwise false
*/
boolean hasRepositoryGroup( String groupId );
/**
* Adds or updates the given managed repository. If a managed repository with the given id exists already, it is updated
* from the data of the given instance. Otherwise a new repository is created and updated by the data of the given instance.
*
* The archiva configuration is updated and saved after updating the registered repository instance.
*
* @param managedRepository the managed repository
* @return the repository instance, that was created or updated
* @throws RepositoryException if an error occurred while creating or updating the instance
*/
ManagedRepository putRepository( ManagedRepository managedRepository ) throws RepositoryException;
/**
* Adds or updates the given managed repository. If a managed repository with the given id exists already, it is updated
* from the data of the given configuration. Otherwise a new repository is created and updated by the data of the given configuration.
*
* The archiva configuration is updated and saved after updating the registered repository instance.
*
* @param managedRepositoryConfiguration the managed repository configuration
* @return the repository instance, that was created or updated
* @throws RepositoryException if an error occurred while creating or updating the instance
*/
ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration ) throws RepositoryException;
/**
* Adds or updates the given managed repository. If a managed repository with the given id exists already, it is updated
* from the data of the given configuration. Otherwise a new repository is created and updated by the data of the given configuration.
*
* This method can be used, if the archiva configuration should not be saved. It will only update the given configuration object.
*
* @param managedRepositoryConfiguration the managed repository configuration
* @param configuration the archiva configuration that is updated
* @return the repository instance, that was created or updated
* @throws RepositoryException if an error occurred while creating or updating the instance
*/
ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration ) throws RepositoryException;
/**
* Adds or updates the given repository group. If a repository group with the given id exists already, it is updated
* from the data of the given instance. Otherwise a new repository is created and updated by the data of the given instance.
*
* The archiva configuration is updated and saved after updating the registered repository instance.
*
* @param repositoryGroup the repository group
* @return the repository instance, that was created or updated
* @throws RepositoryException if an error occurred while creating or updating the instance
*/
RepositoryGroup putRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException;
/**
* Adds or updates the given repository group. If a repository group with the given id exists already, it is updated
* from the data of the given configuration. Otherwise a new repository is created and updated by the data of the given configuration.
*
* The archiva configuration is updated and saved after updating the registered repository instance.
*
* @param repositoryGroupConfiguration the repository group configuration
* @return the repository instance, that was created or updated
* @throws RepositoryException if an error occurred while creating or updating the instance
*/
RepositoryGroup putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration ) throws RepositoryException;
/**
* This method creates or updates a repository by the given configuration. It uses the validator
to check the
* result. If the validation is not successful, the repository will not be saved.
*
* @param configuration the repository configuration
* @return the result
*/
CheckedResultnull
if no matching repository is found
*/
Repository getRepositoryOfAsset( StorageAsset asset );
/**
* Validates the set attributes of the given repository instance and returns the validation result.
* The repository registry uses all available validators and applies their validateRepository method to the given
* repository. Validation results will be merged per field.
*
* @param repository the repository to validate against
* @return the result of the validation.
*/