getRepositoryInfo(Url,url::ViewOption) added
authorJan Kupec <jkupec@suse.cz>
Wed, 18 Jul 2007 08:49:19 +0000 (08:49 +0000)
committerJan Kupec <jkupec@suse.cz>
Wed, 18 Jul 2007 08:49:19 +0000 (08:49 +0000)
zypp/RepoManager.cc
zypp/RepoManager.h

index 265e15e..96cae81 100644 (file)
@@ -911,6 +911,31 @@ namespace zypp
 
   ////////////////////////////////////////////////////////////////////////////
 
+  RepoInfo RepoManager::getRepositoryInfo( const Url & url,
+                                           const url::ViewOption & urlview,
+                                           const ProgressData::ReceiverFnc & progressrcv )
+  {
+    std::list<RepoInfo> repos = knownRepositories();
+    for ( std::list<RepoInfo>::const_iterator it = repos.begin();
+          it != repos.end();
+          ++it )
+    {
+      for(RepoInfo::urls_const_iterator urlit = (*it).baseUrlsBegin();
+          urlit != (*it).baseUrlsEnd();
+          ++urlit)
+      {
+        if ((*urlit).asString(urlview) == url.asString(urlview))
+          return *it;
+      }
+    }
+    RepoInfo info;
+    info.setAlias(info.alias());
+    info.setBaseUrl(url);
+    ZYPP_THROW(RepoNotFoundException(info));
+  }
+
+  ////////////////////////////////////////////////////////////////////////////
+
   std::ostream & operator<<( std::ostream & str, const RepoManager & obj )
   {
     return str << *obj._pimpl;
index 250e74d..7b27f5c 100644 (file)
@@ -90,7 +90,7 @@ namespace zypp
     {
       
     };
-    
+
    /**
     * \short List known repositories.
     *
@@ -257,6 +257,28 @@ namespace zypp
     RepoInfo getRepositoryInfo( const std::string &alias,
                                 const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
     
+    /**
+     * \short Find repository info by URL.
+     *
+     * \param url URL to find.
+     * \param urlview url::ViewOption to influence URL matching.
+     * \param progressrcv Progress receiver function.
+     *
+     * \note if multple repositories incorrectly share the
+     * same URL, the first one found will be returned.
+     *
+     * \note the string representation of the URLs are compared.
+     *       The \a urlview can be used to influence which
+             parts of the URL are to be compared.
+     *
+     * \throws RepoNotFoundException If no repo match
+     * \throws ParseException If the file parsing fails
+     * \throws Exception On other errors.
+     */
+    RepoInfo getRepositoryInfo( const Url & url,
+                                const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
+                                const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+
   protected:
     RepoStatus rawMetadataStatus( const RepoInfo &info );
     RepoStatus cacheStatus( const RepoInfo &info );