public static String toKey( ArtifactReference ref ) { StringBuffer key = new StringBuffer(); key.append( ref.getGroupId() ).append( ":" ); key.append( ref.getArtifactId() ).append( ":" ); key.append( ref.getVersion() ).append( ":" ); key.append( StringUtils.defaultString( ref.getClassifier() ) ).append( ":" ); key.append( ref.getType() ); return key.toString(); } }
public void finishGraph( DependencyGraph graph ) { super.finishGraph( graph ); for ( ArtifactReference ref : this.nodeVersionChanges.keySet() ) { String toVersion = this.nodeVersionChanges.get( ref ); collapseVersions( graph, ref, ref.getVersion(), toVersion ); } }
public static String toKey( ArtifactReference artifactReference ) { StringBuffer key = new StringBuffer(); key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" ); key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" ); key.append( defaultString( artifactReference.getVersion() ) ).append( ":" ); key.append( defaultString( artifactReference.getClassifier() ) ).append( ":" ); key.append( defaultString( artifactReference.getType() ) ); return key.toString(); }
public String toPath( ArtifactReference reference ) { if ( reference == null ) { throw new IllegalArgumentException( "Artifact reference cannot be null" ); } String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() ); return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(), reference.getClassifier(), reference.getType() ); }
private void getRelatedArtifacts( File typeDir, ArtifactReference reference, Set<ArtifactReference> foundArtifacts ) { for ( File repoFile : typeDir.listFiles() ) { if ( repoFile.isDirectory() ) { // Skip it. it's a directory. continue; } String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); if ( filetypes.matchesArtifactPattern( relativePath ) ) { try { ArtifactReference artifact = toArtifactReference( relativePath ); if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) && artifact.getVersion().startsWith( reference.getVersion() ) ) { foundArtifacts.add( artifact ); } } catch ( LayoutException e ) { /* don't fail the process if there is a bad artifact within the directory. */ } } } }
private void getVersionedVersions( File typeDir, VersionedReference reference, Set<String> foundVersions ) { for ( File repoFile : typeDir.listFiles() ) { if ( repoFile.isDirectory() ) { // Skip it. it's a directory. continue; } String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); if ( filetypes.matchesArtifactPattern( relativePath ) ) { try { ArtifactReference artifact = toArtifactReference( relativePath ); if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) && artifact.getVersion().startsWith( reference.getVersion() ) ) { foundVersions.add( artifact.getVersion() ); } } catch ( LayoutException e ) { /* don't fail the process if there is a bad artifact within the directory. */ } } } }
artifact.getVersion().equals( reference.getVersion() ) )
public String toPath( ArtifactReference reference ) { if ( reference == null ) { throw new IllegalArgumentException( "Artifact reference cannot be null" ); } return toPath( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), reference.getClassifier(), reference.getType() ); }
private void getProjectVersions( File typeDir, ProjectReference reference, Set<String> foundVersions ) { File repoFiles[] = typeDir.listFiles(); for ( File repoFile : repoFiles ) { if ( repoFile.isDirectory() ) { // Skip it. it's a directory. continue; } String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); if ( filetypes.matchesArtifactPattern( relativePath ) ) { try { ArtifactReference artifact = toArtifactReference( relativePath ); if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) ) { foundVersions.add( artifact.getVersion() ); } } catch ( LayoutException e ) { /* don't fail the process if there is a bad artifact within the directory. */ } } } }
public ArchivaArtifact( ArtifactReference ref ) { this( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref.getClassifier(), ref.getType() ); }
private void deleteVersions( File typeDir, VersionedReference reference ) { File repoFiles[] = typeDir.listFiles(); for ( File repoFile : repoFiles ) { if ( repoFile.isDirectory() ) { // Skip it. it's a directory. continue; } String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); if ( filetypes.matchesArtifactPattern( relativePath ) ) { try { ArtifactReference artifact = toArtifactReference( relativePath ); if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) && StringUtils.equals( artifact.getVersion(), reference.getVersion() ) ) { repoFile.delete(); deleteSupportFiles( repoFile ); } } catch ( LayoutException e ) { /* don't fail the process if there is a bad artifact within the directory. */ } } } }
String specifiedVersion = rules.artifact.getVersion(); String nodeVersion = subnode.getArtifact().getVersion();
public static String toKey( ArtifactReference ref ) { return toKey( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref.getClassifier(), ref.getType() ); }
private ArchivaProjectModel createDefaultModel( ArtifactReference reference ) { ArchivaProjectModel model = new ArchivaProjectModel(); // Create default (dummy) model model = new ArchivaProjectModel(); model.setGroupId( reference.getGroupId() ); model.setArtifactId( reference.getArtifactId() ); model.setVersion( reference.getVersion() ); model.setPackaging( reference.getType() ); return model; } }
private VersionedReference toVersionedReference( DependencyGraphNode node ) { VersionedReference ref = new VersionedReference(); ref.setGroupId( node.getArtifact().getGroupId() ); ref.setArtifactId( node.getArtifact().getArtifactId() ); ref.setVersion( node.getArtifact().getVersion() ); return ref; }
public static ArtifactReference clone( ArtifactReference artifactReference ) { if ( artifactReference == null ) { return null; } ArtifactReference cloned = new ArtifactReference(); cloned.setGroupId( artifactReference.getGroupId() ); cloned.setArtifactId( artifactReference.getArtifactId() ); cloned.setVersion( artifactReference.getVersion() ); cloned.setClassifier( artifactReference.getClassifier() ); cloned.setType( artifactReference.getType() ); return cloned; }
/** * Get a Live Artifact from a Path. * <p/> * Will resolve the artifact details from the path, and then return a database live version * of that artifact. Suitable for modification and saving (without the need to check for * existance in database prior to save.) * * @param path the path to work from. * @return the artifact that is suitable for database saving. */ public ArchivaArtifact getLiveArtifact( String path ) { try { ArtifactReference artifact = repository.toArtifactReference( path ); ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), artifact.getType() ); return liveArtifact; } catch ( LayoutException e ) { triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: " + e.getMessage() ); return null; } }
/** * Get a Live Artifact from a Path. * <p/> * Will resolve the artifact details from the path, and then return a database live version * of that artifact. Suitable for modification and saving (without the need to check for * existance in database prior to save.) * * @param path the path to work from. * @return the artifact that is suitable for database saving. */ public ArchivaArtifact getLiveArtifact( String path ) { try { ArtifactReference artifact = repository.toArtifactReference( path ); ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), artifact.getType(), repository.getId()); return liveArtifact; } catch ( LayoutException e ) { triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: " + e.getMessage() ); return null; } }
private ArchivaProjectModel resolveModel( ArtifactReference reference ) { VersionedReference projectRef = new VersionedReference(); projectRef.setGroupId( reference.getGroupId() ); projectRef.setArtifactId( reference.getArtifactId() ); projectRef.setVersion( reference.getVersion() ); ArchivaProjectModel model = resolverFactory.getCurrentResolverStack().findProject( projectRef ); if ( model == null ) { return createDefaultModel( reference ); } try { ArchivaProjectModel processedModel = effectiveFilter.filter( model ); return processedModel; } catch ( ProjectModelException e ) { e.printStackTrace( System.err ); return createDefaultModel( reference ); } }
public void processFile( String path ) throws ConsumerException { try { ArtifactReference reference = managedRepository.toArtifactReference( path ); Artifact artifact = artifactFactory.createArtifact( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), reference.getClassifier(), reference.getType() ); artifactConverter.convert( artifact, destinationRepository ); } catch ( LayoutException e ) { getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e ); } catch ( ArtifactConversionException e ) { getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e ); } }