mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Add error pages, fix error handling and PHP conf
This commit is contained in:
@@ -73,7 +73,8 @@ use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
|
||||
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
|
||||
use Alchemy\Phrasea\Controller\User\Notifications;
|
||||
use Alchemy\Phrasea\Controller\User\Preferences;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\Logout;
|
||||
use Alchemy\Phrasea\Core\PhraseaExceptionHandler;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\LogoutSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaLocaleSubscriber;
|
||||
use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider;
|
||||
use Alchemy\Phrasea\Core\Provider\BrowserServiceProvider;
|
||||
@@ -121,7 +122,6 @@ use Silex\Provider\SwiftmailerServiceProvider;
|
||||
use Silex\Provider\UrlGeneratorServiceProvider;
|
||||
use Silex\Provider\ValidatorServiceProvider;
|
||||
use Silex\Provider\ServiceControllerServiceProvider;
|
||||
use Silex\Provider\WebProfilerServiceProvider;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Unoconv\UnoconvServiceProvider;
|
||||
@@ -155,34 +155,25 @@ class Application extends SilexApplication
|
||||
private $environment;
|
||||
private $sessionCookieEnabled = true;
|
||||
|
||||
const ENV_DEV = 'dev';
|
||||
const ENV_PROD = 'prod';
|
||||
const ENV_TEST = 'test';
|
||||
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->environment;
|
||||
}
|
||||
|
||||
public function __construct($environment = 'prod')
|
||||
public function __construct($environment = self::ENV_PROD)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
$this['root.path'] = realpath(__DIR__ . '/../../..');
|
||||
$this->environment = $environment;
|
||||
|
||||
if ((int) ini_get('memory_limit') < 2048) {
|
||||
ini_set('memory_limit', '2048M');
|
||||
}
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
ini_set('display_errors', 'on');
|
||||
ini_set('output_buffering', '4096');
|
||||
ini_set('default_charset', 'UTF-8');
|
||||
ini_set('session.use_cookies', '1');
|
||||
ini_set('session.use_only_cookies', '1');
|
||||
ini_set('session.auto_start', '0');
|
||||
ini_set('session.hash_function', '1');
|
||||
ini_set('session.hash_bits_per_character', '6');
|
||||
ini_set('session.cache_limiter', '');
|
||||
ini_set('allow_url_fopen', 'on');
|
||||
mb_internal_encoding("UTF-8");
|
||||
|
||||
!defined('JETON_MAKE_SUBDEF') ? define('JETON_MAKE_SUBDEF', 0x01) : '';
|
||||
@@ -193,17 +184,12 @@ class Application extends SilexApplication
|
||||
$this['charset'] = 'UTF-8';
|
||||
|
||||
$this['debug'] = $this->share(function(Application $app) {
|
||||
return $app->getEnvironment() !== 'prod';
|
||||
return Application::ENV_PROD !== $app->getEnvironment();
|
||||
});
|
||||
|
||||
if ($this['debug'] === true) {
|
||||
ini_set('display_errors', 'on');
|
||||
if ($this->getEnvironment() === 'dev') {
|
||||
ini_set('log_errors', 'on');
|
||||
ini_set('error_log', __DIR__ . '/../../../logs/php_error.log');
|
||||
}
|
||||
} else {
|
||||
ini_set('display_errors', 'off');
|
||||
ini_set('error_log', $this['root.path'] . '/logs/php_error.log');
|
||||
}
|
||||
|
||||
$this->register(new AuthenticationManagerServiceProvider());
|
||||
@@ -263,7 +249,7 @@ class Application extends SilexApplication
|
||||
|
||||
$this->register(new SearchEngineServiceProvider());
|
||||
$this->register(new SessionServiceProvider(), array(
|
||||
'session.test' => $this->getEnvironment() == 'test'
|
||||
'session.test' => $this->getEnvironment() === static::ENV_TEST
|
||||
));
|
||||
$this->register(new ServiceControllerServiceProvider());
|
||||
$this->register(new SwiftmailerServiceProvider());
|
||||
@@ -272,7 +258,7 @@ class Application extends SilexApplication
|
||||
$this->register(new TokensServiceProvider());
|
||||
$this->register(new TwigServiceProvider(), array(
|
||||
'twig.options' => array(
|
||||
'cache' => realpath(__DIR__ . '/../../../tmp/cache_twig/'),
|
||||
'cache' => $this['root.path'] . '/tmp/cache_twig/',
|
||||
),
|
||||
'twig.form.templates' => array('login/common/form_div_layout.html.twig')
|
||||
));
|
||||
@@ -285,19 +271,14 @@ class Application extends SilexApplication
|
||||
$this->register(new UnicodeServiceProvider());
|
||||
$this->register(new ValidatorServiceProvider());
|
||||
|
||||
if ('dev' === $this->environment) {
|
||||
$this->register($p = new WebProfilerServiceProvider(), array(
|
||||
'profiler.cache_dir' => __DIR__ . '/../../../tmp/cache/profiler',
|
||||
));
|
||||
$this->mount('/_profiler', $p);
|
||||
}
|
||||
|
||||
$this->register(new XPDFServiceProvider());
|
||||
|
||||
$this['phraseanet.exception_handler'] = $this->share(function ($app) {
|
||||
return PhraseaExceptionHandler::register($app['debug']);
|
||||
});
|
||||
|
||||
$this['swiftmailer.transport'] = $this->share(function ($app) {
|
||||
|
||||
if ($app['phraseanet.registry']->get('GV_smtp')) {
|
||||
|
||||
$transport = new \Swift_Transport_EsmtpTransport(
|
||||
$app['swiftmailer.transport.buffer'],
|
||||
array($app['swiftmailer.transport.authhandler']),
|
||||
@@ -340,9 +321,6 @@ class Application extends SilexApplication
|
||||
return $transport;
|
||||
});
|
||||
|
||||
// $this->register(new \Silex\Provider\HttpCacheServiceProvider());
|
||||
// $this->register(new \Silex\Provider\SecurityServiceProvider());
|
||||
|
||||
$this['imagine.factory'] = $this->share(function(Application $app) {
|
||||
if ($app['phraseanet.registry']->get('GV_imagine_driver') != '') {
|
||||
return $app['phraseanet.registry']->get('GV_imagine_driver');
|
||||
@@ -384,11 +362,17 @@ class Application extends SilexApplication
|
||||
})
|
||||
);
|
||||
|
||||
$this['dispatcher']->addListener(KernelEvents::REQUEST, array($this, 'initSession'), 254);
|
||||
$this['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'addUTF8Charset'), -128);
|
||||
$this['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'disableCookiesIfRequired'), -256);
|
||||
$this['dispatcher']->addSubscriber(new Logout());
|
||||
$this['dispatcher']->addSubscriber(new PhraseaLocaleSubscriber($this));
|
||||
$this['dispatcher'] = $this->share(
|
||||
$this->extend('dispatcher', function($dispatcher, Application $app){
|
||||
$dispatcher->addListener(KernelEvents::REQUEST, array($app, 'initSession'), 254);
|
||||
$dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128);
|
||||
$dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'disableCookiesIfRequired'), -256);
|
||||
$dispatcher->addSubscriber(new LogoutSubscriber());
|
||||
$dispatcher->addSubscriber(new PhraseaLocaleSubscriber($app));
|
||||
|
||||
return $dispatcher;
|
||||
})
|
||||
);
|
||||
|
||||
$this->register(new LocaleServiceProvider());
|
||||
|
||||
|
@@ -17,17 +17,19 @@ use Alchemy\Phrasea\Controller\Api\Oauth2;
|
||||
use Alchemy\Phrasea\Controller\Api\V1;
|
||||
use Alchemy\Phrasea\Core\Event\ApiLoadEndEvent;
|
||||
use Alchemy\Phrasea\Core\Event\ApiLoadStartEvent;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\ApiOauth2ErrorsSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\ApiExceptionHandlerSubscriber;
|
||||
use Silex\Application as SilexApplication;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
return call_user_func(function($environment = 'prod') {
|
||||
return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
|
||||
|
||||
$app = new PhraseaApplication($environment);
|
||||
|
||||
$app['exception_handler'] = $app->share(function ($app) {
|
||||
return new ApiExceptionHandlerSubscriber($app);
|
||||
});
|
||||
|
||||
$app->disableCookies();
|
||||
|
||||
$app->register(new \API_V1_Timer());
|
||||
@@ -61,72 +63,7 @@ return call_user_func(function($environment = 'prod') {
|
||||
$app->mount('/api/oauthv2', new Oauth2());
|
||||
$app->mount('/api/v1', new V1());
|
||||
|
||||
/**
|
||||
* Route Errors
|
||||
*/
|
||||
$app->error(function (\Exception $e) use ($app) {
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if (0 === strpos($request->getPathInfo(), '/api/oauthv2')) {
|
||||
if ($e instanceof NotFoundHttpException || $e instanceof \Exception_NotFound) {
|
||||
return new Response('The requested page could not be found.', 404, array('X-Status-Code' => 404));
|
||||
}
|
||||
|
||||
$code = 500;
|
||||
$msg = 'We are sorry, but something went wrong';
|
||||
$headers = array();
|
||||
|
||||
if ($e instanceof HttpExceptionInterface) {
|
||||
$headers = $e->getHeaders();
|
||||
$msg = $e->getMessage();
|
||||
$code = $e->getStatusCode();
|
||||
|
||||
if (isset($headers['content-type']) && $headers['content-type'] == 'application/json') {
|
||||
$msg = json_encode(array('msg' => $msg, 'code' => $code));
|
||||
}
|
||||
}
|
||||
|
||||
return new Response($msg, $code, $headers);
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
|
||||
if ($e instanceof \API_V1_exception_methodnotallowed) {
|
||||
$code = \API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
} elseif ($e instanceof MethodNotAllowedHttpException) {
|
||||
$code = \API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
} elseif ($e instanceof \API_V1_exception_badrequest) {
|
||||
$code = \API_V1_result::ERROR_BAD_REQUEST;
|
||||
} elseif ($e instanceof \API_V1_exception_forbidden) {
|
||||
$code = \API_V1_result::ERROR_FORBIDDEN;
|
||||
} elseif ($e instanceof \API_V1_exception_unauthorized) {
|
||||
$code = \API_V1_result::ERROR_UNAUTHORIZED;
|
||||
} elseif ($e instanceof \API_V1_exception_internalservererror) {
|
||||
$code = \API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||
} elseif ($e instanceof \Exception_NotFound) {
|
||||
$code = \API_V1_result::ERROR_NOTFOUND;
|
||||
} elseif ($e instanceof NotFoundHttpException) {
|
||||
$code = \API_V1_result::ERROR_NOTFOUND;
|
||||
} else {
|
||||
$code = \API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||
}
|
||||
|
||||
if ($e instanceof HttpException) {
|
||||
$headers = $e->getHeaders();
|
||||
}
|
||||
|
||||
$result = $app['api']->get_error_message($app['request'], $code, $e->getMessage());
|
||||
$response = $result->get_response();
|
||||
$response->headers->set('X-Status-Code', $result->get_http_code());
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$response->headers->set($key, $value);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler']));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_END, new ApiLoadEndEvent());
|
||||
|
||||
return $app;
|
||||
|
@@ -12,15 +12,22 @@
|
||||
namespace Alchemy\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaExceptionHandlerSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeExceptionSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\FirewallSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\JsonRequestSubscriber;
|
||||
use Alchemy\Phrasea\Core\Event\Subscriber\DebuggerSubscriber;
|
||||
use Silex\Provider\WebProfilerServiceProvider;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
return call_user_func(function($environment = null) {
|
||||
return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
|
||||
|
||||
$app = new PhraseaApplication($environment);
|
||||
|
||||
$app['exception_handler'] = $app->share(function ($app) {
|
||||
return new PhraseaExceptionHandlerSubscriber($app['phraseanet.exception_handler']);
|
||||
});
|
||||
|
||||
$app->before(function (Request $request) use ($app) {
|
||||
if (0 === strpos($request->getPathInfo(), '/setup')) {
|
||||
if (!$app['phraseanet.configuration-tester']->isBlank()) {
|
||||
@@ -41,98 +48,23 @@ return call_user_func(function($environment = null) {
|
||||
|
||||
$app->bindRoutes();
|
||||
|
||||
$app->error(function(\Exception $e) use ($app) {
|
||||
$request = $app['request'];
|
||||
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
|
||||
$app->register(new WebProfilerServiceProvider(), array(
|
||||
'profiler.cache_dir' => $app['root.path'] . '/tmp/cache/profiler',
|
||||
'profiler.mount_prefix' => '/_profiler',
|
||||
));
|
||||
}
|
||||
|
||||
if ($e instanceof \Bridge_Exception) {
|
||||
$params = array(
|
||||
'message' => $e->getMessage()
|
||||
, 'file' => $e->getFile()
|
||||
, 'line' => $e->getLine()
|
||||
, 'r_method' => $request->getMethod()
|
||||
, 'r_action' => $request->getRequestUri()
|
||||
, 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all())
|
||||
$app['dispatcher'] = $app->share(
|
||||
$app->extend('dispatcher', function($dispatcher, PhraseaApplication $app){
|
||||
$dispatcher->addSubscriber(new BridgeExceptionSubscriber($app));
|
||||
$dispatcher->addSubscriber(new FirewallSubscriber());
|
||||
$dispatcher->addSubscriber(new JsonRequestSubscriber());
|
||||
$dispatcher->addSubscriber(new DebuggerSubscriber($app));
|
||||
|
||||
return $dispatcher;
|
||||
})
|
||||
);
|
||||
|
||||
if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
$response = new Response($app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
$response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
$response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiDisabled) {
|
||||
$params = array_merge($params, array('api' => $e->get_api()));
|
||||
|
||||
$response = new Response($app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} else {
|
||||
$response = new Response($app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
}
|
||||
|
||||
$response->headers->set('Phrasea-StatusCode', 200);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ((0 !== strpos($request->getPathInfo(), '/admin/')
|
||||
|| 0 === strpos($request->getPathInfo(), '/admin/collection/')
|
||||
|| 0 === strpos($request->getPathInfo(), '/admin/databox/'))
|
||||
&& $request->getRequestFormat() == 'json') {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
|
||||
return $app->json($datas, 200, array('X-Status-Code' => 200));
|
||||
}
|
||||
|
||||
if ($e instanceof HttpExceptionInterface) {
|
||||
$headers = $e->getHeaders();
|
||||
|
||||
if (isset($headers['X-Phraseanet-Redirect'])) {
|
||||
return new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302));
|
||||
}
|
||||
|
||||
$message = isset(Response::$statusTexts[$e->getStatusCode()]) ? Response::$statusTexts[$e->getStatusCode()] : '';
|
||||
|
||||
if (400 === $e->getStatusCode()) {
|
||||
$message .= ' : ' . $e->getMessage();
|
||||
}
|
||||
|
||||
return new Response($message, $e->getStatusCode(), $e->getHeaders());
|
||||
}
|
||||
|
||||
if ($e instanceof \Exception_BadRequest) {
|
||||
return new Response('Bad Request', 400, array('X-Status-Code' => 400));
|
||||
}
|
||||
if ($e instanceof \Exception_Forbidden) {
|
||||
return new Response('Forbidden', 403, array('X-Status-Code' => 403));
|
||||
}
|
||||
|
||||
if ($e instanceof \Exception_Session_NotAuthenticated) {
|
||||
$code = 403;
|
||||
$message = 'Forbidden';
|
||||
} elseif ($e instanceof \Exception_NotAllowed) {
|
||||
$code = 403;
|
||||
$message = 'Forbidden';
|
||||
} elseif ($e instanceof \Exception_NotFound) {
|
||||
$code = 404;
|
||||
$message = 'Not Found';
|
||||
} elseif ($e instanceof \Exception_UnauthorizedAction) {
|
||||
$code = 403;
|
||||
$message = 'Forbidden';
|
||||
} else {
|
||||
$code = 500;
|
||||
$message = 'Server Error' . ($app['debug'] ? ' : ' . $e->getMessage() : '');
|
||||
}
|
||||
|
||||
return new Response($message, $code, array('X-Status-Code' => $code));
|
||||
});
|
||||
|
||||
return $app;
|
||||
}, isset($environment) ? $environment : null);
|
||||
|
@@ -17,6 +17,7 @@ use Browser;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Entities\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Authenticator
|
||||
{
|
||||
@@ -93,7 +94,7 @@ class Authenticator
|
||||
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($session->getUsrId(), $this->app);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
throw new RuntimeException('Unable to refresh the session', $e->getCode(), $e);
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Authentication\Token;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class TokenValidator
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class TokenValidator
|
||||
$datas = $this->app['tokens']->helloToken($token);
|
||||
|
||||
return $datas['usr_id'];
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Border\Attribute;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Phraseanet Border MetaField Attribute
|
||||
@@ -108,7 +109,7 @@ class MetaField implements AttributeInterface
|
||||
return new static($app['phraseanet.appbox']
|
||||
->get_databox($datas['sbas_id'])
|
||||
->get_meta_structure()->get_element($datas['id']), $datas['value']);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
throw new \InvalidArgumentException('Field does not exist anymore');
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Border\Attribute;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Phraseanet Border Story Attribute
|
||||
@@ -82,7 +83,7 @@ class Story implements AttributeInterface
|
||||
|
||||
try {
|
||||
$story = new \record_adapter($app, $ids[0], $ids[1]);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
throw new \InvalidArgumentException('Unable to fetch a story from string');
|
||||
}
|
||||
|
||||
|
@@ -219,11 +219,11 @@ class Manager
|
||||
*/
|
||||
protected function bookLazaretPathfile($filename, $suffix = '')
|
||||
{
|
||||
$output = __DIR__ . '/../../../../tmp/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$output = $this->app['root.path'] . '/tmp/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$infos = pathinfo($output);
|
||||
$n = 0;
|
||||
|
||||
$this->app['filesystem']->mkdir(__DIR__ . '/../../../../tmp/lazaret');
|
||||
$this->app['filesystem']->mkdir($this->app['root.path'] . '/tmp/lazaret');
|
||||
|
||||
while (true) {
|
||||
$output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : ''));
|
||||
|
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -111,23 +112,23 @@ class Publications implements ControllerProviderInterface
|
||||
|
||||
try {
|
||||
if (!$request->files->get('files')) {
|
||||
throw new \Exception_BadRequest('Missing file parameter');
|
||||
throw new BadRequestHttpException('Missing file parameter');
|
||||
}
|
||||
|
||||
if (count($request->files->get('files')) > 1) {
|
||||
throw new \Exception_BadRequest('Upload is limited to 1 file per request');
|
||||
throw new BadRequestHttpException('Upload is limited to 1 file per request');
|
||||
}
|
||||
|
||||
$file = current($request->files->get('files'));
|
||||
|
||||
if (!$file->isValid()) {
|
||||
throw new \Exception_BadRequest('Uploaded file is invalid');
|
||||
throw new BadRequestHttpException('Uploaded file is invalid');
|
||||
}
|
||||
|
||||
$media = $app['mediavorus']->guess($file->getPathname());
|
||||
|
||||
if ($media->getType() !== \MediaVorus\Media\MediaInterface::TYPE_IMAGE) {
|
||||
throw new \Exception_BadRequest('Bad filetype');
|
||||
throw new BadRequestHttpException('Bad filetype');
|
||||
}
|
||||
|
||||
$spec = new \MediaAlchemyst\Specification\Image();
|
||||
|
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -340,7 +341,7 @@ class Root implements ControllerProviderInterface
|
||||
if (null !== $file = $request->files->get('image_off')) {
|
||||
try {
|
||||
\databox_status::updateIcon($app, $databox_id, $bit, 'off', $file);
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
} catch (AccessDeniedHttpException $e) {
|
||||
return $app->redirectPath('database_display_statusbit_form', array(
|
||||
'databox_id' => $databox_id,
|
||||
'bit' => $bit,
|
||||
@@ -386,7 +387,7 @@ class Root implements ControllerProviderInterface
|
||||
if (null !== $file = $request->files->get('image_on')) {
|
||||
try {
|
||||
\databox_status::updateIcon($app, $databox_id, $bit, 'on', $file);
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
} catch (AccessDeniedHttpException $e) {
|
||||
return $app->redirectPath('database_display_statusbit_form', array(
|
||||
'databox_id' => $databox_id,
|
||||
'bit' => $bit,
|
||||
|
@@ -165,6 +165,7 @@ class TaskManager implements ControllerProviderInterface
|
||||
/**
|
||||
* todo : add a message back
|
||||
*/
|
||||
|
||||
return $app->redirectPath('admin_tasks_list');
|
||||
}
|
||||
})->bind('admin_tasks_task_delete');
|
||||
|
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Silex\Application;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -63,7 +64,7 @@ class Datafiles extends AbstractDelivery
|
||||
}
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_access_to_subdef($record, $subdef)) {
|
||||
throw new \Exception_UnauthorizedAction(sprintf('User has not access to subdef %s', $subdef));
|
||||
throw new AccessDeniedHttpException(sprintf('User has not access to subdef %s', $subdef));
|
||||
}
|
||||
|
||||
$stamp = false;
|
||||
|
@@ -17,6 +17,7 @@ use Silex\ControllerProviderInterface;
|
||||
use Silex\Application as SilexApplication;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Lightbox implements ControllerProviderInterface
|
||||
{
|
||||
@@ -43,7 +44,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
|
||||
try {
|
||||
$datas = $app['tokens']->helloToken($request->query->get('LOG'));
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return;
|
||||
}
|
||||
switch ($datas['type']) {
|
||||
|
@@ -26,7 +26,7 @@ class Minifier implements ControllerProviderInterface
|
||||
$controllers->get('/', function (Application $app, Request $request) {
|
||||
|
||||
// cache directory path
|
||||
$min_cachePath = __DIR__ . '/../../../../tmp/cache_minify';
|
||||
$min_cachePath = $app['root.path'] . '/tmp/cache_minify';
|
||||
|
||||
/**
|
||||
* Cache file locking. Set to false if filesystem is NFS. On at least one
|
||||
|
@@ -37,7 +37,7 @@ class Permalink extends AbstractDelivery
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||
|
||||
if (!$record instanceof \record_adapter) {
|
||||
throw new \Exception_NotFound('bad luck');
|
||||
throw new NotFoundHttpException('bad luck');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
@@ -56,7 +56,7 @@ class Permalink extends AbstractDelivery
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||
|
||||
if (!($record instanceof \record_adapter)) {
|
||||
throw new \Exception_NotFound('bad luck');
|
||||
throw new NotFoundHttpException('bad luck');
|
||||
}
|
||||
|
||||
$watermark = $stamp = false;
|
||||
|
@@ -18,6 +18,8 @@ use Entities\ValidationData;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -272,9 +274,9 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$success = true;
|
||||
$msg = _('Basket has been updated');
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$msg = _('The requested basket does not exist');
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
} catch (AccessDeniedHttpException $e) {
|
||||
$msg = _('You do not have access to this basket');
|
||||
} catch (\Exception $e) {
|
||||
$msg = _('An error occurred');
|
||||
|
@@ -17,64 +17,113 @@ use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$app['firewall']
|
||||
->requireNotGuest()
|
||||
->requireRight('bas_chupub');
|
||||
$app['firewall']->requireRight('bas_chupub');
|
||||
});
|
||||
|
||||
$app['require_connection'] = $app->protect(function(\Bridge_Account $account) use ($app) {
|
||||
$app['current_account'] = function() use ($account) {
|
||||
return $account;
|
||||
};
|
||||
$app['bridge.controller'] = $this;
|
||||
|
||||
if (!$account->get_api()->get_connector()->is_configured())
|
||||
$controllers
|
||||
->post('/manager/', 'bridge.controller:doPostManager');
|
||||
|
||||
$controllers
|
||||
->get('/login/{api_name}/', 'bridge.controller:doGetLogin')
|
||||
->bind('prod_bridge_login');
|
||||
|
||||
$controllers
|
||||
->get('/callback/{api_name}/', 'bridge.controller:doGetCallback')
|
||||
->bind('prod_bridge_callback');
|
||||
|
||||
$controllers
|
||||
->get('/adapter/{account_id}/logout/', 'bridge.controller:doGetAccountLogout')
|
||||
->bind('prod_bridge_account_logout')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->post('/adapter/{account_id}/delete/', 'bridge.controller:doPostAccountDelete')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->get('/adapter/{account_id}/load-records/', 'bridge.controller:doGetloadRecords')
|
||||
->bind('prod_bridge_account_loadrecords')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->get('/adapter/{account_id}/load-elements/{type}/', 'bridge.controller:doGetLoadElements')
|
||||
->bind('bridge_load_elements')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->get('/adapter/{account_id}/load-containers/{type}/', 'bridge.controller:doGetLoadContainers')
|
||||
->bind('prod_bridge_account_loadcontainers')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->get('/action/{account_id}/{action}/{element_type}/', 'bridge.controller:doGetAction')
|
||||
->bind('bridge_account_action')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->post('/action/{account_id}/{action}/{element_type}/', 'bridge.controller:doPostAction')
|
||||
->bind('bridge_account_do_action')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers
|
||||
->get('/upload/', 'bridge.controller:doGetUpload')
|
||||
->bind('prod_bridge_upload');
|
||||
|
||||
$controllers
|
||||
->post('/upload/', 'bridge.controller:doPostUpload')
|
||||
->bind('prod_bridge_do_upload');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
private function requireConnection(Application $app, \Bridge_Account $account)
|
||||
{
|
||||
$app['bridge.account'] = $account;
|
||||
|
||||
if (!$account->get_api()->get_connector()->is_configured()) {
|
||||
throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured");
|
||||
if (!$account->get_api()->get_connector()->is_connected())
|
||||
}
|
||||
if (!$account->get_api()->get_connector()->is_connected()) {
|
||||
throw new \Bridge_Exception_ApiConnectorNotConnected("Bridge API Connector is not connected");
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
$controllers->post('/manager/', function(Application $app) {
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
|
||||
public function doPostManager(Application $app, Request $request)
|
||||
{
|
||||
$route = new RecordHelper\Bridge($app, $request);
|
||||
$params = array(
|
||||
'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $app['authentication']->getUser())
|
||||
, 'available_apis' => \Bridge_Api::get_availables($app)
|
||||
, 'route' => $route
|
||||
, 'current_account_id' => ''
|
||||
'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $app['authentication']->getUser()),
|
||||
'available_apis' => \Bridge_Api::get_availables($app),
|
||||
'route' => $route,
|
||||
'current_account_id' => '',
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params);
|
||||
});
|
||||
}
|
||||
|
||||
$controllers->get('/login/{api_name}/', function(Application $app, $api_name) {
|
||||
public function doGetLogin(Application $app, Request $request, $api_name)
|
||||
{
|
||||
$connector = \Bridge_Api::get_connector_by_name($app, $api_name);
|
||||
|
||||
return $app->redirect($connector->get_auth_url());
|
||||
})->bind('prod_bridge_login');
|
||||
}
|
||||
|
||||
$controllers->get('/callback/{api_name}/', function(Application $app, $api_name) {
|
||||
public function doGetCallback(Application $app, Request $request, $api_name)
|
||||
{
|
||||
$error_message = '';
|
||||
try {
|
||||
$api = \Bridge_Api::get_by_api_name($app, $api_name);
|
||||
$connector = $api->get_connector();
|
||||
|
||||
$response = $connector->connect();
|
||||
|
||||
$user_id = $connector->get_user_id();
|
||||
|
||||
try {
|
||||
@@ -82,15 +131,17 @@ class Bridge implements ControllerProviderInterface
|
||||
} catch (\Bridge_Exception_AccountNotFound $e) {
|
||||
$account = \Bridge_Account::create($app, $api, $app['authentication']->getUser(), $user_id, $connector->get_user_name());
|
||||
}
|
||||
|
||||
$settings = $account->get_settings();
|
||||
|
||||
if (isset($response['auth_token']))
|
||||
if (isset($response['auth_token'])) {
|
||||
$settings->set('auth_token', $response['auth_token']);
|
||||
if (isset($response['refresh_token']))
|
||||
}
|
||||
if (isset($response['refresh_token'])) {
|
||||
$settings->set('refresh_token', $response['refresh_token']);
|
||||
}
|
||||
|
||||
$connector->set_auth_settings($settings);
|
||||
|
||||
$connector->reconnect();
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
@@ -99,23 +150,22 @@ class Bridge implements ControllerProviderInterface
|
||||
$params = array('error_message' => $error_message);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params);
|
||||
})->bind('prod_bridge_callback');
|
||||
}
|
||||
|
||||
$controllers->get('/adapter/{account_id}/logout/', function(Application $app, $account_id) {
|
||||
public function doGetAccountLogout(Application $app, Request $request, $account_id)
|
||||
{
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
$account->get_api()->get_connector()->disconnect();
|
||||
|
||||
return $app->redirectPath('bridge_load_elements', array(
|
||||
'account_id' => $account_id,
|
||||
'type' => $account->get_api()->get_connector()->get_default_element_type(),
|
||||
));
|
||||
})
|
||||
->bind('prod_bridge_account_logout')
|
||||
->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->post('/adapter/{account_id}/delete/'
|
||||
, function($account_id) use ($app) {
|
||||
public function doPostAccountDelete(Application $app, Request $request, $account_id)
|
||||
{
|
||||
$success = false;
|
||||
$message = '';
|
||||
try {
|
||||
@@ -134,84 +184,79 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->json(array('success' => $success, 'message' => $message));
|
||||
})->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-records/', function(Application $app, $account_id) {
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
public function doGetloadRecords(Application $app, Request $request, $account_id)
|
||||
{
|
||||
$page = max((int) $request->query->get('page'), 0);
|
||||
$quantity = 10;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$elements = \Bridge_Element::get_elements_by_account($app, $account, $offset_start, $quantity);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
|
||||
$params = array(
|
||||
'adapter_action' => 'load-records'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
, 'error_message' => $request->query->get('error')
|
||||
, 'notice_message' => $request->query->get('notice')
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params);
|
||||
})
|
||||
->bind('prod_bridge_account_loadrecords')
|
||||
->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-elements/{type}/', function($account_id, $type) use ($app) {
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
public function doGetLoadElements(Application $app, Request $request, $account_id, $type)
|
||||
{
|
||||
$page = max((int) $request->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
|
||||
$elements = $account->get_api()->list_elements($type, $offset_start, $quantity);
|
||||
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-elements'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
'action_type' => $type,
|
||||
'adapter_action' => 'load-elements',
|
||||
'account' => $account,
|
||||
'elements' => $elements,
|
||||
'error_message' => $request->query->get('error'),
|
||||
'notice_message' => $request->query->get('notice'),
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||
})
|
||||
->bind('bridge_load_elements')
|
||||
->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-containers/{type}/', function(Application $app, $account_id, $type) {
|
||||
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
public function doGetLoadContainers(Application $app, Request $request, $account_id, $type)
|
||||
{
|
||||
$page = max((int) $request->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
$elements = $account->get_api()->list_containers($type, $offset_start, $quantity);
|
||||
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-containers'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
'action_type' => $type,
|
||||
'adapter_action' => 'load-containers',
|
||||
'account' => $account,
|
||||
'elements' => $elements,
|
||||
'error_message' => $request->query->get('error'),
|
||||
'notice_message' => $request->query->get('notice'),
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||
})
|
||||
->bind('prod_bridge_account_loadcontainers')
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||
}
|
||||
|
||||
public function doGetAction(Application $app, Request $request, $account_id, $action, $element_type)
|
||||
{
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$request = $app['request'];
|
||||
$this->requireConnection($app, $account);
|
||||
$elements = $request->query->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
|
||||
@@ -243,12 +288,10 @@ class Bridge implements ControllerProviderInterface
|
||||
break;
|
||||
|
||||
case 'moveinto':
|
||||
|
||||
$route_params = array('containers' => $account->get_api()->list_containers($destination, 0, 0));
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -257,32 +300,29 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'constraint_errors' => null
|
||||
, 'adapter_action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
'account' => $account,
|
||||
'destination' => $destination,
|
||||
'element_type' => $element_type,
|
||||
'action' => $action,
|
||||
'constraint_errors' => null,
|
||||
'adapter_action' => $action,
|
||||
'elements' => $elements,
|
||||
'error_message' => $request->query->get('error'),
|
||||
'notice_message' => $request->query->get('notice'),
|
||||
);
|
||||
|
||||
$params = array_merge($params, $route_params);
|
||||
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
|
||||
return $app['twig']->render($template, $params);
|
||||
})
|
||||
->bind('bridge_account_action')
|
||||
->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->post('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||
public function doPostAction(Application $app, Request $request, $account_id, $action, $element_type)
|
||||
{
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
|
||||
$request = $app['request'];
|
||||
$elements = $request->request->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
|
||||
@@ -297,22 +337,22 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($request);
|
||||
$errors = $account->get_api()->get_connector()->check_update_constraints($datas);
|
||||
}
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$params = array(
|
||||
'element' => $account->get_api()->get_element_from_id($element_id, $element_type)
|
||||
, 'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'adapter_action' => $action
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
'element' => $account->get_api()->get_element_from_id($element_id, $element_type),
|
||||
'account' => $account,
|
||||
'destination' => $destination,
|
||||
'element_type' => $element_type,
|
||||
'action' => $action,
|
||||
'elements' => $elements,
|
||||
'adapter_action' => $action,
|
||||
'error_message' => _('Request contains invalid datas'),
|
||||
'constraint_errors' => $errors,
|
||||
'notice_message' => $request->request->get('notice'),
|
||||
);
|
||||
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
@@ -321,7 +361,7 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($request);
|
||||
$account->get_api()->update_element($element_type, $element_id, $datas);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -329,21 +369,16 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
case 'createcontainer':
|
||||
try {
|
||||
|
||||
$container_type = $request->request->get('f_container_type');
|
||||
|
||||
$account->get_api()->create_container($container_type, $app['request']);
|
||||
$account->get_api()->create_container($container_type, $request);
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
case 'moveinto':
|
||||
try {
|
||||
$container_id = $request->request->get('container_id');
|
||||
@@ -355,9 +390,6 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-containers/' . $destination . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
@@ -368,67 +400,61 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/');
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Unknown action');
|
||||
break;
|
||||
}
|
||||
|
||||
return new Response($html);
|
||||
})
|
||||
->bind('bridge_account_do_action')
|
||||
->assert('account_id', '\d+');
|
||||
}
|
||||
|
||||
$controllers->get('/upload/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
public function doGetUpload(Application $app, Request $request)
|
||||
{
|
||||
$account = \Bridge_Account::load_account($app, $request->query->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$route = new RecordHelper\Bridge($app, $request);
|
||||
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
, 'account' => $account
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
, 'constraint_errors' => null
|
||||
, 'adapter_action' => 'upload'
|
||||
'route' => $route,
|
||||
'account' => $account,
|
||||
'error_message' => $request->query->get('error'),
|
||||
'notice_message' => $request->query->get('notice'),
|
||||
'constraint_errors' => null,
|
||||
'adapter_action' => 'upload',
|
||||
);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
|
||||
);
|
||||
})->bind('prod_bridge_upload');
|
||||
}
|
||||
|
||||
$controllers->post('/upload/', function(Application $app) {
|
||||
public function doPostUpload(Application $app, Request $request)
|
||||
{
|
||||
$errors = array();
|
||||
$request = $app['request'];
|
||||
$account = \Bridge_Account::load_account($app, $request->request->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
$this->requireConnection($app, $account);
|
||||
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$route = new RecordHelper\Bridge($app, $request);
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
$connector = $account->get_api()->get_connector();
|
||||
|
||||
/**
|
||||
* check constraints
|
||||
*/
|
||||
// check constraints
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
|
||||
}
|
||||
|
||||
if (count($errors) > 0) {
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
, 'account' => $account
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
, 'adapter_action' => 'upload'
|
||||
'route' => $route,
|
||||
'account' => $account,
|
||||
'error_message' => _('Request contains invalid datas'),
|
||||
'constraint_errors' => $errors,
|
||||
'notice_message' => $request->request->get('notice'),
|
||||
'adapter_action' => 'upload',
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params);
|
||||
@@ -442,8 +468,5 @@ class Bridge implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . sprintf(_('%d elements en attente'), count($route->get_elements())));
|
||||
})->bind('prod_bridge_do_upload');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class DoDownload implements ControllerProviderInterface
|
||||
{
|
||||
@@ -91,11 +92,7 @@ class DoDownload implements ControllerProviderInterface
|
||||
*/
|
||||
public function prepareDownload(Application $app, Request $request, $token)
|
||||
{
|
||||
try {
|
||||
$datas = $app['tokens']->helloToken($token);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app->abort(404, 'Invalid token');
|
||||
}
|
||||
|
||||
if (false === $list = @unserialize((string) $datas['datas'])) {
|
||||
$app->abort(500, 'Invalid datas');
|
||||
@@ -140,11 +137,7 @@ class DoDownload implements ControllerProviderInterface
|
||||
*/
|
||||
public function downloadDocuments(Application $app, Request $request, $token)
|
||||
{
|
||||
try {
|
||||
$datas = $app['tokens']->helloToken($token);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app->abort(404, 'Invalid token');
|
||||
}
|
||||
|
||||
if (false === $list = @unserialize((string) $datas['datas'])) {
|
||||
$app->abort(500, 'Invalid datas');
|
||||
@@ -160,7 +153,7 @@ class DoDownload implements ControllerProviderInterface
|
||||
$mime = $subdef['mime'];
|
||||
$list['complete'] = true;
|
||||
} else {
|
||||
$exportFile = __DIR__ . '/../../../../../tmp/download/' . $datas['value'] . '.zip';
|
||||
$exportFile = $app['root.path'] . '/tmp/download/' . $datas['value'] . '.zip';
|
||||
$mime = 'application/zip';
|
||||
}
|
||||
|
||||
@@ -202,7 +195,7 @@ class DoDownload implements ControllerProviderInterface
|
||||
{
|
||||
try {
|
||||
$datas = $app['tokens']->helloToken($token);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return $app->json(array(
|
||||
'success' => false,
|
||||
'message' => 'Invalid token'
|
||||
@@ -225,7 +218,7 @@ class DoDownload implements ControllerProviderInterface
|
||||
$app,
|
||||
$token,
|
||||
$list,
|
||||
sprintf('%s/../../../../../tmp/download/%s.zip', __DIR__, $datas['value']) // Dest file
|
||||
sprintf($app['root.path'] . '/tmp/download/%s.zip', $datas['value']) // Dest file
|
||||
);
|
||||
|
||||
return $app->json(array(
|
||||
|
@@ -16,6 +16,8 @@ use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -79,7 +81,7 @@ class Feed implements ControllerProviderInterface
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
|
||||
if (!$entry->is_publisher($app['authentication']->getUser())) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$feeds = \Feed_Collection::load_all($app, $app['authentication']->getUser());
|
||||
@@ -102,7 +104,7 @@ class Feed implements ControllerProviderInterface
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
|
||||
if (!$entry->is_publisher($app['authentication']->getUser())) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$title = $request->request->get('title');
|
||||
@@ -120,12 +122,12 @@ class Feed implements ControllerProviderInterface
|
||||
if ($current_feed_id != $new_feed_id) {
|
||||
try {
|
||||
$new_feed = \Feed_Adapter::load_with_user($app, $app['authentication']->getUser(), $new_feed_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
throw new \Exception_Forbidden('You have no access to this feed');
|
||||
} catch (NotFoundHttpException $e) {
|
||||
throw new AccessDeniedHttpException('You have no access to this feed');
|
||||
}
|
||||
|
||||
if (!$new_feed->is_publisher($app['authentication']->getUser())) {
|
||||
throw new \Exception_Forbidden('You are not publisher of this feed');
|
||||
throw new AccessDeniedHttpException('You are not publisher of this feed');
|
||||
}
|
||||
|
||||
$entry->set_feed($new_feed);
|
||||
@@ -151,10 +153,10 @@ class Feed implements ControllerProviderInterface
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed not found');
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
} catch (AccessDeniedHttpException $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('You are not authorized to access this feed');
|
||||
} catch (\Exception $e) {
|
||||
@@ -178,7 +180,7 @@ class Feed implements ControllerProviderInterface
|
||||
|
||||
if (!$entry->is_publisher($app['authentication']->getUser())
|
||||
&& $entry->get_feed()->is_owner($app['authentication']->getUser()) === false) {
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
throw new AccessDeniedHttpException(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
|
||||
$entry->delete();
|
||||
|
@@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,13 +33,13 @@ class MustacheLoader implements ControllerProviderInterface
|
||||
$template_name = $request->query->get('template');
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9-_]+$/', $template_name)) {
|
||||
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
|
||||
throw new BadRequestHttpException('Wrong template name : ' . $template_name);
|
||||
}
|
||||
|
||||
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
|
||||
|
||||
if (!file_exists($template_path)) {
|
||||
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
|
||||
throw new NotFoundHttpException('Template does not exists : ' . $template_path);
|
||||
}
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\Response(file_get_contents($template_path));
|
||||
|
@@ -255,11 +255,7 @@ class Order implements ControllerProviderInterface
|
||||
*/
|
||||
public function displayOneOrder(Application $app, Request $request, $order_id)
|
||||
{
|
||||
try {
|
||||
$order = new \set_order($app, $order_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app->abort(404);
|
||||
}
|
||||
|
||||
return $app['twig']->render('prod/orders/order_item.html.twig', array(
|
||||
'order' => $order
|
||||
@@ -278,11 +274,7 @@ class Order implements ControllerProviderInterface
|
||||
{
|
||||
$success = false;
|
||||
|
||||
try {
|
||||
$order = new \set_order($app, $order_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app->abort(404);
|
||||
}
|
||||
|
||||
try {
|
||||
$order->send_elements($app, $request->request->get('elements', array()), !!$request->request->get('force', false));
|
||||
@@ -317,11 +309,7 @@ class Order implements ControllerProviderInterface
|
||||
{
|
||||
$success = false;
|
||||
|
||||
try {
|
||||
$order = new \set_order($app, $order_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app->abort(404);
|
||||
}
|
||||
|
||||
try {
|
||||
$order->deny_elements($request->request->get('elements', array()));
|
||||
|
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
||||
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -370,7 +371,7 @@ class Push implements ControllerProviderInterface
|
||||
try {
|
||||
$Participant = $Validation->getParticipant($participant_user, $app);
|
||||
continue;
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,6 @@ class Root implements ControllerProviderInterface
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
|
||||
if (!$app['authentication']->isAuthenticated() && null !== $request->query->get('nolog')) {
|
||||
return $app->redirectPath('login_authenticate_as_guest');
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,7 +44,7 @@ class Story implements ControllerProviderInterface
|
||||
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||
throw new AccessDeniedHttpException('You can not create a story on this collection');
|
||||
}
|
||||
|
||||
$Story = \record_adapter::createStory($app, $collection);
|
||||
@@ -121,7 +122,7 @@ class Story implements ControllerProviderInterface
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
throw new AccessDeniedHttpException('You can not add document to this Story');
|
||||
|
||||
$n = 0;
|
||||
|
||||
@@ -154,7 +155,7 @@ class Story implements ControllerProviderInterface
|
||||
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
throw new AccessDeniedHttpException('You can not add document to this Story');
|
||||
|
||||
$Story->removeChild($record);
|
||||
|
||||
|
@@ -19,6 +19,8 @@ use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
* Upload controller collection
|
||||
@@ -159,27 +161,27 @@ class Upload implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
if (null === $request->files->get('files')) {
|
||||
throw new \Exception_BadRequest('Missing file parameter');
|
||||
throw new BadRequestHttpException('Missing file parameter');
|
||||
}
|
||||
|
||||
if (count($request->files->get('files')) > 1) {
|
||||
throw new \Exception_BadRequest('Upload is limited to 1 file per request');
|
||||
throw new BadRequestHttpException('Upload is limited to 1 file per request');
|
||||
}
|
||||
|
||||
$base_id = $request->request->get('base_id');
|
||||
|
||||
if (!$base_id) {
|
||||
throw new \Exception_BadRequest('Missing base_id parameter');
|
||||
throw new BadRequestHttpException('Missing base_id parameter');
|
||||
}
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($base_id, 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('User is not allowed to add record on this collection');
|
||||
throw new AccessDeniedHttpException('User is not allowed to add record on this collection');
|
||||
}
|
||||
|
||||
$file = current($request->files->get('files'));
|
||||
|
||||
if (!$file->isValid()) {
|
||||
throw new \Exception_BadRequest('Uploaded file is invalid');
|
||||
throw new BadRequestHttpException('Uploaded file is invalid');
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -19,6 +19,7 @@ use Silex\ControllerProviderInterface;
|
||||
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -477,9 +478,9 @@ class UsrLists implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
if (!$app['request']->request->get('role'))
|
||||
throw new \Exception_BadRequest('Missing role parameter');
|
||||
throw new BadRequestHttpException('Missing role parameter');
|
||||
elseif (!in_array($app['request']->request->get('role'), $availableRoles))
|
||||
throw new \Exception_BadRequest('Role is invalid');
|
||||
throw new BadRequestHttpException('Role is invalid');
|
||||
|
||||
try {
|
||||
$repository = $app['EM']->getRepository('\Entities\UsrList');
|
||||
|
@@ -16,6 +16,9 @@ use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Alchemy\Phrasea\Helper\WorkZone as WorkzoneHelper;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -121,7 +124,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
public function attachStories(Application $app, Request $request)
|
||||
{
|
||||
if (!$request->request->get('stories')) {
|
||||
throw new \Exception_BadRequest();
|
||||
throw new BadRequestHttpException('Missing parameters stories');
|
||||
}
|
||||
|
||||
$StoryWZRepo = $app['EM']->getRepository('\Entities\StoryWZ');
|
||||
@@ -139,7 +142,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if (!$app['authentication']->getUser()->ACL()->has_access_to_base($Story->get_base_id())) {
|
||||
throw new \Exception_Forbidden('You do not have access to this Story');
|
||||
throw new AccessDeniedHttpException('You do not have access to this Story');
|
||||
}
|
||||
|
||||
if ($StoryWZRepo->findUserStory($app, $app['authentication']->getUser(), $Story)) {
|
||||
@@ -205,7 +208,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
$StoryWZ = $repository->findUserStory($app, $app['authentication']->getUser(), $Story);
|
||||
|
||||
if (!$StoryWZ) {
|
||||
throw new \Exception_NotFound('Story not found');
|
||||
throw new NotFoundHttpException('Story not found');
|
||||
}
|
||||
|
||||
$app['EM']->remove($StoryWZ);
|
||||
|
@@ -15,6 +15,7 @@ use Entities\Basket;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class RecordsRequest extends ArrayCollection
|
||||
{
|
||||
@@ -223,7 +224,7 @@ class RecordsRequest extends ArrayCollection
|
||||
$record = new \record_adapter($app, (int) $basrec[0], (int) $basrec[1]);
|
||||
$received[$record->get_serialize_key()] = $record;
|
||||
unset($record);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Account implements ControllerProviderInterface
|
||||
{
|
||||
@@ -221,7 +222,7 @@ class Account implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
$account->set_revoked((bool) $request->query->get('revoke'), false);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -189,7 +190,7 @@ class Developers implements ControllerProviderInterface
|
||||
try {
|
||||
$clientApp = new \API_OAuth2_Application($app, $id);
|
||||
$clientApp->delete();
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ class Developers implements ControllerProviderInterface
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -283,7 +284,7 @@ class Developers implements ControllerProviderInterface
|
||||
try {
|
||||
$clientApp = new \API_OAuth2_Application($app, $id);
|
||||
$clientApp->set_grant_password((bool) $request->request->get('grant', false));
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -368,7 +369,7 @@ class Developers implements ControllerProviderInterface
|
||||
{
|
||||
try {
|
||||
$client = new \API_OAuth2_Application($app, $id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$app->abort(404);
|
||||
}
|
||||
|
||||
|
@@ -474,7 +474,7 @@ class Login implements ControllerProviderInterface
|
||||
|
||||
try {
|
||||
$datas = $app['tokens']->helloToken($code);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$app->addFlash('error', _('Invalid unlock link.'));
|
||||
|
||||
return $app->redirectPath('homepage');
|
||||
@@ -795,7 +795,7 @@ class Login implements ControllerProviderInterface
|
||||
|
||||
try {
|
||||
$token = $this->app['tokens']->getValidationToken($participantId, $basketId);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class ApiExceptionHandlerSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::EXCEPTION => array('onSilexError', 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
$headers = array();
|
||||
$e = $event->getException();
|
||||
|
||||
if ($e instanceof \API_V1_exception_methodnotallowed) {
|
||||
$code = \API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
} elseif ($e instanceof MethodNotAllowedHttpException) {
|
||||
$code = \API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
} elseif ($e instanceof \API_V1_exception_badrequest) {
|
||||
$code = \API_V1_result::ERROR_BAD_REQUEST;
|
||||
} elseif ($e instanceof \API_V1_exception_forbidden) {
|
||||
$code = \API_V1_result::ERROR_FORBIDDEN;
|
||||
} elseif ($e instanceof \API_V1_exception_unauthorized) {
|
||||
$code = \API_V1_result::ERROR_UNAUTHORIZED;
|
||||
} elseif ($e instanceof \API_V1_exception_internalservererror) {
|
||||
$code = \API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||
} elseif ($e instanceof NotFoundHttpException) {
|
||||
$code = \API_V1_result::ERROR_NOTFOUND;
|
||||
} else {
|
||||
$code = \API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||
}
|
||||
|
||||
if ($e instanceof HttpException) {
|
||||
$headers = $e->getHeaders();
|
||||
}
|
||||
|
||||
$result = $this->app['api']->get_error_message($event->getRequest(), $code, $e->getMessage());
|
||||
$response = $result->get_response();
|
||||
$response->headers->set('X-Status-Code', $result->get_http_code());
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$response->headers->set($key, $value);
|
||||
}
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $handler;
|
||||
|
||||
public function __construct(ExceptionHandler $handler)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::EXCEPTION => array('onSilexError', 20),
|
||||
);
|
||||
}
|
||||
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
if (0 !== strpos($request->getPathInfo(), '/api/oauthv2')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$e = $event->getException();
|
||||
|
||||
$code = 500;
|
||||
$msg = _('Whoops, looks like something went wrong.');
|
||||
$headers = array();
|
||||
|
||||
if ($e instanceof HttpExceptionInterface) {
|
||||
$headers = $e->getHeaders();
|
||||
$msg = $e->getMessage();
|
||||
$code = $e->getStatusCode();
|
||||
}
|
||||
|
||||
if (isset($headers['content-type']) && $headers['content-type'] == 'application/json') {
|
||||
$msg = json_encode(array('msg' => $msg, 'code' => $code));
|
||||
$event->setResponse(new Response($msg, $code, $headers));
|
||||
} else {
|
||||
$event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class BridgeExceptionSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if (!$event->getException() instanceof \Bridge_Exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
$e = $event->getException();
|
||||
$request = $event->getRequest();
|
||||
|
||||
$params = array(
|
||||
'account' => null,
|
||||
'elements' => array(),
|
||||
'message' => $e->getMessage(),
|
||||
'error_message' => null,
|
||||
'notice_message' => null,
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'r_method' => $request->getMethod(),
|
||||
'r_action' => $request->getRequestUri(),
|
||||
'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()),
|
||||
);
|
||||
|
||||
if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) {
|
||||
$params = array_replace($params, array('account' => $this->app['bridge.account']));
|
||||
$response = new Response($this->app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) {
|
||||
$params = array_replace($params, array('account' => $this->app['bridge.account']));
|
||||
$response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) {
|
||||
$params = array_replace($params, array('account' => $this->app['bridge.account']));
|
||||
$response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiDisabled) {
|
||||
$params = array_replace($params, array('api' => $e->get_api()));
|
||||
$response = new Response($this->app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
} else {
|
||||
$response = new Response($this->app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200));
|
||||
}
|
||||
|
||||
$response->headers->set('Phrasea-StatusCode', 200);
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::EXCEPTION => array('onSilexError', 20));
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class DebuggerSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::REQUEST => array(
|
||||
array('checkIp', 255),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function checkIp(GetResponseEvent $event)
|
||||
{
|
||||
if (Application::ENV_DEV !== $this->app->getEnvironment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->app['phraseanet.configuration']['debugger'])
|
||||
&& isset($this->app['phraseanet.configuration']['debugger']['allowed-ips'])) {
|
||||
|
||||
$allowedIps = $this->app['phraseanet.configuration']['debugger']['allowed-ips'];
|
||||
$allowedIps = is_array($allowedIps) ? $allowedIps : array($allowedIps);
|
||||
} else {
|
||||
$allowedIps = array();
|
||||
}
|
||||
|
||||
$ips = array_merge(array('127.0.0.1', 'fe80::1', '::1'), $allowedIps);
|
||||
|
||||
if (!in_array($event->getRequest()->getClientIp(), $ips)) {
|
||||
throw new AccessDeniedHttpException('You are not allowed to access this file. Check index_dev.php for more information.');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
class FirewallSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::RESPONSE => array('onKernelResponse', 0),
|
||||
KernelEvents::EXCEPTION => array('onSilexError', 20),
|
||||
);
|
||||
}
|
||||
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
{
|
||||
if ($event->getResponse()->headers->has('X-Phraseanet-Redirect')) {
|
||||
$event->getResponse()->headers->remove('X-Phraseanet-Redirect');
|
||||
}
|
||||
}
|
||||
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
$e = $event->getException();
|
||||
|
||||
if ($e instanceof HttpExceptionInterface) {
|
||||
$headers = $e->getHeaders();
|
||||
|
||||
if (isset($headers['X-Phraseanet-Redirect'])) {
|
||||
$event->setResponse(new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class JsonRequestSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
$exception = $event->getException();
|
||||
$request = $event->getRequest();
|
||||
|
||||
if ((0 !== strpos($request->getPathInfo(), '/admin/')
|
||||
|| 0 === strpos($request->getPathInfo(), '/admin/collection/')
|
||||
|| 0 === strpos($request->getPathInfo(), '/admin/databox/'))
|
||||
&& $request->getRequestFormat() == 'json') {
|
||||
$datas = array(
|
||||
'success' => false,
|
||||
'message' => $exception->getMessage(),
|
||||
);
|
||||
|
||||
$event->setResponse(new JsonResponse($datas, 200, array('X-Status-Code' => 200)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::EXCEPTION => array('onSilexError', 10));
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@ use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use Alchemy\Phrasea\Core\Event\LogoutEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class Logout implements EventSubscriberInterface
|
||||
class LogoutSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function onLogout(LogoutEvent $event)
|
||||
{
|
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class PhraseaExceptionHandlerSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
protected $enabled;
|
||||
protected $handler;
|
||||
|
||||
public function __construct(ExceptionHandler $handler)
|
||||
{
|
||||
$this->enabled = true;
|
||||
$this->handler = $handler;
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
public function onSilexError(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if (!$this->enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::EXCEPTION => array('onSilexError', 0));
|
||||
}
|
||||
}
|
143
lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php
Normal file
143
lib/Alchemy/Phrasea/Core/PhraseaExceptionHandler.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core;
|
||||
|
||||
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class PhraseaExceptionHandler extends SymfonyExceptionHandler
|
||||
{
|
||||
public function createResponseBasedOnRequest(Request $request, $exception)
|
||||
{
|
||||
return parent::createResponse($exception);
|
||||
}
|
||||
|
||||
public function getContent(FlattenException $exception)
|
||||
{
|
||||
switch (true) {
|
||||
case 404 === $exception->getStatusCode():
|
||||
$title = _('Sorry, the page you are looking for could not be found.');
|
||||
break;
|
||||
case 403 === $exception->getStatusCode():
|
||||
$title = _('Sorry, you do have access to the page you are looking for.');
|
||||
break;
|
||||
case 500 === $exception->getStatusCode():
|
||||
$title = _('Whoops, looks like something went wrong.');
|
||||
break;
|
||||
case isset(Response::$statusTexts[$exception->getStatusCode()]):
|
||||
$title = $exception->getStatusCode() . ' : ' . Response::$statusTexts[$exception->getStatusCode()];
|
||||
break;
|
||||
default:
|
||||
$title = 'Whoops, looks like something went wrong.';
|
||||
}
|
||||
|
||||
$content = parent::getContent($exception);
|
||||
$start = strpos($content, '</h1>');
|
||||
|
||||
$content = '<div id="sf-resetcontent" class="sf-reset">'
|
||||
. '<h1><span>' . $title . '</span></h1>'
|
||||
. substr($content, $start);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getStylesheet(FlattenException $exception)
|
||||
{
|
||||
$exception->getStatusCode();
|
||||
|
||||
switch ($exception->getStatusCode()) {
|
||||
case 403:
|
||||
$errorImg = '/skins/error-pages/403.png';
|
||||
break;
|
||||
case 404:
|
||||
$errorImg = '/skins/error-pages/404.png';
|
||||
break;
|
||||
case 500:
|
||||
$errorImg = '/skins/error-pages/500.png';
|
||||
break;
|
||||
default:
|
||||
$errorImg = '/skins/error-pages/error.png';
|
||||
break;
|
||||
}
|
||||
|
||||
return <<<EOF
|
||||
html {
|
||||
background-image:url("/skins/error-pages/background.png");
|
||||
background-repeat:repeat;
|
||||
padding-top:0px;
|
||||
}
|
||||
body {
|
||||
background-image:url("$errorImg");
|
||||
background-repeat:no-repeat;
|
||||
background-position:top center;
|
||||
}
|
||||
.sf-reset { font: 11px Arial, Verdana, sans-serif; color: #333 }
|
||||
.sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
|
||||
.sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
|
||||
.sf-reset .clear_fix { display:inline-block; }
|
||||
.sf-reset * html .clear_fix { height:1%; }
|
||||
.sf-reset .clear_fix { display:block; }
|
||||
.sf-reset, .sf-reset .block { margin: auto }
|
||||
.sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
|
||||
.sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
|
||||
.sf-reset strong { font-weight:bold; }
|
||||
.sf-reset a { color:#6c6159; }
|
||||
.sf-reset a img { border:none; }
|
||||
.sf-reset a:hover { text-decoration:underline; }
|
||||
.sf-reset em { font-style:italic; }
|
||||
.sf-reset h2 { font: 20px Arial, Verdana, sans-serif; color: #3C3C3B; }
|
||||
.sf-reset h2 span {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
padding: 6px;
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
color: #ED7060;
|
||||
border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
}
|
||||
.sf-reset .traces li { font-size:15px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; margin-top:15px; }
|
||||
.sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
|
||||
border-bottom:1px solid #ccc;
|
||||
border-right:1px solid #ccc;
|
||||
border-left:1px solid #ccc;
|
||||
}
|
||||
.sf-reset .block_exception {
|
||||
background-color:#ddd;
|
||||
color: #333;
|
||||
padding:20px;
|
||||
-webkit-border-top-left-radius: 16px;
|
||||
-webkit-border-top-right-radius: 16px;
|
||||
-moz-border-radius-topleft: 16px;
|
||||
-moz-border-radius-topright: 16px;
|
||||
border-top-left-radius: 16px;
|
||||
border-top-right-radius: 16px;
|
||||
border-top:1px solid #ccc;
|
||||
border-right:1px solid #ccc;
|
||||
border-left:1px solid #ccc;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
background-color: #719AAF;
|
||||
}
|
||||
.sf-reset li a { background:none; color:#868686; text-decoration:none; }
|
||||
.sf-reset li a:hover { background:none; color:#313131; text-decoration:underline; }
|
||||
.sf-reset ol { padding: 10px 0; }
|
||||
.sf-reset h1 {
|
||||
height:510px;
|
||||
}
|
||||
.sf-reset h1 span { color:#646363; display:inline-block; margin-top:430px; margin-left:190px; font-size:28px; }
|
||||
EOF;
|
||||
}
|
||||
}
|
@@ -22,7 +22,7 @@ class CacheServiceProvider implements ServiceProviderInterface
|
||||
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['phraseanet.cache-registry'] = __DIR__ . '/../../../../../tmp/cache_registry.php';
|
||||
$app['phraseanet.cache-registry'] = $app['root.path'] . '/tmp/cache_registry.php';
|
||||
|
||||
$app['phraseanet.cache-compiler'] = $app->share(function () {
|
||||
return new Compiler();
|
||||
|
@@ -21,8 +21,8 @@ class JMSSerializerServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['serializer.cache-directory'] = __DIR__ . '/../../../../../tmp/serializer/';
|
||||
$app['serializer.src_directory'] = __DIR__ . '/../../../../../vendor/jms/serializer/src/';
|
||||
$app['serializer.cache-directory'] = $app['root.path'] . '/tmp/serializer/';
|
||||
$app['serializer.src_directory'] = $app['root.path'] . '/vendor/jms/serializer/src/';
|
||||
|
||||
$app['serializer.metadata.annotation_reader'] = $app->share(function () use ($app) {
|
||||
AnnotationRegistry::registerAutoloadNamespace("JMS\Serializer\Annotation", $app['serializer.src_directory']);
|
||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Form\Constraint;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class PasswordToken extends Constraint
|
||||
{
|
||||
@@ -32,7 +33,7 @@ class PasswordToken extends Constraint
|
||||
{
|
||||
try {
|
||||
$data = $this->random->helloToken($token);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,6 @@ class PhraseaRegisterForm extends AbstractType
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
$builder->add('password', 'repeated', array(
|
||||
'type' => 'password',
|
||||
'required' => true,
|
||||
|
@@ -16,6 +16,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -644,7 +645,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$template = \User_adapter::getInstance($this->request->get('template'), $this->app);
|
||||
|
||||
if ($template->get_template_owner()->get_id() != $this->app['authentication']->getUser()->get_id()) {
|
||||
throw new \Exception_Forbidden('You are not the owner of the template');
|
||||
throw new AccessDeniedHttpException('You are not the owner of the template');
|
||||
}
|
||||
|
||||
$base_ids = array_keys($this->app['authentication']->getUser()->ACL()->get_granted_base(array('canadmin')));
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Kernel
|
||||
@@ -279,7 +280,7 @@ class ValidationSession
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception_NotFound('Particpant not found' . $user->get_email());
|
||||
throw new NotFoundHttpException('Particpant not found' . $user->get_email());
|
||||
}
|
||||
/**
|
||||
* @var integer $initiator
|
||||
|
@@ -4,6 +4,7 @@ namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Entities;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* BasketElementRepository
|
||||
@@ -38,7 +39,7 @@ class BasketElementRepository extends EntityRepository
|
||||
|
||||
/* @var $element \Entities\BasketElement */
|
||||
if (null === $element) {
|
||||
throw new \Exception_NotFound(_('Element is not found'));
|
||||
throw new NotFoundHttpException(_('Element is not found'));
|
||||
}
|
||||
|
||||
return $element;
|
||||
|
@@ -14,6 +14,8 @@ namespace Repositories;
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Entities;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -120,8 +122,8 @@ class BasketRepository extends EntityRepository
|
||||
/**
|
||||
* Find a basket specified by his basket_id and his owner
|
||||
*
|
||||
* @throws \Exception_NotFound
|
||||
* @throws \Exception_Forbidden
|
||||
* @throws NotFoundHttpException
|
||||
* @throws AccessDeniedHttpException
|
||||
* @param type $basket_id
|
||||
* @param \User_Adapter $user
|
||||
* @return \Entities\Basket
|
||||
@@ -140,7 +142,7 @@ class BasketRepository extends EntityRepository
|
||||
|
||||
/* @var $basket \Entities\Basket */
|
||||
if (null === $basket) {
|
||||
throw new \Exception_NotFound(_('Basket is not found'));
|
||||
throw new NotFoundHttpException(_('Basket is not found'));
|
||||
}
|
||||
|
||||
if ($basket->getOwner($app)->get_id() != $user->get_id()) {
|
||||
@@ -155,7 +157,7 @@ class BasketRepository extends EntityRepository
|
||||
}
|
||||
}
|
||||
if ( ! $participant) {
|
||||
throw new \Exception_Forbidden(_('You have not access to this basket'));
|
||||
throw new AccessDeniedHttpException(_('You have not access to this basket'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,8 @@ namespace Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* StoryWZRepository
|
||||
@@ -30,7 +32,7 @@ class StoryWZRepository extends EntityRepository
|
||||
foreach ($stories as $key => $story) {
|
||||
try {
|
||||
$story->getRecord($app)->get_title();
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->getEntityManager()->remove($story);
|
||||
unset($stories[$key]);
|
||||
}
|
||||
@@ -67,16 +69,16 @@ class StoryWZRepository extends EntityRepository
|
||||
if ($story) {
|
||||
try {
|
||||
$story->getRecord($app)->get_title();
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->getEntityManager()->remove($story);
|
||||
throw new \Exception_NotFound('Story not found');
|
||||
throw new NotFoundHttpException('Story not found');
|
||||
}
|
||||
|
||||
if ($story->getUser($app)->get_id() !== $user->get_id()) {
|
||||
throw new \Exception_Forbidden('You have not access to ths story');
|
||||
throw new AccessDeniedHttpException('You have not access to ths story');
|
||||
}
|
||||
} else {
|
||||
throw new \Exception_NotFound('Story not found');
|
||||
throw new NotFoundHttpException('Story not found');
|
||||
}
|
||||
|
||||
return $story;
|
||||
@@ -95,7 +97,7 @@ class StoryWZRepository extends EntityRepository
|
||||
if ($story) {
|
||||
try {
|
||||
$record = $story->getRecord($app);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->getEntityManager()->remove($story);
|
||||
$this->getEntityManager()->flush();
|
||||
$story = null;
|
||||
@@ -121,7 +123,7 @@ class StoryWZRepository extends EntityRepository
|
||||
foreach ($stories as $key => $story) {
|
||||
try {
|
||||
$record = $story->getRecord();
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->getEntityManager()->remove($story);
|
||||
$this->getEntityManager()->flush();
|
||||
unset($stories[$key]);
|
||||
@@ -145,7 +147,7 @@ class StoryWZRepository extends EntityRepository
|
||||
foreach ($stories as $key => $story) {
|
||||
try {
|
||||
$record = $story->getRecord();
|
||||
} catch (\Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->getEntityManager()->remove($story);
|
||||
$this->getEntityManager()->flush();
|
||||
unset($stories[$key]);
|
||||
|
@@ -3,6 +3,8 @@
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* UsrListEntryRepository
|
||||
@@ -40,12 +42,12 @@ class UsrListEntryRepository extends EntityRepository
|
||||
$entry = $this->find($entry_id);
|
||||
|
||||
if ( ! $entry) {
|
||||
throw new \Exception_NotFound('Entry not found');
|
||||
throw new NotFoundHttpException('Entry not found');
|
||||
}
|
||||
|
||||
/* @var $entry \Entities\UsrListEntry */
|
||||
if ($entry->getList()->getId() != $list->getId()) {
|
||||
throw new \Exception_Forbidden('Entry mismatch list');
|
||||
throw new AccessDeniedHttpException('Entry mismatch list');
|
||||
}
|
||||
|
||||
return $entry;
|
||||
@@ -68,7 +70,7 @@ class UsrListEntryRepository extends EntityRepository
|
||||
$entry = $query->getResult();
|
||||
|
||||
if ( ! $entry) {
|
||||
throw new \Exception_NotFound('Entry not found');
|
||||
throw new NotFoundHttpException('Entry not found');
|
||||
}
|
||||
|
||||
return $query->getSingleResult();
|
||||
|
@@ -3,6 +3,8 @@
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* UsrListOwnerRepository
|
||||
@@ -26,11 +28,11 @@ class UsrListOwnerRepository extends EntityRepository
|
||||
|
||||
/* @var $owner \Entities\UsrListOwner */
|
||||
if (null === $owner) {
|
||||
throw new \Exception_NotFound(_('Owner is not found'));
|
||||
throw new NotFoundHttpException(_('Owner is not found'));
|
||||
}
|
||||
|
||||
if ( ! $owner->getList()->getid() != $list->getId()) {
|
||||
throw new \Exception_Forbidden(_('Owner and list mismatch'));
|
||||
throw new AccessDeniedHttpException(_('Owner and list mismatch'));
|
||||
}
|
||||
|
||||
return $owner;
|
||||
@@ -61,7 +63,7 @@ class UsrListOwnerRepository extends EntityRepository
|
||||
|
||||
/* @var $owner \Entities\UsrListOwner */
|
||||
if (null === $owner) {
|
||||
throw new \Exception_NotFound(_('Owner is not found'));
|
||||
throw new NotFoundHttpException(_('Owner is not found'));
|
||||
}
|
||||
|
||||
return $owner;
|
||||
|
@@ -4,6 +4,8 @@ namespace Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* UsrListRepository
|
||||
@@ -49,11 +51,11 @@ class UsrListRepository extends EntityRepository
|
||||
|
||||
/* @var $basket \Entities\UsrList */
|
||||
if (null === $list) {
|
||||
throw new \Exception_NotFound(_('List is not found'));
|
||||
throw new NotFoundHttpException(_('List is not found'));
|
||||
}
|
||||
|
||||
if ( ! $list->hasAccess($user, $app)) {
|
||||
throw new \Exception_Forbidden(_('You have not access to this list'));
|
||||
throw new AccessDeniedHttpException(_('You have not access to this list'));
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -179,7 +180,7 @@ class API_OAuth2_Account
|
||||
if (! $this->token) {
|
||||
try {
|
||||
$this->token = new API_OAuth2_Token($this->app['phraseanet.appbox'], $this);
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$this->token = API_OAuth2_Token::create($this->app['phraseanet.appbox'], $this);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +264,7 @@ class API_OAuth2_Account
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (! $row) {
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Account nof found.');
|
||||
}
|
||||
|
||||
return new self($app, $row['api_account_id']);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -149,7 +150,7 @@ class API_OAuth2_Application
|
||||
$stmt->execute(array(':application_id' => $this->id));
|
||||
|
||||
if (0 === $stmt->rowCount()) {
|
||||
throw new \Exception_NotFound(sprintf('Application with id %d not found', $this->id));
|
||||
throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id));
|
||||
}
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -546,7 +547,7 @@ class API_OAuth2_Application
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Application not found.');
|
||||
|
||||
return new API_OAuth2_Account($this->app, $row['api_account_id']);
|
||||
}
|
||||
@@ -659,7 +660,7 @@ class API_OAuth2_Application
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Client not found.');
|
||||
|
||||
return new self($app, $row['application_id']);
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -44,7 +45,7 @@ class API_OAuth2_AuthCode
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Code not found');
|
||||
|
||||
$this->account_id = (int) $row['api_account_id'];
|
||||
$this->redirect_uri = $row['redirect_uri'];
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -78,7 +79,7 @@ class API_OAuth2_Token
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Account not found');
|
||||
|
||||
$stmt->closeCursor();
|
||||
|
||||
@@ -286,7 +287,7 @@ class API_OAuth2_Token
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_NotFound();
|
||||
throw new NotFoundHttpException('Account not found');
|
||||
|
||||
$account = new API_OAuth2_Account($app, $row['api_account_id']);
|
||||
|
||||
|
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Attribute\Status;
|
||||
use Alchemy\Phrasea\Border\Manager as BorderManager;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1190,7 +1191,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
try {
|
||||
$record = $databox->get_record($record_id);
|
||||
$result->set_datas(array('record' => $this->list_record($record)));
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Record Not Found'));
|
||||
} catch (Exception $e) {
|
||||
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
|
||||
@@ -1214,7 +1215,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
try {
|
||||
$story = $databox->get_record($story_id);
|
||||
$result->set_datas(array('story' => $this->list_story($story)));
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found'));
|
||||
} catch (Exception $e) {
|
||||
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_AccountNotFound extends Exception_NotFound
|
||||
class Bridge_Exception_AccountNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_ActionForbidden extends Exception_Forbidden
|
||||
class Bridge_Exception_ActionForbidden extends AccessDeniedHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_ApiConnectorNotFound extends Exception_NotFound
|
||||
class Bridge_Exception_ApiConnectorNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_ApiNotFound extends Exception_NotFound
|
||||
class Bridge_Exception_ApiNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_ElementNotFound extends Exception_NotFound
|
||||
class Bridge_Exception_ElementNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bridge
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Bridge_Exception_TokenNotFound extends Exception_NotFound
|
||||
class Bridge_Exception_TokenNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_BadRequest extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Databox_CollectionNotFound extends Exception_NotFound
|
||||
class Exception_Databox_CollectionNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Databox_FieldNotFound extends Exception_NotFound
|
||||
class Exception_Databox_FieldNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Databox_SubdefNotFound extends Exception_NotFound
|
||||
class Exception_Databox_SubdefNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Databox_metadataDescriptionNotFound extends Exception_NotFound
|
||||
class Exception_Databox_metadataDescriptionNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_DataboxNotFound extends Exception_NotFound
|
||||
{
|
||||
|
||||
}
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Feed_EntryNotFound extends Exception_NotFound
|
||||
class Exception_Feed_EntryNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Feed_ItemNotFound extends Exception_NotFound
|
||||
class Exception_Feed_ItemNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Feed_PublisherNotFound extends Exception_NotFound
|
||||
class Exception_Feed_PublisherNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_FeedNotFound extends Exception_NotFound
|
||||
{
|
||||
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Forbidden extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Media_Subdef_PermalinkNotFound extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Media_SubdefNotFound extends Exception_NotFound
|
||||
class Exception_Media_SubdefNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_NotAllowed extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_NotFound extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Record_AdapterNotFound extends Exception_NotFound
|
||||
class Exception_Record_AdapterNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_ServiceUnavailable extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_AlreadyCreated extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_BadSalinity extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_Closed extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -9,13 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_LoggerNotFound extends Exception_NotFound
|
||||
class Exception_Session_LoggerNotFound extends NotFoundHttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_MailLocked extends Exception
|
||||
{
|
||||
protected $usr_id;
|
||||
|
||||
public function __construct($usr_id = null, $message = null, $code = null, $previous = null)
|
||||
{
|
||||
$this->usr_id = $usr_id;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function get_usr_id()
|
||||
{
|
||||
return $this->usr_id;
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_NotAuthenticated extends Exception_NotAllowed
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_RequireCaptcha extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_StorageClosed extends Exception_NotAllowed
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Session_WrongToken extends Exception
|
||||
{
|
||||
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_Unauthorized extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Exception
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Exception_UnauthorizedAction extends Exception_Abstract
|
||||
{
|
||||
|
||||
}
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -94,7 +95,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (!$row)
|
||||
throw new Exception_FeedNotFound ();
|
||||
throw new NotFoundHttpException('Feed not found');
|
||||
|
||||
$this->title = $row['title'];
|
||||
$this->subtitle = $row['subtitle'];
|
||||
@@ -464,7 +465,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
|
||||
return $feed;
|
||||
}
|
||||
|
||||
throw new Exception_FeedNotFound();
|
||||
throw new NotFoundHttpException('Feed not found');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -451,7 +453,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
|
||||
foreach ($rs as $item_id) {
|
||||
try {
|
||||
$items[] = new Feed_Entry_Item($this->app['phraseanet.appbox'], $this, $item_id);
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -514,7 +516,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
|
||||
|
||||
if ( ! $feed->is_public() && $feed->get_collection() instanceof Collection) {
|
||||
if ( ! $publisher->get_user()->ACL()->has_access_to_base($feed->get_collection()->get_base_id())) {
|
||||
throw new Exception_Unauthorized("User has no rights to publish in current feed");
|
||||
throw new AccessDeniedHttpException("User has no rights to publish in current feed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -74,7 +75,7 @@ class Feed_Token
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_FeedNotFound($token);
|
||||
throw new NotFoundHttpException('Feed not found.');
|
||||
|
||||
$this->feed_id = (int) $row['feed_id'];
|
||||
$this->usr_id = (int) $row['usr_id'];
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -42,7 +43,7 @@ class Feed_TokenAggregate extends Feed_Token
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ( ! $row)
|
||||
throw new Exception_FeedNotFound($token);
|
||||
throw new NotFoundHttpException('Feed not found.');
|
||||
|
||||
$this->usr_id = $row['usr_id'];
|
||||
$this->app = $app;
|
||||
|
@@ -15,6 +15,7 @@ use MediaAlchemyst\Specification\Image as ImageSpecification;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -436,7 +437,7 @@ class appbox extends base
|
||||
foreach ($this->retrieve_sbas_ids() as $sbas_id) {
|
||||
try {
|
||||
$ret[$sbas_id] = new \databox($this->app, $sbas_id);
|
||||
} catch (\Exception_DataboxNotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -476,7 +477,7 @@ class appbox extends base
|
||||
$databoxes = $this->get_databoxes();
|
||||
|
||||
if (!array_key_exists($sbas_id, $databoxes)) {
|
||||
throw new Exception_DataboxNotFound('Databox `' . $sbas_id . '` not found');
|
||||
throw new NotFoundHttpException('Databox `' . $sbas_id . '` not found');
|
||||
}
|
||||
|
||||
return $databoxes[$sbas_id];
|
||||
|
@@ -12,6 +12,7 @@
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class databox extends base
|
||||
{
|
||||
@@ -115,7 +116,7 @@ class databox extends base
|
||||
$connection_params = phrasea::sbas_params($this->app);
|
||||
|
||||
if ( ! isset($connection_params[$sbas_id])) {
|
||||
throw new Exception_DataboxNotFound(sprintf('databox %d not found', $sbas_id));
|
||||
throw new NotFoundHttpException(sprintf('databox %d not found', $sbas_id));
|
||||
}
|
||||
|
||||
$this->host = $connection_params[$sbas_id]['host'];
|
||||
@@ -147,7 +148,7 @@ class databox extends base
|
||||
}
|
||||
|
||||
if (!$row) {
|
||||
throw new Exception_DataboxNotFound(sprintf('databox %d not found', $sbas_id));
|
||||
throw new NotFoundHttpException(sprintf('databox %d not found', $sbas_id));
|
||||
}
|
||||
|
||||
$this->ord = $row['ord'];
|
||||
|
@@ -40,8 +40,8 @@ class module_console_systemClearCache extends Command
|
||||
->exclude('.git')
|
||||
->exclude('.svn')
|
||||
->in(array(
|
||||
__DIR__ . '/../../../../tmp/cache_minify/',
|
||||
__DIR__ . '/../../../../tmp/cache_twig/'
|
||||
$this->container['root.path'] . '/tmp/cache_minify/',
|
||||
$this->container['root.path'] . '/tmp/cache_twig/'
|
||||
));
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class module_console_taskState extends Command
|
||||
{
|
||||
@@ -80,7 +81,7 @@ class module_console_taskState extends Command
|
||||
$task = $task_manager->getTask($task_id);
|
||||
$taskPID = $task->getPID();
|
||||
$taskState = $task->getState();
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$output->writeln($input->getOption('short') ? 'unknown_id' : $e->getMessage());
|
||||
|
||||
return self::EXITCODE_TASK_UNKNOWN;
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -109,7 +110,7 @@ class patch_320f implements patchInterface
|
||||
try {
|
||||
$record = new record_adapter($app, phrasea::sbasFromBas($app, $row['base_id']), $row['record_id']);
|
||||
$item = Feed_Entry_Item::create($appbox, $entry, $record);
|
||||
} catch (Exception_NotFound $e) {
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user