Return-Path: Delivered-To: apmail-archiva-dev-archive@www.apache.org Received: (qmail 34210 invoked from network); 17 Jun 2010 12:08:32 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Jun 2010 12:08:32 -0000 Received: (qmail 53286 invoked by uid 500); 17 Jun 2010 03:08:31 -0000 Delivered-To: apmail-archiva-dev-archive@archiva.apache.org Received: (qmail 53137 invoked by uid 500); 17 Jun 2010 03:08:29 -0000 Mailing-List: contact dev-help@archiva.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@archiva.apache.org Delivered-To: mailing list dev@archiva.apache.org Received: (qmail 53127 invoked by uid 99); 17 Jun 2010 03:08:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jun 2010 03:08:28 +0000 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=AWL,FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of odeaching@gmail.com designates 209.85.160.170 as permitted sender) Received: from [209.85.160.170] (HELO mail-gy0-f170.google.com) (209.85.160.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jun 2010 03:08:22 +0000 Received: by gyf2 with SMTP id 2so4686934gyf.15 for ; Wed, 16 Jun 2010 20:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=Wqd/mBDnGjk5FZiZrlzAJXE8waZw8aFH4+LBfnhHtp0=; b=mGBBkjTZBQSAaWNtSNN6OgvhY0JfxTpXqW9NjteUhwp6jq2YnUixEVC8EnZqxvVO/r Of0oEJVXpT2NUWXoz02QVSJ7/AzKppNYDvp2ARtVUMhW9a9ExlqxYiEtCXuKWgHSP8dA dBk3BhucJ2tKAw764bm4tEM2O+3d/aPa8+QeQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=WayrN3plcGUn8QOHEQttKPeWwSnLfqE+E+DyEK8pUCM8rwMBp7HoxtKeJN1jpiVy7r dLm3LFK3h0fcAtTBR/GAZoj0u3YjZaLfKOJ7UAexH3STtqbVu3xh3ohcsLR3kyiMmRZo O8r6BuFG7n1VzT40G+Syb1+pNGtuR2my0LKfY= MIME-Version: 1.0 Received: by 10.229.38.147 with SMTP id b19mr4411779qce.253.1276744081540; Wed, 16 Jun 2010 20:08:01 -0700 (PDT) Sender: odeaching@gmail.com Received: by 10.229.239.147 with HTTP; Wed, 16 Jun 2010 20:08:01 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 Jun 2010 11:08:01 +0800 X-Google-Sender-Auth: _SWUOWm9FEZcglLxy634XSTIpVo Message-ID: Subject: Re: SourceAritfacts class From: Deng Ching To: dev@archiva.apache.org Content-Type: multipart/alternative; boundary=0016363b8be87308b60489312538 --0016363b8be87308b60489312538 Content-Type: text/plain; charset=ISO-8859-1 Hi Eshan, Can you submit what you already have for the repository merging as a diff file in the Jira issue so it's easier to review? Please run svn diff from the root checkout directory so that the source path also gets included. Let's do it this way from now on :) Thanks, Deng On Wed, Jun 16, 2010 at 8:26 AM, Eshan Sudharaka wrote: > hi , > > i wrote a test case for the SourceArtifacts Class. > > 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.slf4j.Logger; > import org.slf4j.LoggerFactory; > //import org.apache.log4j.Logger; > import org.junit.Test; > > import junit.framework.TestCase; > import org.apache.archiva.metadata.repository.MetadataRepository; > import org.apache.archiva.metadata.repository.MetadataResolver; > import org.apache.archiva.web.xmlrpc.api.beans.Artifact; > import > org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; > import org.easymock.MockControl; > > import java.util.ArrayList; > import java.util.Collection; > import java.util.List; > > > public class SourceArtifactsTest > extends TestCase > { > > private Logger log = LoggerFactory.getLogger( SourceArtifactsTest.class > );; > > /** > * @plexus.requirement > */ > private SourceAritfacts sourceArtifacts ; > > private MockControl metadataResolverControl; > > private MetadataResolver metadataResolver ; > > private static final String TEST_REPO_ID = "internal"; > > SourceAritfacts sa; > > > @Override > protected void setUp() > throws Exception > { > super.setUp(); > sa = new SourceAritfacts(); > metadataResolverControl = > MockControl.createControl(MetadataResolver.class) ; > metadataResolver = > (MetadataResolver)metadataResolverControl.getMock(); > sa.setMetadataResolver(metadataResolver); > > ManagedRepositoryConfiguration repository = new > ManagedRepositoryConfiguration(); > repository.setId( TEST_REPO_ID ); > repository.setLocation( " " ); > } > > > @Test > public void test(){ > > metadataResolverControl.expectAndReturn( > sa.getSourceArtifactList(), > (ArrayList)getRootNameSpace() > ); > > metadataResolverControl.replay(); > metadataResolverControl.verify(); > } > > > private Collection getRootNameSpace() > { > List artifactList = new ArrayList(); > Artifact a = new Artifact(); > Artifact b = new Artifact(); > artifactList.add(a); > artifactList.add(b); > return artifactList; > } > } > > > but i got a null pointer exception while executing following line. > metadataResolverControl.expectAndReturn( > sa.getSourceArtifactList(), > (ArrayList)getRootNameSpace() > ); > > and surefire report pointed following. > > > > test(org.apache.archiva.stagerepository.merge.repodetails.SourceArtifactsTest) > Time elapsed: 0.065 sec <<< ERROR! > java.lang.NullPointerException > at > > org.apache.archiva.stagerepository.merge.repodetails.SourceAritfacts.process(SourceAritfacts.java:88) > > > > private void process() > { > //this will get the root name spaces eg : org, com > rootNameSpacesList = ( ArrayList ) > metadataResolver.getRootNamespaces( repoId ); > gruopIdList = new ArrayList() ; > artifactsList = new ArrayList() ; > > 87 //following iterates through the root name spaces list and get > the gruo id of relavet root name spaces. > 88 for( String namespace : rootNameSpacesList ) > { > > i think here exception throws since rootNameSpaceList is null.. > is > is it possible to inject that list or is there any other alternative to > solve this ? > > thanks. > > > On Mon, Jun 14, 2010 at 10:25 PM, Eshan Sudharaka >wrote: > > > yes. i got your point. previously i was confusing how to return that > > ArtifactMetaData list since we have a Artifact list . > > now i added a method which is returning ArtifactMetadata list for a > > particular artifact. > > > > so the caller first need to get the Artifact list and then pass those > > artifacts one by one to get the Artifactmetadata. > > > > http://jira.codehaus.org/secure/ManageAttachments.jspa?id=75406 > > > > thanks. > > > > On Mon, Jun 14, 2010 at 6:21 PM, Deng Ching wrote: > > > >> We're using ArtifactMetadata to abstract what type of artifact it is > >> (whether it is a maven artifact or simply a file in the repository).. > >> Also, > >> if you'll returning a list of Artifact objects from the SourceArtifact > >> > >> class then from those Artifact objects, you'll be querying for the > >> artifact > >> metadata again in the repository merge, won't it be redundant since in > the > >> first place you already have ArtifactMetadata objects in the > >> SourceArtifact > >> class but you returned a list of Artifact objects instead? > >> > >> Thanks, > >> Deng > >> > >> On Sun, Jun 13, 2010 at 12:21 PM, Eshan Sudharaka >> >wrote: > >> > >> > as i understood the purpose of the SourceArtifacts class is the return > a > >> > list of available artifacts to the caller. Once the caller receives > the > >> list > >> > i guess it is his responsibility to get the ArtifactMetaData using > >> > > >> > ** metadataRepository.getArtifacts( repoId, namespace, > projectId, > >> > projectVersion ); > >> > > >> > > >> > > >> > > >> > > >> > > >> > On Fri, Jun 11, 2010 at 9:28 PM, Eshan Sudharaka < > esudharaka@gmail.com > >> >wrote: > >> > > >> >> i have a problem regarding > >> >> Collection 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 rootNameSpacesList; > >> >>> > >> >>> private ArrayList gruopIdList; > >> >>> > >> >>> private ArrayList artifactsList; > >> >>> > >> >>> private ArrayList artifactsVersionsList; > >> >>> > >> >>> private List artifactsListWithDetails; > >> >>> > >> >>> private String repoId; > >> >>> > >> >>> private static final Logger log = LoggerFactory.getLogger( > >> >>> SourceAritfacts.class ); > >> >>> > >> >>> public List getSourceArtifactList(String repoId) > >> >>> { > >> >>> this.repoId = repoId; > >> >>> artifactsListWithDetails = new ArrayList(); > >> >>> process(); > >> >>> return artifactsListWithDetails; > >> >>> } > >> >>> > >> >>> > >> >>> private void process() > >> >>> { > >> >>> //this will get the root name spaces eg : org, com > >> >>> rootNameSpacesList = ( ArrayList ) > >> >>> metadataResolver.getRootNamespaces( repoId ); > >> >>> gruopIdList = new ArrayList() ; > >> >>> artifactsList = new ArrayList() ; > >> >>> > >> >>> //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)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)metadataResolver.getNamespaces( repoId,namespace > + > >> "." + > >> >>> gruopId ); > >> >>> > >> >>> for (String artifact : artifactsList) > >> >>> { > >> >>> //iterates through the artifacts and get the > >> >>> available versions of a particular artifact > >> >>> artifactsVersionsList = ( ArrayList > >> >>> )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 > >> >> > >> > > >> > > >> > > >> > -- > >> > 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 > > > > > > -- > P.A.Eshan Sudharaka > Dept of Computer Science and Engineering > University of Moratuwa > Sri Lanka > --0016363b8be87308b60489312538--