Open Journal Systems  3.3.0
XMLPSWrapper Class Reference

Public Member Functions

 __construct ($host, $username=null, $token=null)
 
 downloadFile ($jobId, $filename='documents.zip', $destinationDir=null)
 
 getCitationList ()
 
 getJobStatus ($jobId)
 
 statusCodeToLabel ($code)
 
 submitJob ($fileName, $fileContent, $citationStyleHash, $metadata=null)
 

Data Fields

const DEFAULT_DEMO_HOST = 'https://pkp-xml-demo.lib.sfu.ca'
 
const JOB_CONVERSION_STAGE_ZIP = 10
 
const JOB_STATUS_COMPLETED = 2
 
const JOB_STATUS_FAILED = 3
 
const JOB_STATUS_PENDING = 0
 
const JOB_STATUS_PROCESSING = 1
 

Protected Member Functions

 _buildRequestUrl ($endpoint, $params=array())
 
 _getFileUrl ($jobId)
 
 _makeApiRequest ($endpoint, $params, $authRequired=false, $isPost=false)
 
 _withLoginCredentials ($params)
 

Protected Attributes

 $_host = null
 
 $_token = null
 
 $_username = null
 

Detailed Description

Wrapper class for XML Parsing Service.

Definition at line 16 of file XMLPSWrapper.inc.php.

Constructor & Destructor Documentation

◆ __construct()

XMLPSWrapper::__construct (   $host,
  $username = null,
  $token = null 
)

Initialize object with server parameters

Parameters
$hoststring server hostname
$usernamestring username
$tokenstring token

Definition at line 52 of file XMLPSWrapper.inc.php.

References DEFAULT_DEMO_HOST.

Member Function Documentation

◆ _buildRequestUrl()

XMLPSWrapper::_buildRequestUrl (   $endpoint,
  $params = array() 
)
protected

Internal helper method to build request url

Parameters
$endpointstring api endpoint
$paramsarray parameters
Returns
string

Definition at line 71 of file XMLPSWrapper.inc.php.

Referenced by _getFileUrl(), and _makeApiRequest().

◆ _getFileUrl()

XMLPSWrapper::_getFileUrl (   $jobId)
protected

Get the converted file URL

Parameters
$jobIdint job id
Returns
string

Definition at line 217 of file XMLPSWrapper.inc.php.

References _buildRequestUrl(), and _withLoginCredentials().

Referenced by downloadFile().

◆ _makeApiRequest()

XMLPSWrapper::_makeApiRequest (   $endpoint,
  $params,
  $authRequired = false,
  $isPost = false 
)
protected

Internal helper method that makes request to api endpoint

Parameters
$endpointstring api endpoint
$paramsarray parameters
$authRequiredboolean whether authentication is required
$isPostboolean Whether to use GET/POST request
Returns
array
Exceptions
Exceptionlogin credentials are not set for and api call requires authentication
ExceptionWhen request fails.

Definition at line 108 of file XMLPSWrapper.inc.php.

References _buildRequestUrl(), and _withLoginCredentials().

Referenced by getCitationList(), getJobStatus(), and submitJob().

◆ _withLoginCredentials()

XMLPSWrapper::_withLoginCredentials (   $params)
protected

adds login credentials to array of parameters

@params $params array parameters

Returns
array

Definition at line 86 of file XMLPSWrapper.inc.php.

Referenced by _getFileUrl(), and _makeApiRequest().

◆ downloadFile()

XMLPSWrapper::downloadFile (   $jobId,
  $filename = 'documents.zip',
  $destinationDir = null 
)

Get a job final stage archive zip file

Parameters
$jobIdint job id
$filenameName for downloaded file
$destinationDirDestination directory
Returns
string

Definition at line 238 of file XMLPSWrapper.inc.php.

References _getFileUrl().

◆ getCitationList()

XMLPSWrapper::getCitationList ( )

Get list of citation styles

Returns
array
Exceptions
ExceptionWhen response status is not equal to success.

Definition at line 265 of file XMLPSWrapper.inc.php.

References _makeApiRequest().

◆ getJobStatus()

XMLPSWrapper::getJobStatus (   $jobId)

Query a job's status

Parameters
$jobIdint job id
Returns
int
Exceptions
ExceptionWhen response status is not equal to success.

Definition at line 195 of file XMLPSWrapper.inc.php.

References _makeApiRequest().

◆ statusCodeToLabel()

XMLPSWrapper::statusCodeToLabel (   $code)

Returns the label for a status code

Parameters
int$codeStatus code

Definition at line 281 of file XMLPSWrapper.inc.php.

References JOB_STATUS_COMPLETED, JOB_STATUS_FAILED, JOB_STATUS_PENDING, and JOB_STATUS_PROCESSING.

◆ submitJob()

XMLPSWrapper::submitJob (   $fileName,
  $fileContent,
  $citationStyleHash,
  $metadata = null 
)

Submit a file for conversion

Parameters
$fileNamestring file name
$fileContentstring content
$citationStyleHashstring citation style hash
$metadataarray document metadata
Returns
int
Exceptions
ExceptionWhen response status is not equal to success.

Definition at line 165 of file XMLPSWrapper.inc.php.

References _makeApiRequest().

Field Documentation

◆ $_host

$host XMLPSWrapper::$_host = null
protected

string server host

Definition at line 42 of file XMLPSWrapper.inc.php.

◆ $_token

$token XMLPSWrapper::$_token = null
protected

string user token

Definition at line 36 of file XMLPSWrapper.inc.php.

◆ $_username

$username XMLPSWrapper::$_username = null
protected

string user login

Definition at line 30 of file XMLPSWrapper.inc.php.

◆ DEFAULT_DEMO_HOST

const XMLPSWrapper::DEFAULT_DEMO_HOST = 'https://pkp-xml-demo.lib.sfu.ca'

Definition at line 24 of file XMLPSWrapper.inc.php.

Referenced by __construct().

◆ JOB_CONVERSION_STAGE_ZIP

const XMLPSWrapper::JOB_CONVERSION_STAGE_ZIP = 10

Definition at line 18 of file XMLPSWrapper.inc.php.

◆ JOB_STATUS_COMPLETED

const XMLPSWrapper::JOB_STATUS_COMPLETED = 2

◆ JOB_STATUS_FAILED

const XMLPSWrapper::JOB_STATUS_FAILED = 3

◆ JOB_STATUS_PENDING

const XMLPSWrapper::JOB_STATUS_PENDING = 0

◆ JOB_STATUS_PROCESSING

const XMLPSWrapper::JOB_STATUS_PROCESSING = 1

The documentation for this class was generated from the following file: