Skip to content

Commit

Permalink
SOAP API: added new SOAP API methods
Browse files Browse the repository at this point in the history
mc_filter_search_issue_ids() - returns the array of issue ids.
mc_issues_get() - given an integer array returns array of issue data.
mc_issues_get_header() - given an integer array returns array of issue header data.

Fixes #8657

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
  • Loading branch information
Matej Habrnal committed Jan 24, 2015
1 parent 46daf17 commit 10f2b97
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 0 deletions.
50 changes: 50 additions & 0 deletions api/soap/mantisconnect.wsdl
Expand Up @@ -510,6 +510,18 @@
<part name="issue_id" type="xsd:integer" /></message>
<message name="mc_issue_getResponse">
<part name="return" type="tns:IssueData" /></message>
<message name="mc_issues_getRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="issue_ids" type="tns:IntegerArray" /></message>
<message name="mc_issues_getResponse">
<part name="return" type="tns:IssueDataArray" /></message>
<message name="mc_issues_get_headerRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="issue_ids" type="tns:IntegerArray" /></message>
<message name="mc_issues_get_headerResponse">
<part name="return" type="tns:IssueHeaderDataArray" /></message>
<message name="mc_issue_get_historyRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
Expand Down Expand Up @@ -818,6 +830,14 @@
<part name="per_page" type="xsd:integer" /></message>
<message name="mc_filter_search_issuesResponse">
<part name="return" type="tns:IssueDataArray" /></message>
<message name="mc_filter_search_issue_idsRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="filter" type="tns:FilterSearchData" />
<part name="page_number" type="xsd:integer" />
<part name="per_page" type="xsd:integer" /></message>
<message name="mc_filter_search_issue_idsResponse">
<part name="return" type="tns:IntegerArray" /></message>
<message name="mc_config_get_stringRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
Expand Down Expand Up @@ -950,6 +970,16 @@
<input message="tns:mc_issue_getRequest"/>
<output message="tns:mc_issue_getResponse"/>
</operation>
<operation name="mc_issues_get">
<documentation>Get all issues matching the ids.</documentation>
<input message="tns:mc_issues_getRequest"/>
<output message="tns:mc_issues_getResponse"/>
</operation>
<operation name="mc_issues_get_header">
<documentation>Get all issues header matching the ids.</documentation>
<input message="tns:mc_issues_get_headerRequest"/>
<output message="tns:mc_issues_get_headerResponse"/>
</operation>
<operation name="mc_issue_get_history">
<documentation>Get the history of the issue with the specified id.</documentation>
<input message="tns:mc_issue_get_historyRequest"/>
Expand Down Expand Up @@ -1175,6 +1205,11 @@
<input message="tns:mc_filter_search_issuesRequest"/>
<output message="tns:mc_filter_search_issuesResponse"/>
</operation>
<operation name="mc_filter_search_issue_ids">
<documentation>Get the issue ids that match the custom filter and paging details.</documentation>
<input message="tns:mc_filter_search_issue_idsRequest"/>
<output message="tns:mc_filter_search_issue_idsResponse"/>
</operation>
<operation name="mc_config_get_string">
<documentation>Get the value for the specified configuration variable.</documentation>
<input message="tns:mc_config_get_stringRequest"/>
Expand Down Expand Up @@ -1298,6 +1333,16 @@
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="mc_issues_get">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issues_get" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="mc_issues_get_header">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issues_get_header" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="mc_issue_get_history">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issue_get_history" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
Expand Down Expand Up @@ -1523,6 +1568,11 @@
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="mc_filter_search_issue_ids">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_filter_search_issue_ids" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="mc_config_get_string">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_config_get_string" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
Expand Down
32 changes: 32 additions & 0 deletions api/soap/mc_filter_api.php
Expand Up @@ -109,6 +109,11 @@ function mc_filter_get( $p_username, $p_password, $p_project_id ) {
* @return array that represents an IssueDataArray structure
*/
function mc_filter_get_issues( $p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page ) {
$t_user_id = mci_check_login( $p_username, $p_password );
if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}
$t_lang = mci_get_user_lang( $t_user_id );

if( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
Expand Down Expand Up @@ -334,3 +339,30 @@ function mc_filter_search_issues( $p_username, $p_password, $p_filter_search, $p
return $t_result;
}

/**
* Get all issue ids matching the custom filter.
*
* @param string $p_username The name of the user trying to access the filters.
* @param string $p_password The password of the user.
* @param FilterSearchData $p_filter_search The custom filter.
* @param integer $p_page_number Start with the given page number (zero-based).
* @param integer $p_per_page Number of issues to display per page.
* @return array that represents an IntegerArray structure
*/
function mc_filter_search_issue_ids( $p_username, $p_password, $p_filter_search, $p_page_number, $p_per_page ) {

$t_user_id = mci_check_login( $p_username, $p_password );

if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}

$t_rows = mci_filter_search_get_rows( $t_user_id, $p_filter_search, $p_page_number, $p_per_page);

$t_result = array();
foreach( $t_rows as $t_issue_data ) {
$t_result[] = $t_issue_data->id;
}

return $t_result;
}
90 changes: 90 additions & 0 deletions api/soap/mc_issue_api.php
Expand Up @@ -1639,3 +1639,93 @@ function mci_issue_data_as_header_array( BugData $p_issue_data ) {

return $t_issue;
}

/**
* Get all issues matching the ids.
*
* @param string $p_username The name of the user trying to access the filters.
* @param string $p_password The password of the user.
* @param IntegerArray $p_issue_ids Number of issues to display per page.
* @return array that represents an IssueDataArray structure
*/
function mc_issues_get( $p_username, $p_password, $p_issue_ids ) {

global $g_project_override;

$t_user_id = mci_check_login( $p_username, $p_password );
if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}

$t_lang = mci_get_user_lang( $t_user_id );

$t_result = array();
foreach( $p_issue_ids as $t_id ) {

if( !bug_exists( $t_id ) ) {
return SoapObjectsFactory::newSoapFault( 'Client', 'Issue ' . $t_id . ' does not exist' );
}

$t_project_id = bug_get_field( $t_id, 'project_id' );
$g_project_override = $t_project_id;
if( !mci_has_readonly_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}

if( !access_has_bug_level( config_get( 'view_bug_threshold', null, null, $t_project_id ), $t_id, $t_user_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}

log_event( LOG_WEBSERVICE, 'getting details for issue \'' . $t_id . '\'' );

$t_issue_data = bug_get( $t_id, true );
$t_result[] = mci_issue_data_as_array( $t_issue_data, $t_user_id, $t_lang );
}

return $t_result;
}

/**
* Get all issues header matching the ids.
*
* @param string $p_username The name of the user trying to access the filters.
* @param string $p_password The password of the user.
* @param IntegerArray $p_issue_ids Number of issues to display per page.
* @return array that represents an IssueHeaderDataArray structure
*/
function mc_issues_get_header( $p_username, $p_password, $p_issue_ids ) {

global $g_project_override;

$t_user_id = mci_check_login( $p_username, $p_password );
if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}

$t_lang = mci_get_user_lang( $t_user_id );

$t_result = array();
foreach( $p_issue_ids as $t_id ) {

if( !bug_exists( $t_id ) ) {
return SoapObjectsFactory::newSoapFault( 'Client', 'Issue ' . $t_id . ' does not exist' );
}

$t_project_id = bug_get_field( $t_id, 'project_id' );
$g_project_override = $t_project_id;
if( !mci_has_readonly_access( $t_user_id, $t_project_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}

if( !access_has_bug_level( config_get( 'view_bug_threshold', null, null, $t_project_id ), $t_id, $t_user_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}

log_event( LOG_WEBSERVICE, 'getting details for issue \'' . $t_id . '\'' );

$t_issue_data = bug_get( $t_id, true );
$t_result[] = mci_issue_data_as_header_array( $t_issue_data, $t_user_id, $t_lang );
}

return $t_result;
}

0 comments on commit 10f2b97

Please sign in to comment.