-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fixTimeoutDataverse330-697' into 'stable-3_3_0'
Resolve problemas de quando Dataverse excede tempo de resposta - 330 See merge request softwares-pkp/plugins_ojs/dataverse!167
- Loading branch information
Showing
20 changed files
with
550 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
import('lib.pkp.classes.handler.APIHandler'); | ||
import('plugins.generic.dataverse.dataverseAPI.DataverseClient'); | ||
|
||
class DataverseHandler extends APIHandler | ||
{ | ||
public function __construct() | ||
{ | ||
$this->_handlerPath = 'dataverse'; | ||
$roles = [ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_AUTHOR]; | ||
$this->_endpoints = array( | ||
'GET' => array( | ||
array( | ||
'pattern' => $this->getEndpointPattern() . '/dataverseName', | ||
'handler' => array($this, 'getDataverseName'), | ||
'roles' => $roles | ||
), | ||
array( | ||
'pattern' => $this->getEndpointPattern() . '/rootDataverseName', | ||
'handler' => array($this, 'getRootDataverseName'), | ||
'roles' => $roles | ||
), | ||
array( | ||
'pattern' => $this->getEndpointPattern() . '/licenses', | ||
'handler' => array($this, 'getDataverseLicenses'), | ||
'roles' => $roles | ||
), | ||
), | ||
); | ||
parent::__construct(); | ||
} | ||
|
||
public function authorize($request, &$args, $roleAssignments) | ||
{ | ||
import('lib.pkp.classes.security.authorization.PolicySet'); | ||
$rolePolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES); | ||
|
||
import('lib.pkp.classes.security.authorization.RoleBasedHandlerOperationPolicy'); | ||
foreach ($roleAssignments as $role => $operations) { | ||
$rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations)); | ||
} | ||
$this->addPolicy($rolePolicy); | ||
|
||
return parent::authorize($request, $args, $roleAssignments); | ||
} | ||
|
||
public function getDataverseName($slimRequest, $response, $args) | ||
{ | ||
try { | ||
$dataverseClient = new DataverseClient(); | ||
$dataverseCollection = $dataverseClient->getDataverseCollectionActions()->get(); | ||
$dataverseName = $dataverseCollection->getName(); | ||
|
||
return $response->withJson(['dataverseName' => $dataverseName], 200); | ||
} catch (DataverseException $e) { | ||
error_log('Dataverse API error while getting dataverse name: ' . $e->getMessage()); | ||
return $response->withStatus($e->getCode()); | ||
} | ||
} | ||
|
||
public function getRootDataverseName($slimRequest, $response, $args) | ||
{ | ||
try { | ||
$dataverseClient = new DataverseClient(); | ||
$rootDataverseCollection = $dataverseClient->getDataverseCollectionActions()->getRoot(); | ||
$rootDataverseName = $rootDataverseCollection->getName(); | ||
|
||
return $response->withJson(['rootDataverseName' => $rootDataverseName], 200); | ||
} catch (DataverseException $e) { | ||
error_log('Dataverse API error while getting root name: ' . $e->getMessage()); | ||
return $response->withStatus($e->getCode()); | ||
} | ||
} | ||
|
||
public function getDataverseLicenses($slimRequest, $response, $args) | ||
{ | ||
try { | ||
$dataverseClient = new DataverseClient(); | ||
$dataverseLicenses = $dataverseClient->getDataverseCollectionActions()->getLicenses(); | ||
|
||
return $response->withJson(['licenses' => $dataverseLicenses], 200); | ||
} catch (DataverseException $e) { | ||
error_log('Dataverse API error while getting licenses: ' . $e->getMessage()); | ||
return $response->withStatus($e->getCode()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.