Sync with 2431

git-svn-id: svn://10.0.0.236/trunk@216268 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ghendricks%novell.com
2006-12-01 18:06:58 +00:00
parent 175ea305f7
commit ab3a43f6a6
43 changed files with 827 additions and 228 deletions

View File

@@ -31,13 +31,13 @@ sub lookup_name_by_id
die "Invalid Build ID"
unless defined $build_id && length($build_id) > 0 && $build_id > 0;
Bugzilla->login;
$self->login;
my $build = new Bugzilla::Testopia::Build($build_id);
my $result = defined $build ? $build->name : '';
Bugzilla->logout;
$self->logout;
# Result is build name string or empty string if failed
return $result;
@@ -48,11 +48,11 @@ sub lookup_id_by_name
my $self = shift;
my ($name) = @_;
Bugzilla->login;
$self->login;
my $result = Bugzilla::Testopia::Build->check_build_by_name($name);
Bugzilla->logout;
$self->logout;
if (!defined $result)
{

View File

@@ -0,0 +1,83 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Dallas Harken <dharken@novell.com>
package Bugzilla::WebService::Testopia::Product;
use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Testopia::Product;
sub lookup_name_by_id
{
my $self = shift;
my ($product_id) = @_;
die "Invalid Product ID"
unless defined $product_id && length($product_id) > 0 && $product_id > 0;
$self->login;
my $product = new Bugzilla::Testopia::Product($product_id);
my $result = defined $product ? $product->name : '';
$self->logout;
# Result is product name string or empty string if failed
return $result;
}
sub lookup_id_by_name
{
my $self = shift;
my ($name) = @_;
$self->login;
my $result = Bugzilla::Testopia::Product->check_product_by_name($name);
$self->logout;
if (!defined $result)
{
$result = 0;
}
# Result is product id or 0 if failed
return $result;
}
#sub get_product
#{
# my $self = shift;
# my ($product_id) = @_;
#
# Bugzilla->login;
#
# # We can detaint immediately if what we get passed is fully numeric.
# # We leave bug alias checks to Bugzilla::Testopia::TestPlan::new.
#
# if ($product_id =~ /^[0-9]+$/) {
# detaint_natural($product_id);
# }
#
# return new Bugzilla::Product($product_id);
#}
1;

View File

@@ -21,64 +21,12 @@ use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Util qw(detaint_natural);
use Bugzilla::Product;
use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::Testopia::TestPlan;
use Bugzilla::Testopia::Search;
use Bugzilla::Testopia::Table;
# Convert string field values to their respective integer id's
sub _convert_to_ids
{
my ($hash) = @_;
if (defined($$hash{"author"}))
{
$$hash{"author_id"} = login_to_id($$hash{"author"});
}
delete $$hash{"author"};
if (defined($$hash{"product"}))
{
my $product = Bugzilla::Product::check_product($$hash{"product"});
$$hash{"product_id"} = $product->id;
}
delete $$hash{"product"};
if (defined($$hash{"type"}))
{
$$hash{"type_id"} = Bugzilla::Testopia::TestPlan::lookup_type_by_name($$hash{"type"});
}
delete $$hash{"type"};
}
# Convert fields with integer id's to their respective string values
sub _convert_to_strings
{
my ($hash) = @_;
$$hash{"author"} = "";
if (defined($$hash{"author_id"}))
{
$$hash{"author"} = new Bugzilla::User($$hash{"author_id"})->login;
}
delete $$hash{"author_id"};
$$hash{"product"} = "";
if (defined($$hash{"product_id"}))
{
$$hash{"product"} = new Bugzilla::Product($$hash{"product_id"})->name;
}
delete $$hash{"product_id"};
$$hash{"type"} = "";
if (defined($$hash{"type_id"}))
{
$$hash{"type"} = Bugzilla::Testopia::TestPlan->lookup_type($$hash{"type_id"});
}
delete $$hash{"type_id"};
}
# Utility method called by the list method
sub _list
{
@@ -86,8 +34,6 @@ sub _list
my $cgi = Bugzilla->cgi;
$cgi->param("viewall", 1);
$cgi->param("current_tab", "plan");
foreach (keys(%$query))
@@ -111,42 +57,38 @@ sub get
my $self = shift;
my ($test_plan_id) = @_;
Bugzilla->login;
# We can detaint immediately if what we get passed is fully numeric.
# We leave bug alias checks to Bugzilla::Testopia::TestPlan::new.
if ($test_plan_id =~ /^[0-9]+$/) {
detaint_natural($test_plan_id);
}
$self->login;
#Result is a test plan hash map
my $testplan = new Bugzilla::Testopia::TestPlan($test_plan_id);
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
_convert_to_strings($testplan);
Bugzilla->logout;
return $testplan;
$self->logout;
return $test_plan;
}
sub list
{
Bugzilla->login;
my $self = shift;
my ($query) = @_;
_convert_to_ids($query);
$self->login;
my $list = _list($query);
foreach (@$list)
{
_convert_to_strings($_);
}
Bugzilla->logout;
$self->logout;
return $list;
}
@@ -156,16 +98,16 @@ sub create
my $self =shift;
my ($new_values) = @_;
Bugzilla->login;
$self->login;
_convert_to_ids($new_values);
my $test_plan = new Bugzilla::Testopia::TestPlan($new_values);
Bugzilla->logout;
my $result = $test_plan->store();
$self->logout;
# Result is new test plan id
return $test_plan->store();
return $result;
}
sub update
@@ -173,18 +115,154 @@ sub update
my $self =shift;
my ($test_plan_id, $new_values) = @_;
Bugzilla->login;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canedit)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->update($new_values);
$self->logout;
_convert_to_ids($new_values);
$test_plan->update($new_values);
Bugzilla->logout;
# Result is zero on success, otherwise an exception will be thrown
return 0;
return $test_plan;
}
sub get_test_cases
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_cases();
$self->logout;
# Result is list of test cases for the given test plan
return $result;
}
sub get_test_runs
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_runs();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub get_categories
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->product->categories();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub lookup_type_name_by_id
{
my $self =shift;
my ($id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type($id);
$self->logout;
# Result is test plan type name for the given test plan type id
return $result;
}
sub lookup_type_id_by_name
{
my $self =shift;
my ($name) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type_by_name($name);
$self->logout;
if (!defined $result)
{
$result = 0;
};
# Result is test plan type id for the given test plan type name
return $result;
}
1;