Ejemplo n.º 1
0
 /**
  * getArtifacts - returns an ArtifactQueryResult that belongs to the project $group_id, to the tracker $group_artifact_id,
  *                and that match the criteria $criteria. If $offset and $max_rows are filled, the number of returned artifacts
  *                will not exceed $max_rows, beginning at $offset.
  *
  * !!!!!!!!!!!!!!!
  * !!! Warning : If $max_rows is not filled, $offset is not taken into account. !!!
  * !!!!!!!!!!!!!!!
  *
  * @param string $sessionKey the session hash associated with the session opened by the person who calls the service
  * @param int $group_id the ID of the group we want to retrieve the array of artifacts
  * @param int $tracker_id the ID of the tracker we want to retrieve the array of artifacts
  * @param array{SOAPCriteria} $criteria the criteria that the set of artifact must match
  * @param int $offset number of artifact skipped. Used in association with $max_rows to limit the number of returned artifact.
  * @param int $max_rows the maximum number of artifacts returned
  * @return the SOAPArtifactQueryResult that match the criteria $criteria and belong to the project $group_id and the tracker $group_artifact_id,
  *          or a soap fault if group_id does not match with a valid project, or if group_artifact_id does not match with a valid tracker.
  */
 function getArtifacts($sessionKey, $group_id, $tracker_id, $criteria, $offset, $max_rows)
 {
     if (session_continue($sessionKey)) {
         $pm = ProjectManager::instance();
         try {
             $project = $pm->getGroupByIdForSoap($group_id, 'getArtifacts');
         } catch (SoapFault $e) {
             return $e;
         }
         if (!$project->usesService('plugin_tracker')) {
             return new SoapFault(get_service_fault, 'Tracker service is not used for this project.', 'getArtifacts');
         }
         $tf = TrackerFactory::instance();
         if (!$tf) {
             return new SoapFault(get_tracker_factory_fault, 'Could Not Get TrackerFactory', 'getArtifacts');
         }
         $tracker = $tf->getTrackerById($tracker_id);
         if ($tracker == null) {
             return new SoapFault(get_tracker_factory_fault, 'Could Not Get Tracker', 'getArtifacts');
         } else {
             if (!$tracker->userCanView()) {
                 return new SoapFault(get_tracker_factory_fault, 'Permission Denied: You are not granted sufficient permission to perform this operation.', 'getArtifacts');
             } else {
                 $af = Tracker_ArtifactFactory::instance();
                 $artifacts = $af->getArtifactsByTrackerId($tracker_id);
             }
         }
         // the function getArtifacts returns all artifacts without whecking if user is allowed to see them
         // => we need to fliter them
         return artifact_query_result_to_soap($artifacts);
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session ', 'getArtifacts');
     }
 }
Ejemplo n.º 2
0
 /**
  * getArtifacts - returns an ArtifactQueryResult that belongs to the project $group_id, to the tracker $group_artifact_id,
  *                and that match the criteria $criteria. If $offset and $max_rows are filled, the number of returned artifacts
  *                will not exceed $max_rows, beginning at $offset.
  *
  * !!!!!!!!!!!!!!!
  * !!! Warning : If $max_rows is not filled, $offset is not taken into account. !!!
  * !!!!!!!!!!!!!!!
  *
  * @param string $sessionKey the session hash associated with the session opened by the person who calls the service
  * @param int $group_id the ID of the group we want to retrieve the array of artifacts
  * @param int $group_artifact_id the ID of the tracker we want to retrieve the array of artifacts
  * @param array{SOAPCriteria} $criteria the criteria that the set of artifact must match
  * @param int $offset number of artifact skipped. Used in association with $max_rows to limit the number of returned artifact.
  * @param int $max_rows the maximum number of artifacts returned
  * @return the SOAPArtifactQueryResult that match the criteria $criteria and belong to the project $group_id and the tracker $group_artifact_id,
  *          or a soap fault if group_id does not match with a valid project, or if group_artifact_id does not match with a valid tracker.
  */
 function getArtifacts($sessionKey, $group_id, $group_artifact_id, $criteria, $offset, $max_rows)
 {
     global $art_field_fact;
     if (session_continue($sessionKey)) {
         try {
             $pm = ProjectManager::instance();
             $grp = $pm->getGroupByIdForSoap($group_id, 'getArtifacts');
         } catch (SoapFault $e) {
             return $e;
         }
         $at = new ArtifactType($grp, $group_artifact_id);
         if (!$at || !is_object($at)) {
             return new SoapFault(get_artifact_type_fault, 'Could Not Get ArtifactType', 'getArtifacts');
         } elseif (!$at->userCanView()) {
             return new SoapFault(get_artifact_type_fault, 'Permission Denied: You are not granted sufficient permission to perform this operation.', 'getArtifacts');
         } elseif ($at->isError()) {
             return new SoapFault(get_artifact_type_fault, $at->getErrorMessage(), 'getArtifacts');
         }
         $art_field_fact = new ArtifactFieldFactory($at);
         if (!$art_field_fact || !is_object($art_field_fact)) {
             return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldFactory', 'getArtifactTypes');
         } elseif ($art_field_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_field_fact->getErrorMessage(), 'getArtifactTypes');
         }
         $af = new ArtifactFactory($at);
         if (!$af || !is_object($af)) {
             return new SoapFault(get_artifact_factory_fault, 'Could Not Get ArtifactFactory', 'getArtifacts');
         } elseif ($af->isError()) {
             return new SoapFault(get_artifact_factory_fault, $af->getErrorMessage(), 'getArtifacts');
         }
         $total_artifacts = 0;
         // the function getArtifacts returns only the artifacts the user is allowed to view
         $artifacts = $af->getArtifacts($criteria, $offset, $max_rows, $total_artifacts);
         return artifact_query_result_to_soap($artifacts, $total_artifacts);
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session ', 'getArtifactTypes');
     }
 }