/** * Get the field data for artifact submission * * @param string the soap field value * * @return String the field data corresponding to the soap_value for artifact submision */ public function getFieldData($soap_value) { if (!$soap_value instanceof stdClass) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "Invalid submitted value for file field"); } if (!isset($soap_value->file_info) || !is_array($soap_value->file_info)) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "A File FieldValue must have a 'file_info' array (ArrayOfFieldValueFileInfo)"); } $field_data = array(); foreach ($soap_value->file_info as $fileinfo) { if (!$fileinfo instanceof stdClass) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "Fileinfo must be an array of FieldValueFileInfo"); } if (!(isset($fileinfo->description) && isset($fileinfo->filename) && isset($fileinfo->filetype) && isset($fileinfo->filesize))) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "Fileinfo must be an array of FieldValueFileInfo"); } if (!(isset($fileinfo->id) && $fileinfo->id)) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "FieldValueFileInfo must have an id of a temporary file"); } if (isset($fileinfo->action) && $fileinfo->action == 'delete') { $field_data['delete'][] = $fileinfo->id; } else { $temporary_file = new Tracker_SOAP_TemporaryFile($this->getCurrentUser(), $fileinfo->id); if (!$temporary_file->exists($fileinfo->id)) { throw new SoapFault(self::SOAP_FAULT_INVALID_REQUEST_FORMAT, "Invalid FieldValueFileInfo->id, file doesn't exist"); } $field_data[] = array('id' => $fileinfo->id, 'description' => $fileinfo->description, 'name' => $fileinfo->filename, 'type' => $fileinfo->filetype, 'size' => $fileinfo->filesize, 'error' => UPLOAD_ERR_OK, 'tmp_name' => $temporary_file->getPath($fileinfo->id)); } } return $field_data; }