archiva-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eshan Sudharaka <esudhar...@gmail.com>
Subject Re: SourceAritfacts class
Date Fri, 11 Jun 2010 15:58:00 GMT
i have a problem regarding
  Collection<ArtifactMetadata> getArtifacts( String repoId, String
namespace, String projectId,  String projectVersion );
 method.

here parameters are unique to a particular artifact. so what are  the
things  that  returning list  contains ?

as i understood class ArtifactMetadata contains the details for a particular
artifact. So i am wondering how this method returns a list for the
parameters of a particular artifact ..


also the purpose of sourceArtifact class is to retrieve the list of
Artifacts in the target repo. i guess once we have Artifacts details
(gruopId, artifact id , version) we can check that artifact is available or
not using available archiva methods.(as deng menstioned for that task we
need only artifacts coordinates) So i am still confusing why we need a list
of  ArtifactMetadata instead of a list of Artifacts.

may be inorder to update archiva meta data model this  ArtifactMetadata list
will be usefull.

On Fri, Jun 11, 2010 at 8:33 PM, Eshan Sudharaka <esudharaka@gmail.com>wrote:

> package org.apache.archiva.stagerepository.merge.repodetails;
>
> /*
>  * 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.metadata.repository.DefaultMetadataResolver;
> import org.apache.archiva.metadata.repository.MetadataRepository;
> import org.apache.archiva.metadata.repository.MetadataResolver;
> import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
> import java.util.List;
> import java.util.Collection;
> import java.util.ArrayList;
> import java.util.Iterator;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> /**
>  * @plexus.component role="org.apache.archiva.repodetails.SourceAritfacts"
>  */
>
> public class SourceAritfacts
> {
>
>     /**
>      * @plexus.requirement
>      */
>     private MetadataResolver metadataResolver;
>
>     private ArrayList<String> rootNameSpacesList;
>
>     private ArrayList<String> gruopIdList;
>
>     private ArrayList<String> artifactsList;
>
>     private ArrayList<String> artifactsVersionsList;
>
>     private List<Artifact>  artifactsListWithDetails;
>
>     private String repoId;
>
>     private static final Logger log = LoggerFactory.getLogger(
> SourceAritfacts.class );
>
>     public List<Artifact> getSourceArtifactList(String repoId)
>     {
>         this.repoId = repoId;
>         artifactsListWithDetails = new ArrayList<Artifact>();
>         process();
>         return artifactsListWithDetails;
>     }
>
>
>     private void process()
>     {
>         //this will get the root name spaces eg : org, com
>         rootNameSpacesList = ( ArrayList<String> )
> metadataResolver.getRootNamespaces( repoId );
>         gruopIdList = new ArrayList<String>() ;
>         artifactsList = new ArrayList<String>() ;
>
>         //following iterates through the  root name spaces list and get the
> gruo id of relavet root name spaces.
>         for( String namespace : rootNameSpacesList )
>         {
>             //this will get the gruop id list of relavant name space . eg :
> org > archiva(gruop id)
>             gruopIdList =
> (ArrayList<String>)metadataResolver.getNamespaces( repoId , namespace );
>
>             // following will iterates through the particular gruop id 's
>             for (String gruopId : gruopIdList )
>             {
>                 // parse the parameters "repoId" and "namespace + gruop id
> "to  artifacts list. eg : params = ("internal" , "org.archiva")
>                 artifactsList =
> (ArrayList<String>)metadataResolver.getNamespaces( repoId,namespace + "." +
> gruopId );
>
>                 for (String artifact : artifactsList)
>                 {
>                     //iterates through the artifacts and get the available
> versions of a particular artifact
>                     artifactsVersionsList = ( ArrayList <String>
> )metadataResolver.getProjectVersions( repoId , namespace + "." + gruopId ,
> artifact );
>                     Artifact artifactWithDetails = new Artifact();
>
>                     for (String version : artifactsVersionsList)
>                     {
>                         //assign gathered attributes Artifact object and
> add it in to the list
>                         artifactWithDetails.setVersion(version);
>                         artifactWithDetails.setArtifactId(artifact);
>                         artifactWithDetails.setGroupId(gruopId);
>                         artifactWithDetails.setRepositoryId(repoId);
>                         artifactsListWithDetails.add(artifactWithDetails);
>
>                     }
>                 }
>             }
>         }
>
>
>     }
> }
>
>
>
>
> --
> P.A.Eshan Sudharaka
> Dept of Computer Science and Engineering
> University of Moratuwa
> Sri Lanka
>



-- 
P.A.Eshan Sudharaka
Dept of Computer Science and Engineering
University of Moratuwa
Sri Lanka

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message