Changes between Version 2 and Version 3 of FactoryManual/FromScratch


Ignore:
Timestamp:
06/30/09 12:52:22 (8 years ago)
Author:
sander
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FactoryManual/FromScratch

    v2 v3  
    99== jobs.poll() == 
    1010 
    11 You start using the API by calling `jobs.poll`. The first time you call this function will activate your factory on the server. That means that the applications associated with your factory will be shown on the front page of the Officeshots website. By default, only factories that have been active (i.e. called the `jobs.poll` function) will be shown on the front page. The signature is as follows. 
     11You start using the API by calling `jobs.poll`. The first time you call this function will activate your factory on the server. That means that the applications associated with your factory will be shown on the front page of the Officeshots website. By default, only factories that have been active (i.e. called the `jobs.poll` function) will be shown on the front page. If there are jobs waiting on the server for your factory then one will be returned. 
    1212 
    13 {{{ 
    14 struct jobs.poll(string factory_name); 
    15 }}} 
     13When a job is returned to you it will be locked for five minutes. That means the job will not be sent to any other factory that could handle the job. This lock expires automatically. If you take longer than five minutes to process the job then it is possible that it has been sent to a different factory. In that case your upload using `jobs.finish` will fail. 
    1614 
    17 When there are no suitable jobs waiting on the server then an empty value will be returned. If there are jobs then you will get a struct containing nine members. 
    18  
    19  job (string):: 
    20     The GUID of the job.  
    21  application (string):: 
    22     The name of the application this job needs to be processed by.  
    23  version (string):: 
    24     The version string of the application.  
    25  pageStart (int):: 
    26     The first page of the doucment to render in the output. Supporting this feature is optional.  
    27  pageEnd (int):: 
    28     The last page of the document to render. If this is zero then all the pages starting from pageStart should be rendered. Supporting this feature is optional.  
    29  format (string):: 
    30     A three letter code indicating the desired output format (pdf, png, odf). If this is empty then you may choose the output format yourself.  
    31  filename (string):: 
    32     The original filename of the document as it was uploaded by the user.  
    33  doctype (string):: 
    34     A three-letter code indicating the file format of the file (odt, ods, odp).  
    35  document (string):: 
    36     The base64-encoded contents of the file. 
    37  
    38 === Job locking === 
    39  
    40 When a job is returned to you it will be locked for five mintues. That means the job will not be sent to any other factory that could handle the job. This lock expires automatically. If you take longer than five minutes to process the job then it is possible that it has been sent to a different factory. In that case your upload using `jobs.finish` will fail. 
    41  
    42 === Examples === 
    43  
    44 Calling `jobs.poll()`: 
    45  
    46 {{{ 
    47 #!xml 
    48 POST /xmlrpc HTTP/1.0 
    49 Host: www.officeshots.org 
    50 Content-Type: text/xml 
    51 Content-Length: 163 
    52  
    53 <?xml version='1.0'?> 
    54 <methodCall> 
    55   <methodName>jobs.poll</methodName> 
    56   <params> 
    57     <param><value><string>My factory</string></value></param> 
    58   </params> 
    59 </methodCall> 
    60 }}} 
    61  
    62 Response to `jobs.poll()` containing a job: 
    63  
    64 {{{ 
    65 #!xml 
    66 HTTP/1.1 200 OK 
    67 Date: Fri, 15 May 2009 12:06:12 GMT 
    68 Server: Apache/2.2.9 (Debian) 
    69 X-Powered-By: PHP/5.2.6-1+lenny3 
    70 Set-Cookie: CAKEPHP=1234567890ABCDEF; path=/; secure 
    71 P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" 
    72 Connection: close 
    73 Content-Type: application/xml 
    74  
    75 <?xml version="1.0" encoding="iso-8859-1"?> 
    76 <methodResponse> 
    77   <params> 
    78     <param> 
    79       <value> 
    80         <struct> 
    81           <member> 
    82             <name>job</name> 
    83             <value><string>4975c9c6-79a0-43a1-8134-0ba5c0a80105</string></value> 
    84           </member> 
    85           <member> 
    86             <name>application</name> 
    87             <value><string>OpenOffice.org Writer</string></value> 
    88           </member> 
    89           <member> 
    90             <name>version</name> 
    91             <value><string>3.0</string></value> 
    92           </member> 
    93           <member> 
    94             <name>pageStart</name> 
    95             <value><string>1</string></value> 
    96           </member> 
    97           <member> 
    98             <name>pageEnd</name> 
    99             <value><string>0</string></value> 
    100           </member> 
    101           <member> 
    102             <name>format</name> 
    103             <value><string>pdf</string></value> 
    104           </member> 
    105           <member> 
    106             <name>filename</name> 
    107             <value><string>mydocument.odt</string></value> 
    108           </member> 
    109           <member> 
    110             <name>doctype</name> 
    111             <value><string>odt</string></value> 
    112           </member> 
    113           <member> 
    114             <name>document</name> 
    115             <value><string>UEsDBBQA ... AAAAAA==</string></value> 
    116           </member> 
    117         </struct> 
    118       </value> 
    119     <param> 
    120   </params> 
    121 </methodResponse> 
    122 }}} 
    123  
    124 Response to `jobs.poll()` when there are no jobs: 
    125  
    126 {{{ 
    127 #!xml 
    128 HTTP/1.1 200 OK 
    129 Date: Fri, 15 May 2009 12:06:12 GMT 
    130 Server: Apache/2.2.9 (Debian) 
    131 X-Powered-By: PHP/5.2.6-1+lenny3 
    132 Set-Cookie: CAKEPHP=1234567890ABCDEF; path=/; secure 
    133 P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" 
    134 Connection: close 
    135 Content-Type: application/xml 
    136  
    137 <?xml version="1.0" encoding="iso-8859-1"?> 
    138 <methodResponse> 
    139   <params> 
    140     <param> 
    141       <value> 
    142       </value> 
    143     <param> 
    144   </params> 
    145 </methodResponse> 
    146 }}} 
     15See: [wiki:XMLRPC/JobsPoll]