mirror of https://github.com/apache/archiva.git
use a better exception mechanism for that
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1387387 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
65768e8719
commit
5a3bf2a3af
|
@ -27,8 +27,8 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
|
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
|
||||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||||
import org.apache.archiva.metadata.repository.MetadataRepository;
|
import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||||
|
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
|
||||||
import org.apache.archiva.metadata.repository.filter.Filter;
|
import org.apache.archiva.metadata.repository.filter.Filter;
|
||||||
import org.apache.archiva.metadata.repository.filter.IncludesFilter;
|
|
||||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||||
import org.apache.archiva.model.ArchivaRepositoryMetadata;
|
import org.apache.archiva.model.ArchivaRepositoryMetadata;
|
||||||
import org.apache.archiva.repository.RepositoryException;
|
import org.apache.archiva.repository.RepositoryException;
|
||||||
|
@ -93,9 +93,11 @@ public class Maven2RepositoryMerger
|
||||||
}
|
}
|
||||||
|
|
||||||
public void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId )
|
public void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId )
|
||||||
throws Exception
|
throws RepositoryMergerException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
List<ArtifactMetadata> artifactsInSourceRepo = metadataRepository.getArtifacts( sourceRepoId );
|
List<ArtifactMetadata> artifactsInSourceRepo = metadataRepository.getArtifacts( sourceRepoId );
|
||||||
for ( ArtifactMetadata artifactMetadata : artifactsInSourceRepo )
|
for ( ArtifactMetadata artifactMetadata : artifactsInSourceRepo )
|
||||||
{
|
{
|
||||||
|
@ -103,11 +105,26 @@ public class Maven2RepositoryMerger
|
||||||
createFolderStructure( sourceRepoId, targetRepoId, artifactMetadata );
|
createFolderStructure( sourceRepoId, targetRepoId, artifactMetadata );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch ( MetadataRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( RepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO when UI needs a subset to merge
|
// TODO when UI needs a subset to merge
|
||||||
public void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId,
|
public void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId,
|
||||||
Filter<ArtifactMetadata> filter )
|
Filter<ArtifactMetadata> filter )
|
||||||
throws Exception
|
throws RepositoryMergerException
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
|
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
|
||||||
for ( ArtifactMetadata metadata : sourceArtifacts )
|
for ( ArtifactMetadata metadata : sourceArtifacts )
|
||||||
|
@ -118,6 +135,19 @@ public class Maven2RepositoryMerger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch ( MetadataRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( RepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void createFolderStructure( String sourceRepoId, String targetRepoId, ArtifactMetadata artifactMetadata )
|
private void createFolderStructure( String sourceRepoId, String targetRepoId, ArtifactMetadata artifactMetadata )
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
|
@ -352,7 +382,9 @@ public class Maven2RepositoryMerger
|
||||||
|
|
||||||
public List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
public List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
||||||
String targetRepo )
|
String targetRepo )
|
||||||
throws Exception
|
throws RepositoryMergerException
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<ArtifactMetadata> targetArtifacts = metadataRepository.getArtifacts( targetRepo );
|
List<ArtifactMetadata> targetArtifacts = metadataRepository.getArtifacts( targetRepo );
|
||||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepo );
|
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepo );
|
||||||
|
@ -373,10 +405,14 @@ public class Maven2RepositoryMerger
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceArtifacts.removeAll( conflictsArtifacts );
|
sourceArtifacts.removeAll( conflictsArtifacts );
|
||||||
Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
|
||||||
// merge( sourceRepo, targetRepo, artifactsWithOutConflicts );
|
|
||||||
return conflictsArtifacts;
|
return conflictsArtifacts;
|
||||||
}
|
}
|
||||||
|
catch ( MetadataRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RepositoryMergerException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isEquals( ArtifactMetadata sourceArtifact, ArtifactMetadata targetArtifact )
|
private boolean isEquals( ArtifactMetadata sourceArtifact, ArtifactMetadata targetArtifact )
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,13 +28,13 @@ import java.util.List;
|
||||||
public interface RepositoryMerger
|
public interface RepositoryMerger
|
||||||
{
|
{
|
||||||
void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId )
|
void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId )
|
||||||
throws Exception;
|
throws RepositoryMergerException;
|
||||||
|
|
||||||
void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId,
|
void merge( MetadataRepository metadataRepository, String sourceRepoId, String targetRepoId,
|
||||||
Filter<ArtifactMetadata> filter )
|
Filter<ArtifactMetadata> filter )
|
||||||
throws Exception;
|
throws RepositoryMergerException;
|
||||||
|
|
||||||
List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
||||||
String targetRepo )
|
String targetRepo )
|
||||||
throws Exception;
|
throws RepositoryMergerException;
|
||||||
}
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.archiva.stagerepository.merge;
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Olivier Lamy
|
||||||
|
* @since 1.4-M3
|
||||||
|
*/
|
||||||
|
public class RepositoryMergerException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
public RepositoryMergerException( String msg, Exception e )
|
||||||
|
{
|
||||||
|
super( msg, e );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue