Skip to content

Commit

Permalink
pkp#20 Added missing errors with meaningful error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jan 16, 2023
1 parent f58a05f commit 2492ab3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 29 deletions.
66 changes: 38 additions & 28 deletions classes/DepositPackage.inc.php
Expand Up @@ -443,15 +443,15 @@ public function transferDeposit() {
if ($this->_deposit->getLockssAgreementStatus()) {
$url .= PLN_PLUGIN_CONT_IRI . '/' . $plnPlugin->getSetting($journalId, 'journal_uuid');
$url .= '/' . $this->_deposit->getUUID() . '/edit';
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.postAtom',
array('depositId' => $this->_deposit->getId(),
'statusLocal' => $this->_deposit->getLocalStatus(),
'statusProcessing' => $this->_deposit->getProcessingStatus(),

$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.postAtom',
array('depositId' => $this->_deposit->getId(),
'statusLocal' => $this->_deposit->getLocalStatus(),
'statusProcessing' => $this->_deposit->getProcessingStatus(),
'statusLockss' => $this->_deposit->getLockssStatus(),
'url' => $url,
'atomPath' => $atomPath,
'method' => 'PutFile')),
'method' => 'PutFile')),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$result = $plnPlugin->curlPutFile(
Expand All @@ -461,14 +461,14 @@ public function transferDeposit() {
} else {
$url .= PLN_PLUGIN_COL_IRI . '/' . $plnPlugin->getSetting($journalId, 'journal_uuid');

$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.postAtom',
array('depositId' => $this->_deposit->getId(),
'statusLocal' => $this->_deposit->getLocalStatus(),
'statusProcessing' => $this->_deposit->getProcessingStatus(),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.postAtom',
array('depositId' => $this->_deposit->getId(),
'statusLocal' => $this->_deposit->getLocalStatus(),
'statusProcessing' => $this->_deposit->getProcessingStatus(),
'statusLockss' => $this->_deposit->getLockssStatus(),
'url' => $url,
'atomPath' => $atomPath,
'method' => 'PostFile')),
'method' => 'PostFile')),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$result = $plnPlugin->curlPostFile(
Expand All @@ -479,8 +479,8 @@ public function transferDeposit() {

// if we get the OK, set the status as transferred
if (($result['status'] == PLN_PLUGIN_HTTP_STATUS_OK) || ($result['status'] == PLN_PLUGIN_HTTP_STATUS_CREATED)) {
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultSucceeded',
array('depositId' => $this->_deposit->getId())),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultSucceeded',
array('depositId' => $this->_deposit->getId())),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$this->_deposit->setTransferredStatus();
Expand All @@ -493,20 +493,20 @@ public function transferDeposit() {
} else {
// we got an error back from the staging server
if($result['status'] == FALSE) {
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultFailed',
array('depositId' => $this->_deposit->getId(),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultFailed',
array('depositId' => $this->_deposit->getId(),
'error' => $result['error'],
'result' => $result['result'])),
'result' => $result['result'])),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$this->_logMessage(__('plugins.generic.pln.error.network.deposit', array('error' => $result['error'])));

$this->_deposit->setExportDepositError(__('plugins.generic.pln.error.network.deposit', array('error' => $result['error'])));
} else {
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultFailed',
array('depositId' => $this->_deposit->getId(),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.transferringdeposits.processing.resultFailed',
array('depositId' => $this->_deposit->getId(),
'error' => $result['status'],
'result' => $result['result'])),
'result' => $result['result'])),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$this->_logMessage(__('plugins.generic.pln.error.http.deposit', array('error' => $result['status'])));
Expand Down Expand Up @@ -548,8 +548,8 @@ public function packageDeposit() {
}

if (!$fileManager->fileExists($packagePath)) {
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageFailed',
array('depositId' => $this->_deposit->getId())),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageFailed',
array('depositId' => $this->_deposit->getId())),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$this->_deposit->setPackagedStatus(false);
Expand All @@ -559,8 +559,8 @@ public function packageDeposit() {
}

