Commit 9d79814b authored by Stefan Froemken's avatar Stefan Froemken

Move exception classes to namespace versins

parent 79a4bb95
Pipeline #2243 passed with stages
in 1 minute and 27 seconds
<?php
/**
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
......@@ -12,6 +14,7 @@
*
* The TYPO3 project - inspiring people to share!
*/
class tx_ter_exception extends Exception
{
class Exception extends \Exception {
}
<?php
/**
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
......@@ -12,9 +15,6 @@
* The TYPO3 project - inspiring people to share!
*/
/**
* an exception when user authentication is required (HTTP-Status-Code 401)
*/
class tx_ter_exception_unauthorized extends tx_ter_exception
{
class FailedDependencyException extends Exception {
}
<?php
/**
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
......@@ -12,9 +15,6 @@
* The TYPO3 project - inspiring people to share!
*/
/**
* Exception reflecting that version exists in repository (HTTP error code 424)
*/
class tx_ter_exception_versionExists extends tx_ter_exception
{
class InternalServerErrorException extends Exception {
}
<?php
/**
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
......@@ -12,9 +15,6 @@
* The TYPO3 project - inspiring people to share!
*/
/**
* Exception reflecting that required dependencies are not met (HTTP error code 424)
*/
class tx_ter_exception_failedDependency extends tx_ter_exception
{
class NotFoundException extends Exception {
}
<?php
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
class UnauthorizedException extends Exception {
}
<?php
namespace T3o\Ter\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
class VersionExistsException extends Exception {
}
......@@ -31,7 +31,6 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.p
*/
class tx_ter_api
{
/**
* @var tx_ter_helper
*/
......@@ -116,7 +115,8 @@ class tx_ter_api
* @param array $filesData : The array of file data objects as received by the SOAP server
*
* @return object uploadExtensionResult object if upload was successful, otherwise an exception is thrown.
* @throws tx_ter_exception
* @throws \T3o\Ter\Exception\Exception
* @throws \T3o\Ter\Exception\VersionExistsException
* @access public
* @since 2.0.0
*/
......@@ -146,18 +146,18 @@ class tx_ter_api
$uploadUserRecordArr = $this->helperObj->getValidUser($accountData);
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
if ($extensionKeyRecordArr == false) {
throw new tx_ter_exception_notFound('Extension "' . $extensionKey . '" does not exist.', TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONDOESNTEXIST);
throw new \T3o\Ter\Exception\NotFoundException('Extension "' . $extensionKey . '" does not exist.', TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONDOESNTEXIST);
}
if (strtolower($extensionKeyRecordArr['ownerusername']) !== strtolower(
$accountData->username
) && $uploadUserRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED);
}
// check for a valid version number
if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $extensionInfoData->version) == false) {
throw new tx_ter_exception(
throw new \T3o\Ter\Exception\Exception(
'Your version number "' . htmlspecialchars(
$extensionInfoData->version
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".',
......@@ -166,7 +166,7 @@ class tx_ter_api
}
if ($this->checkUploadedExtensionVersionExistsInRepository($extensionInfoData)) {
throw new tx_ter_exception_versionExists(
throw new \T3o\Ter\Exception\VersionExistsException(
'Version number ' . $extensionInfoData->version . ' already exists in repository.',
TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONVERSIONEXISTS
);
......@@ -182,7 +182,7 @@ class tx_ter_api
$message = 'Check on dependency for a supported version of TYPO3 failed due to technical reasons';
break;
}
throw new tx_ter_exception_failedDependency($message, $typo3DependencyCheck);
throw new \T3o\Ter\Exception\FailedDependencyException($message, $typo3DependencyCheck);
}
$this->uploadExtension_writeExtensionAndIconFile($extensionInfoData, $filesData);
......@@ -221,6 +221,10 @@ class tx_ter_api
* @param array $filesData The array of file data objects
*
* @return boolean TRUE on success
*
* @throws \T3o\Ter\Exception\Exception
* @throws \T3o\Ter\Exception\NotFoundException
* @throws \T3o\Ter\Exception\UnauthorizedException
*/
public static function uploadExtensionWithoutSoap($username, $extensionInfoData, $filesData)
{
......@@ -237,15 +241,15 @@ class tx_ter_api
// Load extension
$extensionKeyRecordArr = $instance->helperObj->getExtensionKeyRecord(strtolower($extensionInfoData->extensionKey));
if ($extensionKeyRecordArr == false) {
throw new tx_ter_exception_notFound('Extension does not exist.', TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONDOESNTEXIST);
throw new \T3o\Ter\Exception\NotFoundException('Extension does not exist.', TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONDOESNTEXIST);
}
if (strtolower($extensionKeyRecordArr['ownerusername']) !== strtolower($username)) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED);
}
// check for a valid version number
if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $extensionInfoData->version) == false) {
throw new tx_ter_exception(
throw new \T3o\Ter\Exception\Exception(
'Your version number "' . htmlspecialchars(
$extensionInfoData->version
) . '" is invalid. Allowed are three numbers with maximum 999, e.g. "7.8.999".',
......@@ -264,7 +268,7 @@ class tx_ter_api
$message = 'Check on dependency for a supported version of TYPO3 failed due to technical reasons';
break;
}
throw new tx_ter_exception($message, $typo3DependencyCheck);
throw new \T3o\Ter\Exception\Exception($message, $typo3DependencyCheck);
}
// Upload...
$instance->uploadExtension_writeExtensionAndIconFile($extensionInfoData, $filesData);
......@@ -284,8 +288,8 @@ class tx_ter_api
* @param string $version : Version string of the extension version to delete
*
* @return object simpleResult object if extension could be deleted, otherwise an exception is thrown.
* @throws tx_ter_exception_unauthorized
* @throws tx_ter_exception_notFound
* @throws \T3o\Ter\Exception\UnauthorizedException
* @throws \T3o\Ter\Exception\NotFoundException
* @access public
* @since 2.0.1
*/
......@@ -302,14 +306,14 @@ class tx_ter_api
$userRecordArr = $this->helperObj->getValidUser($accountData);
if ($userRecordArr['admin'] !== true) {
throw new tx_ter_exception_unauthorized(
throw new \T3o\Ter\Exception\UnauthorizedException(
'Access denied. You must be administrator in order to delete extensions',
TX_TER_ERROR_DELETEEXTENSION_ACCESS_DENIED
);
}
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
if ($extensionKeyRecordArr == false) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'Extension does not exist.',
TX_TER_ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
);
......@@ -445,7 +449,7 @@ class tx_ter_api
}
$resultCode = TX_TER_RESULT_GENERAL_OK;
} else {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while fetching extension keys.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -469,8 +473,8 @@ class tx_ter_api
* @return object simpleResponse-object. An exception is thrown if a fatal error ocurred.
* @access public
* @since 2.0.0
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_unauthorized
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\UnauthorizedException
*/
public function deleteExtensionKey($accountData, $extensionKey)
{
......@@ -482,7 +486,7 @@ class tx_ter_api
$accountData->username
) && $userRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_DELETEEXTENSIONKEY_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_DELETEEXTENSIONKEY_ACCESSDENIED);
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
......@@ -506,7 +510,7 @@ class tx_ter_api
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while deleting extension key.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -516,7 +520,7 @@ class tx_ter_api
$this->notifyExtensionKeyDelete($extensionKey);
}
} else {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while fetching versions.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -551,7 +555,7 @@ class tx_ter_api
* @return object simpleResponse-object. An exception is thrown if a fatal error ocurred.
* @access public
* @since 2.0.0
* @throws tx_ter_exception_unauthorized
* @throws \T3o\Ter\Exception\UnauthorizedException
*/
public function modifyExtensionKey($accountData, $modifyExtensionKeyData)
{
......@@ -563,7 +567,7 @@ class tx_ter_api
$accountData->username
) && $userRecordArr['admin'] !== true
) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_MODIFYEXTENSIONKEY_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_MODIFYEXTENSIONKEY_ACCESSDENIED);
}
$resultCode = $this->modifyExtensionKey_writeModifiedKeyRecordIntoDB($accountData, $modifyExtensionKeyData);
$this->helperObj->requestUpdateOfExtensionIndexFile();
......@@ -585,8 +589,8 @@ class tx_ter_api
*
* @return array simpleResponse-object. An exception is thrown if a fatal error ocurred.
* @access public
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_unauthorized
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\UnauthorizedException
* @since 2.0.0
*/
public function setReviewState($accountData, $setReviewStateData)
......@@ -595,13 +599,13 @@ class tx_ter_api
$reviewersFrontendUsergroupUid = (int)$this->parentObj->conf['reviewersFrontendUsergroupUid'];
if ($reviewersFrontendUsergroupUid == 0) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Warning: No usergroup for reviewers has been defined on the server side. Aborting ...',
TX_TER_ERROR_SETREVIEWSTATE_NOUSERGROUPDEFINED
);
}
if (!GeneralUtility::inList($userRecordArr['usergroup'], $reviewersFrontendUsergroupUid)) {
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_SETREVIEWSTATE_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_SETREVIEWSTATE_ACCESSDENIED);
}
$this->setReviewState_writeNewStateIntoDB($setReviewStateData);
......@@ -623,8 +627,8 @@ class tx_ter_api
*
* @return object simpleResponse-object. An exception is thrown if a fatal error ocurred.
* @access public
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_unauthorized
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\UnauthorizedException
* @since 2.0.0
*/
public function increaseExtensionDownloadCounters($accountData, $extensionVersionsAndIncrementors)
......@@ -648,7 +652,7 @@ class tx_ter_api
'tx_ter_api',
3
);
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Warning: No usergroup for mirrors has been defined on the server side. Aborting ...',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_NOUSERGROUPDEFINED
);
......@@ -660,7 +664,7 @@ class tx_ter_api
3,
$userRecordArr
);
throw new tx_ter_exception_unauthorized('Access denied.', TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_ACCESSDENIED);
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_ACCESSDENIED);
}
$counter = 0;
......@@ -669,7 +673,7 @@ class tx_ter_api
try {
$this->increaseExtensionDownloadCounter_increaseCounterInDB($extensionVersionAndIncrementor);
$counter++;
} catch (tx_ter_exception $exception) {
} catch (Exception $exception) {
$errorMessages[] = '[' . $extensionVersionAndIncrementor->extensionKey . '][' . $extensionVersionAndIncrementor->version . '] ' . $exception->faultstring;
}
}
......@@ -678,7 +682,7 @@ class tx_ter_api
$extensionVersionAndIncrementor = $extensionVersionsAndIncrementors->extensionVersionAndIncrementor;
$this->increaseExtensionDownloadCounter_increaseCounterInDB($extensionVersionAndIncrementor);
$counter++;
} catch (tx_ter_exception $exception) {
} catch (Exception $exception) {
$errorMessages[] = '[' . $extensionVersionAndIncrementor->extensionKey . '][' . $extensionVersionAndIncrementor->version . '] ' . $exception->faultstring;
}
}
......@@ -741,20 +745,20 @@ class tx_ter_api
* @param object $filesData : The array of file data objects as received by the SOAP server
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_notFound
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
*/
public function uploadExtension_writeExtensionAndIconFile(&$extensionInfoData, $filesData)
{
if (!@is_dir($this->parentObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
}
if (!is_array($filesData->fileData)) {
throw new tx_ter_exception_notFound('Extension contains no files.', TX_TER_ERROR_GENERAL_EXTENSIONCONTAINSNOFILES);
throw new \T3o\Ter\Exception\NotFoundException('Extension contains no files.', TX_TER_ERROR_GENERAL_EXTENSIONCONTAINSNOFILES);
}
// Prepare Files Data Array:
......@@ -762,7 +766,7 @@ class tx_ter_api
foreach ($filesData->fileData as $fileData) {
$decodedContent = base64_decode($fileData->content);
if ($fileData->contentMD5 != md5($decodedContent)) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'MD5 does not match for file ' . (string)$fileData->name,
TX_TER_ERROR_UPLOADEXTENSION_FILEMD5DOESNOTMATCH
);
......@@ -837,7 +841,7 @@ class tx_ter_api
// Check if size of t3x file is too big:
if (strlen($t3xFileData) > $this->extensionMaxUploadSize) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'The extension size exceeded ' . $this->extensionMaxUploadSize . ' bytes which is the maximum for extension uploads.',
TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONTOOBIG
);
......@@ -864,7 +868,7 @@ class tx_ter_api
// Write the files
$fh = @fopen($fullPath . $t3xFileName, 'wb');
if (!$fh) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing .t3x file: ' . $fullPath . $t3xFileName,
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGFILES
);
......@@ -1051,13 +1055,13 @@ class tx_ter_api
* @param string $version : Version number of the extension to delete
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected
*/
protected function deleteExtension_deleteFromDBAndRemoveFiles($extensionKey, $version)
{
if (!@is_dir($this->parentObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
......@@ -1075,14 +1079,14 @@ class tx_ter_api
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
);
if (!$result) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while selecting extension for deletion. (extensionkey: ' . $extensionKey . ' version: ' . $version . ')',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
$extensionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
if (!(int)$extensionRow['uid']) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'deleteExtension_deleteFromDBAndRemoveFiles: Extension does not exist. (extensionkey: ' . $extensionKey . ' version: ' . $version . ')',
TX_TER_ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
);
......@@ -1093,7 +1097,7 @@ class tx_ter_api
'extensionuid = ' . (int)$extensionRow['uid']
);
if (!$result) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while deleting extension details for (extensionkey: ' . $extensionKey . ' uid: ' . $extensionRow['uid'] . ')',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1106,7 +1110,7 @@ class tx_ter_api
) . ' AND version=' . $GLOBALS['TYPO3_DB']->fullquoteStr($version, 'tx_ter_extensions')
);
if (!$result) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while deleting extension. (extensionkey: ' . $extensionKey . ' version: ' . $version . ')',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1333,7 +1337,7 @@ class tx_ter_api
* @param object $extensionKeyData : The extension key and other information
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected
*/
protected function registerExtensionKey_writeExtensionKeyInfoToDB($accountData, $extensionKeyData)
......@@ -1350,7 +1354,7 @@ class tx_ter_api
];
$result = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_ter_extensionkeys', $extensionKeysRow);
if (!$result) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while inserting extension key.',
TX_TER_ERROR_REGISTEREXTENSIONKEY_DBERRORWHILEINSERTINGKEY
);
......@@ -1374,7 +1378,7 @@ class tx_ter_api
* @param object $modifyExtensionKeyData : The extension key field which shall be updated
*
* @return integer the result TER result code
* @throws tx_ter_exception_internalServerError
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected
*/
protected function modifyExtensionKey_writeModifiedKeyRecordIntoDB($accountData, $modifyExtensionKeyData)
......@@ -1404,7 +1408,7 @@ class tx_ter_api
$updateValues
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while updating extension key.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1429,8 +1433,8 @@ class tx_ter_api
* @param object $setReviewStateData : Extension key, version number and the new state
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_notFound
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
*/
protected function setReviewState_writeNewStateIntoDB($setReviewStateData)
......@@ -1444,13 +1448,13 @@ class tx_ter_api
) . ' AND ' . 'version =' . $GLOBALS['TYPO3_DB']->fullQuoteStr($setReviewStateData->version, 'tx_ter_extensions')
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while searching for extension record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'Extension version does not exist.',
TX_TER_ERROR_SETREVIEWSTATE_EXTENSIONVERSIONDOESNOTEXIST
);
......@@ -1465,7 +1469,7 @@ class tx_ter_api
['reviewstate' => (int)$setReviewStateData->reviewState]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while updating extension review state.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1489,8 +1493,8 @@ class tx_ter_api
* @param object $extensionVersionDataAndIncrementor : Extension key and version number and the download count incrementor
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws tx_ter_exception_notFound
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
*/
protected function increaseExtensionDownloadCounter_increaseCounterInDB($extensionVersionDataAndIncrementor)
......@@ -1507,13 +1511,13 @@ class tx_ter_api
)
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while searching for extension record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'Extension version does not exist.',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONVERSIONDOESNOTEXIST
);
......@@ -1522,7 +1526,7 @@ class tx_ter_api
$currentRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
$incrementor = (int)$extensionVersionDataAndIncrementor->downloadCountIncrementor;
if ($incrementor !== abs($incrementor)) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'The incrementor must be a positive integer value.',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_INCREMENTORNOTPOSITIVEINTEGER
);
......@@ -1535,7 +1539,7 @@ class tx_ter_api
['downloadcounter' => $newCounter]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while updating extension download counter.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1550,13 +1554,13 @@ class tx_ter_api
)
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while searching for extension key record.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
}
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) != 1) {
throw new tx_ter_exception_notFound(
throw new \T3o\Ter\Exception\NotFoundException(
'Extension key does not exist.',
TX_TER_ERROR_INCREASEEXTENSIONDOWNLOADCOUNTER_EXTENSIONKEYDOESNOTEXIST
);
......@@ -1571,7 +1575,7 @@ class tx_ter_api
['downloadcounter' => $newCounter]
);
if (!$res) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Database error while updating extension total download counter.',
TX_TER_ERROR_GENERAL_DATABASEERROR
);
......@@ -1661,7 +1665,7 @@ class tx_ter_api
* @param string $fullPath The full path to the image folder
*
* @return void
* @throws tx_ter_exception_internalServerError
* @throws \T3o\Ter\Exception\InternalServerErrorException
*/
protected function saveImages(&$preparedFilesDataArr, $imageBaseName, $fullPath)
{
......@@ -1684,7 +1688,7 @@ class tx_ter_api
if (strlen($imageData)) {
$fh = @fopen($fullPath . $imagePath, 'wb');
if (!$fh) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing file: ' . $fullPath . $imagePath,
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGFILES
);
......
......@@ -131,11 +131,12 @@ class tx_ter_helper
* @param object $accountData : Account data information with username, password and upload password
* @return mixed If success, returns array of fe_users, otherwise error string.
* @access public
* @throws \T3o\Ter\Exception\UnauthorizedException
*/
public function getValidUser($accountData)
{
if (!strlen($accountData->username) || (!strlen($accountData->password))) {
throw new tx_ter_exception_unauthorized('No user or no password submitted.', TX_TER_ERROR_GENERAL_NOUSERORPASSWORD);
throw new \T3o\Ter\Exception\UnauthorizedException('No user or no password submitted.', TX_TER_ERROR_GENERAL_NOUSERORPASSWORD);
}
$res = $this->getDatabaseConnection()->exec_SELECTquery(
......@@ -149,10 +150,10 @@ class tx_ter_helper
if (!$this->userIsAlreadyLoggedIn( $accountData
) && !$this->ldapValidationSucceeded($accountData)
) {
throw new tx_ter_exception_unauthorized ('Wrong password.', TX_TER_ERROR_GENERAL_WRONGPASSWORD);
throw new \T3o\Ter\Exception\UnauthorizedException('Wrong password.', TX_TER_ERROR_GENERAL_WRONGPASSWORD);
}
} else {
throw new tx_ter_exception_unauthorized('The specified user does not exist. You need to login first on extensions.typo3.org.', TX_TER_ERROR_GENERAL_USERNOTFOUND);
throw new \T3o\Ter\Exception\UnauthorizedException('The specified user does not exist. You need to login first on extensions.typo3.org.', TX_TER_ERROR_GENERAL_USERNOTFOUND);
}
$row['admin'] = (intval($this->pluginObj->conf['adminFrontendUsergroupUid']) && GeneralUtility::inList(
......@@ -341,12 +342,13 @@ class tx_ter_helper
*
* @return void
* @access public
* @throws \T3o\Ter\Exception\InternalServerErrorException
*/
public function writeExtensionIndexfile()
{
GeneralUtility::devLog('writing extension index!', 'tx_ter_helper', 0);
if (!@is_dir($this->pluginObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
......@@ -452,7 +454,7 @@ class tx_ter_helper
// Write XML data to disk:
$fh = fopen($this->pluginObj->repositoryDir . 'new-extensions.xml.gz', 'wb');
if (!$fh) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing extensions index file: ' . $this->pluginObj->repositoryDir . 'extensions.xml',
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGEXTENSIONSINDEX
);
......@@ -462,7 +464,7 @@ class tx_ter_helper
if (!@filesize($this->pluginObj->repositoryDir . 'new-extensions.xml.gz') > 0) {
GeneralUtility::devLog('Newly created extension index is zero bytes!', 'tx_ter_helper', 0);
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing extensions index file (zero bytes): ' . $this->pluginObj->repositoryDir . 'extensions.xml',
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGEXTENSIONSINDEX
);
......@@ -479,7 +481,7 @@ class tx_ter_helper
// Write serialized array file to disk:
$fh = fopen($this->pluginObj->repositoryDir . 'new-extensions.bin', 'wb');
if (!$fh) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing extensions index file: ' . $this->pluginObj->repositoryDir . 'extensions.bin',
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGEXTENSIONSINDEX
);
......@@ -489,7 +491,7 @@ class tx_ter_helper
if (!@filesize($this->pluginObj->repositoryDir . 'new-extensions.bin') > 0) {
GeneralUtility::devLog('Newly created extension index is zero bytes!', 'tx_ter_helper', 0);
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Write error while writing extensions index file (zero bytes): ' . $this->pluginObj->repositoryDir . 'extensions.bin',
TX_TER_ERROR_UPLOADEXTENSION_WRITEERRORWHILEWRITINGEXTENSIONSINDEX
);
......
......@@ -497,13 +497,14 @@ function versionConv($input, $rev = false)
*
* @return void
* @access public
* @throws \T3o\Ter\Exception\InternalServerErrorException
*/
function writeExtensionIndexfile()
{
global $TYPO3_DB;
if (!@is_dir($GLOBALS['repositoryDir'])) {
throw new tx_ter_exception_internalServerError(
throw new \T3o\Ter\Exception\InternalServerErrorException(
'Extension repository directory does not exist.',
TX_TER_ERROR_GENERAL_EXTREPDIRDOESNTEXIST
);
......@@ -580,7 +581,7 @@ function writeExtensionIndexfile()
// Write XML data to disc:
$fh = fopen(