Skip to content

Commit

Permalink
[backend] allow to limit product views to a given product
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Feb 10, 2014
1 parent c781332 commit 050a337
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/api/api/api.txt
Expand Up @@ -452,13 +452,15 @@ Parameters:
meta: bool, switch to meta files, optional
view: The "info" view will show data like source version, md5sums and build description files. May be used together with parse, arch or repository parameter, optional
"issues" can be used to show all tracked issues for all packages in project, optional
"products" show all products of a package (works only on "_product" packages)
extension: filter for file extension, optional
lastworking: bool, show sources of last mergeable sources in case of conflicting changes, optional
withlinked: bool, show all used package containers (in case of multiple link indirections) in linkinfo information, optional
deleted: bool, show content of deleted package instance
parse: bool, for view=info: take build description into account, optional
arch: string, for view=info: parse buildinfo for this architecture, optinal
repository: string, for view=info: parse buildinfo for this repository, optinal
product: string, limit the product view to a given product

XmlResult: package directory.xsd

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/source_controller.rb
Expand Up @@ -255,7 +255,7 @@ def show_package

# exec
path = request.path
path << build_query_from_hash(params, [:rev, :linkrev, :emptylink, :expand, :view, :extension, :lastworking, :withlinked, :meta, :deleted, :parse, :arch, :repository])
path << build_query_from_hash(params, [:rev, :linkrev, :emptylink, :expand, :view, :extension, :lastworking, :withlinked, :meta, :deleted, :parse, :arch, :repository, :product])
pass_to_backend path
end

Expand Down
9 changes: 8 additions & 1 deletion src/api/test/functional/product_test.rb
Expand Up @@ -31,7 +31,14 @@ def test_simple_product_file
assert_xml_tag :tag => "kind", :content => "product"
get "/source/home:tom:temporary/_product?view=products"
assert_response :success
assert_xml_tag :tag => "product", :attributes => { :id => 'simple' }
assert_xml_tag :parent => { :tag => "product", :attributes => { :id => 'simple' } },
:tag => "name", :content => "simple"
get "/source/home:tom:temporary/_product?view=products&product=simple"
assert_response :success
assert_xml_tag :tag => "name", :content => "simple"
get "/source/home:tom:temporary/_product?view=products&product=DOES_NOT_EXIST"
assert_response :success
assert_no_xml_tag :tag => "name", :content => "simple"
product = Package.find_by_project_and_name("home:tom:temporary","_product").products.first
assert_equal "simple", product.name
assert_equal "cpe:/a:OBS_Fuzzies:simple:11.2", product.cpe
Expand Down
10 changes: 4 additions & 6 deletions src/backend/bs_srcserver
Expand Up @@ -4628,12 +4628,10 @@ sub getfilelist {
my @res;
for my $filename (sort keys %$files) {
next unless $filename =~ /.product$/;
next if $cgi->{'product'} and $filename ne "$cgi->{'product'}.product";
my $xml = BSProductXML::readproductxml( "$srcrep/$rev->{'package'}/$files->{$filename}-$filename", 0, undef, $files);
if( defined($xml) ) {
push @res, $xml;
} else {
die("400 Unable to parse $filename: \n");
}
die("400 Unable to parse $filename: \n") unless defined($xml);
push @res, $xml;
}
my $ret = {};
$ret->{'productdefinition'} = \@res;
Expand Down Expand Up @@ -7838,7 +7836,7 @@ my $dispatches = [
'PUT:/source/$project/$package cmd: rev? user:? comment:?' => \&sourcecommitfilelist, # obsolete

'/source/$project/$package view=info rev? linkrev? parse:bool? nofilename:bool? repository? arch? withchangesmd5:bool?' => \&getpackagesourceinfo,
'/source/$project/$package rev? linkrev? emptylink:bool? deleted:bool? expand:bool? view:? extension:? lastworking:bool? withlinked:bool? meta:bool?' => \&getfilelist,
'/source/$project/$package rev? linkrev? emptylink:bool? deleted:bool? expand:bool? view:? extension:? lastworking:bool? withlinked:bool? meta:bool? product:?' => \&getfilelist,
'/source/$project/$package/_history rev? meta:bool? deleted:bool? limit:num?' => \&getpackagehistory,
'/source/$project/$package/_meta rev? expand:bool? meta:bool? deleted:bool?' => \&getpackage,
'PUT:/source/$project/$package/_meta user:? comment:? requestid:num?' => \&putpackage,
Expand Down

0 comments on commit 050a337

Please sign in to comment.