if (!$fileManager->fileExists($this->generateAtomDocument())) {
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageFailed',
array('depositId' => $this->_deposit->getId())),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageFailed',
array('depositId' => $this->_deposit->getId())),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

$this->_deposit->setPackagedStatus(false);
Expand All @@ -569,8 +569,8 @@ public function packageDeposit() {
return;
}

$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageSucceeded',
array('depositId' => $this->_deposit->getId())),
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.packagingdeposits.processing.packageSucceeded',
array('depositId' => $this->_deposit->getId())),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

// update the deposit's status
Expand Down Expand Up @@ -611,9 +611,9 @@ public function updateDepositStatus() {

// get the remote deposit state
$processingState = $contentDOM->getElementsByTagName('category')->item(0)->getAttribute('term');
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.statusupdates.processing.processingState',
$this->_task->addExecutionLogEntry(__('plugins.generic.pln.depositor.statusupdates.processing.processingState',
array('depositId' => $this->_deposit->getId(),
'processingState' => $processingState)),
'processingState' => $processingState)),
SCHEDULED_TASK_MESSAGE_TYPE_NOTICE);

switch ($processingState) {
Expand All @@ -628,12 +628,22 @@ public function updateDepositStatus() {
break;
case 'bag-validated':
case 'reserialized':
case 'hold':
$this->_deposit->setValidatedStatus(true);
break;
case 'deposited':
$this->_deposit->setSentStatus(true);
break;
case 'hold':
case 'harvest-error':
case 'deposit-error':
case 'reserialize-error':
case 'virus-error':
case 'xml-error':
case 'payload-error':
case 'bag-error':
case 'status-error':
$this->_deposit->setExportDepositError(__('plugins.generic.pln.status.error.' . $processingState));
break;
default:
$this->_deposit->setExportDepositError('Unknown processing state ' . $processingState);
$this->_logMessage('Deposit ' . $this->_deposit->getId() . ' has unknown processing state ' . $processingState);
Expand Down
26 changes: 26 additions & 0 deletions locale/en_US/locale.po
Expand Up @@ -296,3 +296,29 @@ msgstr "Latest Update"
msgid "plugins.generic.pln.status.description.title"
msgstr "Status Description"

msgid "plugins.generic.pln.status.error.harvest-error"
msgstr "Failed to download the deposit from your system. The operation will be retried, meanwhile, you may check if your system is behind a firewall"

msgid "plugins.generic.pln.status.error.deposit-error"
msgstr "Deposit failed, ensure it didn't exceed the maximum size supported by the Preservation Network"

msgid "plugins.generic.pln.status.error.reserialize-error"
msgstr "Deposit repackaging failed, the operation will be retried"

msgid "plugins.generic.pln.status.error.virus-error"
msgstr "The deposit didn't pass the anti-virus check, you should inspect its files, and resend"

msgid "plugins.generic.pln.status.error.xml-error"
msgstr "The deposit didn't pass the content validation, you may try to resend the deposit"

msgid "plugins.generic.pln.status.error.payload-error"
msgstr "The deposit didn't pass the payload validation, you may try to resend the deposit"

msgid "plugins.generic.pln.status.error.bag-error"
msgstr "The deposit didn't pass the bag validation, you may try to resend the deposit"

msgid "plugins.generic.pln.status.error.status-error"
msgstr "The deposit is being preserved, but it wasn't possible to check its status, the operation will be retried"

msgid "plugins.generic.pln.status.error.hold"
msgstr "The deposit has been withheld, the version of your system is above its expectations"
2 changes: 1 addition & 1 deletion xml/scheduledTasks.xml
Expand Up @@ -21,7 +21,7 @@

<scheduled_tasks>
<task class="plugins.generic.pln.classes.tasks.Depositor">
<descr>Deposit content with the PLN</descr>
<descr>Deposit content with the PKP Preservation Network</descr>
<frequency hour="0"/>
<arg>autoStage</arg>
</task>
Expand Down

0 comments on commit 2492ab3

Please sign in to comment.