Commit d4782b2f94512183659bc25fc26873cab664d5d2
1 parent
dd126320
Added new functions to add_document_with_key for file uploads without the tempfilename.
Committed by: Megan Watson
Showing
1 changed file
with
51 additions
and
15 deletions
ktwebservice/webservice.php
| ... | ... | @@ -954,11 +954,25 @@ class KTWebService |
| 954 | 954 | { |
| 955 | 955 | // add_document |
| 956 | 956 | $this->__dispatch_map['add_document'] = |
| 957 | - array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'unique_file_id' => 'string' ), | |
| 957 | + array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string'), | |
| 958 | 958 | 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ), |
| 959 | 959 | ); |
| 960 | 960 | |
| 961 | 961 | $this->__dispatch_map['add_document_with_metadata'] = |
| 962 | + array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata"), | |
| 963 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ) | |
| 964 | + ); | |
| 965 | + } | |
| 966 | + | |
| 967 | + if($this->version >= 2) | |
| 968 | + { | |
| 969 | + // add_document | |
| 970 | + $this->__dispatch_map['add_document_with_key'] = | |
| 971 | + array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'unique_file_id' => 'string' ), | |
| 972 | + 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ), | |
| 973 | + ); | |
| 974 | + | |
| 975 | + $this->__dispatch_map['add_document_with_key_with_metadata'] = | |
| 962 | 976 | array('in' => array('session_id'=>'string','folder_id'=>'int','title'=>'string','filename'=>'string','documentype' =>'string','tempfilename' =>'string', 'metadata'=>"{urn:$this->namespace}kt_metadata_fieldsets",'sysdata'=>"{urn:$this->namespace}kt_sysdata", 'unique_file_id' => 'string' ), |
| 963 | 977 | 'out' => array( 'return' => "{urn:$this->namespace}kt_document_detail" ) |
| 964 | 978 | ); |
| ... | ... | @@ -2263,18 +2277,7 @@ class KTWebService |
| 2263 | 2277 | |
| 2264 | 2278 | } |
| 2265 | 2279 | |
| 2266 | - /** | |
| 2267 | - * Adds a document to the repository. | |
| 2268 | - * | |
| 2269 | - * @param string $session_id | |
| 2270 | - * @param int $folder_id | |
| 2271 | - * @param string $title | |
| 2272 | - * @param string $filename | |
| 2273 | - * @param string $documenttype | |
| 2274 | - * @param string $tempfilename | |
| 2275 | - * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | |
| 2276 | - */ | |
| 2277 | - function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $unique_file_id = null) | |
| 2280 | + function add_document_with_key($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $unique_file_id = null) | |
| 2278 | 2281 | { |
| 2279 | 2282 | if(empty($tempfilename) && !empty($unique_file_id)){ |
| 2280 | 2283 | $upload_manager = new KTUploadManager(); |
| ... | ... | @@ -2288,6 +2291,22 @@ class KTWebService |
| 2288 | 2291 | } |
| 2289 | 2292 | } |
| 2290 | 2293 | |
| 2294 | + return $this->add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename); | |
| 2295 | + } | |
| 2296 | + | |
| 2297 | + /** | |
| 2298 | + * Adds a document to the repository. | |
| 2299 | + * | |
| 2300 | + * @param string $session_id | |
| 2301 | + * @param int $folder_id | |
| 2302 | + * @param string $title | |
| 2303 | + * @param string $filename | |
| 2304 | + * @param string $documenttype | |
| 2305 | + * @param string $tempfilename | |
| 2306 | + * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS | |
| 2307 | + */ | |
| 2308 | + function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename) | |
| 2309 | + { | |
| 2291 | 2310 | $this->debug("add_document('$session_id',$folder_id,'$title','$filename','$documenttype','$tempfilename')"); |
| 2292 | 2311 | $kt = &$this->get_ktapi($session_id ); |
| 2293 | 2312 | if (is_array($kt)) |
| ... | ... | @@ -2373,9 +2392,26 @@ class KTWebService |
| 2373 | 2392 | return $update_result; |
| 2374 | 2393 | } |
| 2375 | 2394 | |
| 2376 | - function add_document_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata, $unique_file_id = null) | |
| 2395 | + function add_document_with_key_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata, $unique_file_id = null) | |
| 2396 | + { | |
| 2397 | + if(empty($tempfilename) && !empty($unique_file_id)){ | |
| 2398 | + $upload_manager = new KTUploadManager(); | |
| 2399 | + $tempfilename = $upload_manager->get_tempfile_from_unique_id($unique_file_id); | |
| 2400 | + | |
| 2401 | + if (PEAR::isError($tempfilename)) | |
| 2402 | + { | |
| 2403 | + $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT, "Invalid unique file id: {$tempfilename->getMessage()}."); | |
| 2404 | + $this->debug("add_document - cannot add document - " . $tempfilename->getMessage(), $session_id); | |
| 2405 | + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); | |
| 2406 | + } | |
| 2407 | + } | |
| 2408 | + | |
| 2409 | + return $this->add_document_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata); | |
| 2410 | + } | |
| 2411 | + | |
| 2412 | + function add_document_with_metadata($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata) | |
| 2377 | 2413 | { |
| 2378 | - $add_result = $this->add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $unique_file_id); | |
| 2414 | + $add_result = $this->add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename); | |
| 2379 | 2415 | |
| 2380 | 2416 | $status_code = $add_result->value['status_code']; |
| 2381 | 2417 | if ($status_code != 0) | ... | ... |