diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d08273..dfa0bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,3 +62,8 @@ - Tags are now added, therefore it can be replaced by ingest method. - overwriteExisting flag has been fixed and works as expected now! - Introduce `includeInternalPublication` in Events API `getAll`, `get` and `getPublications` methods [#37] +- Deprecated methods cleanup! [#39] + - `OcWorkflow->getStatistics()` + - `OcWorkflow->getInstances()` + - `OcSeries->getTitles()` + - `OcSeries->getAll()` diff --git a/src/OpencastApi/Rest/OcSeries.php b/src/OpencastApi/Rest/OcSeries.php index 0cb08d2..43274b0 100644 --- a/src/OpencastApi/Rest/OcSeries.php +++ b/src/OpencastApi/Rest/OcSeries.php @@ -25,7 +25,7 @@ public function getCount() /** * Returns the access control list for the series with the given identifier as JSON (Object) by default or XLM (text). * - * @param string $seriesId The series identifier + * @param string $seriesId The series identifier * @param string $format (optional) The output format (json or xml) of the response body. (Default value = 'json') * * @return array the response result ['code' => 200, 'body' => '{The access control list as JSON (Object) or XML (text)}'] @@ -40,17 +40,6 @@ public function getAcl($seriesId, $format = '') return $this->restClient->performGet($uri); } - /** - * Returns a list of identifier and title of all series - * @return array the response result ['code' => 200, 'body' => '{JSON (object) list of identifier and title of all series}'] - * @deprecated since version v1.3, removed from Opencast Version 12 - */ - public function getTitles() - { - $uri = self::URI . "/allSeriesIdTitle.json"; - return $this->restClient->performGet($uri); - } - /** * Returns the series with the given identifier as JSON (Object) by default or XLM (text). * @@ -68,7 +57,7 @@ public function get($seriesId, $format = '') return $this->restClient->performGet($uri); } - + /** * Returns the series element * @@ -113,7 +102,7 @@ public function getProperties($seriesId) * Returns a series property value * * @param string $seriesId The series identifier - * @param string $propertyName Name of series property + * @param string $propertyName Name of series property * * @return array the response result ['code' => 200, 'body' => '{JSON (object) series property value}'] */ @@ -123,83 +112,6 @@ public function getProperty($seriesId, $propertyName) return $this->restClient->performGet($uri); } - /** - * Returns the series matching the query parameters as JSON (array) by default or XLM (text). - * - * @param array $params (optional) The list of query params to pass which can contain the followings: - * [ - * 'q' => '{Free text search}', - * 'edit' => '(boolean){Whether this query should return only series that are editable}', - * 'fuzzyMatch' => '(boolean){Whether the seriesId can be used for a partial match. The default is an exact match}', - * 'seriesId' => '{The series identifier}', - * 'seriesTitle' => '{The series title}', - * 'creator' => '{The series creator}', - * 'contributor' => '{The series contributor}', - * 'publisher' => '{The series publisher}', - * 'rightsholder' => '{The series rights holder}', - * 'createdfrom' => '{Filter results by created from (yyyy-MM-dd'T'HH:mm:ss'Z') }', - * 'createdto' => '{Filter results by created to (yyyy-MM-dd'T'HH:mm:ss'Z')) }', - * 'language' => '{The series language}', - * 'license' => '{The series license}', - * 'subject' => '{The series subject}', - * 'abstract' => '{The series abstract}', - * 'description' => '{The series description}', - * 'sort' => '{The sort order. May include any of the following: TITLE, SUBJECT, CREATOR, PUBLISHER, CONTRIBUTOR, ABSTRACT, DESCRIPTION, CREATED, AVAILABLE_FROM, AVAILABLE_TO, LANGUAGE, RIGHTS_HOLDER, SPATIAL, TEMPORAL, IS_PART_OF, REPLACES, TYPE, ACCESS, LICENCE. Add '_DESC' to reverse the sort order (e.g. TITLE_DESC)}', - * 'startPage' => '{The page offset}', - * 'count' => '{Results per page (max 100)}', - * ] - * @param string $format (optional) The output format (json or xml) of the response body. (Default value = 'json') - * - * @return array the response result ['code' => 200, 'body' => '{the series search results as JSON (array) or XML (text)}'] - * @deprecated Deprecated since version 1.3 - since it is removed from Opencast Verrsion 12. - */ - public function getAll($params = [], $format = '') - { - $uri = self::URI . "/series.json"; - if (!empty($format) && strtolower($format) == 'xml') { - $uri = str_replace('.json', '.xml', $uri); - } - - $query = []; - $acceptableParams = [ - 'q', 'edit', 'fuzzyMatch', 'seriesId', 'seriesTitle', - 'creator', 'contributor', 'publisher', 'rightsholder', 'createdfrom', - 'createdto', 'language', 'license', 'subject', 'abstract', - 'description', 'startPage', 'count' - ]; - foreach ($params as $param_name => $param_value) { - if (in_array($param_name, $acceptableParams)) { - if ((($param_name == 'edit' || $param_name == 'fuzzyMatch') && is_bool($param_value)) || !empty($param_value)) { - if ($param_name == 'count') { - $param_value = intval($param_value); - $param_value = ($param_value <= 100) ?: 100; - } - $query[$param_name] = $param_value; - } - } - } - $sortsASC = [ - 'TITLE', 'SUBJECT', 'CREATOR', 'PUBLISHER', - 'CONTRIBUTOR', 'ABSTRACT', 'DESCRIPTION', 'CREATED', - 'AVAILABLE_FROM', 'AVAILABLE_TO','LANGUAGE', 'RIGHTS_HOLDER', - 'SPATIAL', 'TEMPORAL', 'IS_PART_OF', 'REPLACES', 'TYPE', - 'ACCESS', 'LICENCE' - ]; - $sortsDESC = array_map(function ($sort) { - return "{$sort}_DESC"; - }, $sortsASC); - - $sorts = array_merge($sortsASC, $sortsDESC); - - if (array_key_exists('sort', $params) && !empty($params['sort']) && - in_array($params['sort'], $sorts)) { - $query['sort'] = $params['sort']; - } - - $options = $this->restClient->getQueryParams($query); - return $this->restClient->performGet($uri, $options); - } - /** * Deletes a series * @@ -215,9 +127,9 @@ public function delete($seriesId) /** * Deletes a series element - * + * * @param string $seriesId The series identifier - * @param string $elementType The element type + * @param string $elementType The element type * * @return array the response result ['code' => 204, 'reason' => 'No Content'] (Series element deleted) */ @@ -229,7 +141,7 @@ public function deleteElement($seriesId, $elementType) /** * Deletes a series property - * + * * @param string $seriesId The series identifier * @param string $propertyName Name of series property * @@ -307,8 +219,8 @@ public function updateAcl($seriesId, $acl, $override = false) * * @return array the response result: * ['code' => 201, 'reason' => 'Created'] (series created) - * ['code' => 204, 'reason' => 'No Content'] (series updated) - * + * ['code' => 204, 'reason' => 'No Content'] (series updated) + * */ public function update($params, $override = false) { @@ -374,4 +286,4 @@ public function updateProperty($seriesId, $name, $value) return $this->restClient->performPost($uri, $options); } } -?> \ No newline at end of file +?> diff --git a/src/OpencastApi/Rest/OcWorkflow.php b/src/OpencastApi/Rest/OcWorkflow.php index 3ed17fa..c3fb313 100644 --- a/src/OpencastApi/Rest/OcWorkflow.php +++ b/src/OpencastApi/Rest/OcWorkflow.php @@ -14,7 +14,7 @@ public function __construct($restClient) /** * Get the configuration panel for a specific workflow * - * @param string $definitionId (optional) The workflow definition identifier + * @param string $definitionId (optional) The workflow definition identifier * * @return array the response result ['code' => 200, 'body' => '{The HTML workflow configuration panel}'] */ @@ -26,7 +26,7 @@ public function getConfigurationPanel($definitionId = '') if (!empty($definitionId)) { $query['definitionId'] = $definitionId; } - + $options = $this->restClient->getQueryParams($query); return $this->restClient->performGet($uri, $options); } @@ -34,7 +34,7 @@ public function getConfigurationPanel($definitionId = '') /** * Returns the number of workflow instances in a specific state and operation * - * @param string $state (optional) The workflow state + * @param string $state (optional) The workflow state * @param string $operation (optional) The current operation * * @return array the response result ['code' => 200, 'body' => '{The number of workflow instances}'] @@ -50,7 +50,7 @@ public function getCount($state = '', $operation = '') if (!empty($operation)) { $query['operation'] = $operation; } - + $options = $this->restClient->getQueryParams($query); return $this->restClient->performGet($uri, $options); } @@ -112,26 +112,9 @@ public function getStateMappings() return $this->restClient->performGet($uri); } - /** - * Returns the workflow statistics as JSON (Object) by default or XLM (text) - * - * @param string $format (optional) The output format (json or xml) of the response body. (Default value = 'json') - * - * @return array the response result ['code' => 200, 'body' => '{A JSON (object) | XML (text) representation of the workflow statistics }'] - * @deprecated from version v1.3 and will be removed in v1.4 - */ - public function getStatistics($format = '') - { - $uri = self::URI . "/statistics.json"; - if (!empty($format) && strtolower($format) == 'xml') { - $uri = str_replace('.json', '.xml', $uri); - } - return $this->restClient->performGet($uri); - } - /** * Get a specific workflow instance as JSON (Object) by default or XLM (text). - * + * * @param string $instanceId The workflow instance identifier * @param string $format (optional) The output format (json or xml) of the response body. (Default value = 'json') * @@ -146,82 +129,11 @@ public function getInstance($instanceId, $format = '') return $this->restClient->performGet($uri); } - /** - * List all workflow instances matching the query parameters as JSON (Object) by default or XLM (text). - * - * @param array $params (optional) The list of query params to pass which can contain the followings: - * [ - * 'state' => '{Filter results by workflows' current state}', - * 'q' => '{Filter results by free text query}', - * 'seriesId' => '{ Filter results by series identifier }', - * 'seriesTitle' => '{ Filter results by series title }', - * 'creator' => '{ Filter results by the mediapackage's creator }', - * 'contributor' => '{Filter results by the mediapackage's contributor}', - * 'fromdate' => '{Filter results by workflow start date}', - * 'todate' => '{Filter results by workflow start date}', - * 'language' => '{Filter results by mediapackage's language.}', - * 'license' => '{Filter results by mediapackage's license}', - * 'title' => '{Filter results by mediapackage's title}', - * 'subject' => '{Filter results by mediapackage's subject}', - * 'workflowdefinition' => '{Filter results by workflow definition}', - * 'mp' => '{Filter results by mediapackage identifier.}', - * 'op' => '{ Filter results by workflows' current operation}', - * 'sort' => '{The sort order. May include any of the following: DATE_CREATED, TITLE, SERIES_TITLE, SERIES_ID, MEDIA_PACKAGE_ID, WORKFLOW_DEFINITION_ID, CREATOR, CONTRIBUTOR, LANGUAGE, LICENSE, SUBJECT. Add '_DESC' to reverse the sort order (e.g. TITLE_DESC)}', - * 'startPage' => '{(Default value=0): The paging offset }', - * 'count' => '{(Default value=0): The number of results to return.}', - * 'compact' => '{Whether to return a compact version of the workflow instance, with mediapackage elements, workflow and workflow operation configurations and non-current operations removed}', - * ] - * @param string $format (optional) The output format (json or xml) of the response body. (Default value = 'json') - * - * @return array the response result ['code' => 200, 'body' => '{A JSON (object) | XML (text) representation of the workflow set }'] - * @deprecated from version v1.3 and will be removed in v1.4 - */ - public function getInstances($params = [], $format = '') - { - $uri = self::URI . "/instances.json"; - if (!empty($format) && strtolower($format) == 'xml') { - $uri = str_replace('.json', '.xml', $uri); - } - - $query = []; - - $sortsASC = [ - 'DATE_CREATED', 'TITLE', 'SERIES_TITLE', 'SERIES_ID', - 'MEDIA_PACKAGE_ID', 'WORKFLOW_DEFINITION_ID', 'CREATOR', 'CONTRIBUTOR', - 'LANGUAGE', 'LICENSE','SUBJECT' - ]; - $sortsDESC = array_map(function ($sort) { - return "{$sort}_DESC"; - }, $sortsASC); - - $sorts = array_merge($sortsASC, $sortsDESC); - - if (array_key_exists('sort', $params) && !empty($params['sort']) && - in_array($params['sort'], $sorts)) { - $query['sort'] = $params['sort']; - } - - $acceptableParams = [ - 'state', 'q', 'seriesId', 'seriesTitle', 'creator', 'contributor', - 'fromdate', 'todate', 'language', 'license', 'title', 'subject', - 'workflowdefinition', 'mp', 'op', 'startPage', 'count', 'compact' - ]; - - foreach ($params as $param_name => $param_value) { - if (in_array($param_name, $acceptableParams) && !array_key_exists($param_name, $query)) { - $query[$param_name] = $param_value; - } - } - - $options = $this->restClient->getQueryParams($query); - return $this->restClient->performGet($uri, $options); - } - /** * (Danger!) Permenantly removes a workflow instance including all its child jobs. * In most circumstances, /stop is what you should use. * - * @param string $instanceId The workflow instance identifier + * @param string $instanceId The workflow instance identifier * @param boolean $force (optional) If the workflow status should be ignored and the workflow removed anyway (Default value=false) * * @return array the response result ['code' => 204, 'reason' => 'No Content'] (If workflow instance could be removed successfully, no content is returned) @@ -246,7 +158,7 @@ public function removeInstance($instanceId, $force = false) * @param array|string $mediapackage (Optional) The new Mediapackage * @param array|string $properties (Optional) Properties * - * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the updated and resumed workflow instance}'] + * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the updated and resumed workflow instance}'] */ public function replaceAndresume($instanceId, $mediapackage = '', $properties = '') { @@ -271,7 +183,7 @@ public function replaceAndresume($instanceId, $mediapackage = '', $properties = * * @param string $instanceId The workflow instance identifier * - * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the resumed workflow instance.}'] + * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the resumed workflow instance.}'] */ public function resume($instanceId) { @@ -293,7 +205,7 @@ public function resume($instanceId) * @param string $parent (Optional) An optional parent workflow instance identifier * @param string|array $properties (Optional) An optional set of key=value properties * - * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the new workflow instance.}'] + * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the new workflow instance.}'] */ public function start($definition, $mediapackage, $parent = '', $properties = '') { @@ -319,7 +231,7 @@ public function start($definition, $mediapackage, $parent = '', $properties = '' * * @param string $instanceId The workflow instance identifier * - * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the stopped workflow instance.}'] + * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the stopped workflow instance.}'] */ public function stop($instanceId) { @@ -338,7 +250,7 @@ public function stop($instanceId) * * @param string $identifier The workflow instance identifier * - * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the suspended workflow instance.}'] + * @return array the response result ['code' => 200, 'body' => '{An XML (as text) representation of the suspended workflow instance.}'] */ public function suspend($instanceId) { @@ -371,4 +283,4 @@ public function update($workflow) return $this->restClient->performPost($uri, $options); } } -?> \ No newline at end of file +?> diff --git a/tests/Unit/OcWorkflowTest.php b/tests/Unit/OcWorkflowTest.php index 796002e..a355a5f 100644 --- a/tests/Unit/OcWorkflowTest.php +++ b/tests/Unit/OcWorkflowTest.php @@ -50,16 +50,6 @@ public function getters_test(): void $responseGetStateMappings = $this->ocWorkflow->getStateMappings(); $this->assertSame(200, $responseGetStateMappings['code'], 'Failure to get State Mappings'); - // Get statistics @depricated - // $responseGetStatistics = $this->ocWorkflow->getStatistics(); - // $this->assertSame(200, $responseGetStatistics['code'], 'Failure to get statistics'); - - // Get All Instances @depricated - // $responseGetInstances = $this->ocWorkflow->getInstances(); - // $this->assertSame(200, $responseGetInstances['code'], 'Failure to get workflow Instances'); - // $instances = $responseGetInstances['body']->workflows->workflow; - // $this->assertNotEmpty($instances); - // Get Single Instance $dummyInstanceId = 1234567890; $responseGetInstance = $this->ocWorkflow->getInstance($dummyInstanceId);