Skip to content
Permalink
Browse files

Merge branch 'PRESIDECMS-1585_postReadRestResourceDirectories-interce…

…ption-point' of https://github.com/sebduggan/Preside-CMS into hotfix-10.10.71
  • Loading branch information...
DominicWatson committed Jun 7, 2019
2 parents 33c8da3 + 418eb56 commit de91698e2ff6252accdf4468c3cf1f8c2db31273
@@ -62,7 +62,7 @@ component extends="testbox.system.BaseSpec"{

var log = restService.$callLog()._announceInterception;
expect( log.len() > 0 ).toBe( true );
expect( log[1] ).toBe([ "onRestRequest", { restRequest=restRequest, restResponse=restResponse } ]);
expect( log[2] ).toBe([ "onRestRequest", { restRequest=restRequest, restResponse=restResponse } ]);
} );

it( "it should call processRequest to handle the request", function(){
@@ -1146,23 +1146,26 @@ component extends="testbox.system.BaseSpec"{
variables.mockValidationEngine = createMock( "preside.system.services.validation.ValidationEngine" ).init();
variables.mockI18n = createMock( "preside.system.services.i18n.i18n" );

var restService = createMock( object=new preside.system.services.rest.PresideRestService(
controller = mockController
, resourceDirectories = [ "/resources/rest/dir1", "/resources/rest/dir2" ]
, configurationWrapper = mockConfigWrapper
, authService = mockAuthService
, validationEngine = mockValidationEngine
, i18n = mockI18n
) );
var restService = createMock( "preside.system.services.rest.PresideRestService" );

restService.$( "_announceInterception" );
restService.$( "$announceInterception" );
restService.$( "$raiseError" );
restService.$( "authenticateRequest" );
restService.$( "$getRequestContext", mockRequestContext );
mockRequestContext.$( "cachePage" );
mockRequestContext.$( "setRestResponse" );
mockRequestContext.$( "setRestRequest" );

restService.init(
controller = mockController
, resourceDirectories = [ "/resources/rest/dir1", "/resources/rest/dir2" ]
, configurationWrapper = mockConfigWrapper
, authService = mockAuthService
, validationEngine = mockValidationEngine
, i18n = mockI18n
);

return restService;
}

@@ -108,6 +108,7 @@ component {
interceptorSettings.customInterceptionPoints.append( "onReturnFile304" );
interceptorSettings.customInterceptionPoints.append( "preDownloadAsset" );
interceptorSettings.customInterceptionPoints.append( "onDownloadAsset" );
interceptorSettings.customInterceptionPoints.append( "postReadRestResourceDirectories" );
interceptorSettings.customInterceptionPoints.append( "onRestRequest" );
interceptorSettings.customInterceptionPoints.append( "onRestError" );
interceptorSettings.customInterceptionPoints.append( "onMissingRestResource" );
@@ -354,6 +354,7 @@ component {
var resourceReader = new PresideRestResourceReader();
var apis = resourceReader.readResourceDirectories( arguments.resourceDirectories );

_announceInterception( "postReadRestResourceDirectories", { apis=apis } );
_setApis( apis );
}

@@ -370,7 +371,7 @@ component {

private void function _announceInterception( required string state, struct interceptData={} ) {
try {
_getInterceptorService().processState( argumentCollection=arguments );
$announceInterception( argumentCollection=arguments );
} catch( any e ) {
$raiseError( e );

@@ -386,10 +387,6 @@ component {
}
}

private any function _getInterceptorService() {
return _getController().getInterceptorService();
}

private void function _dealWithEtags( required any restRequest, required any restResponse, required any requestContext ) {
if ( [ "HEAD", "GET" ].findNoCase( restRequest.getVerb() ) ) {
var etag = setEtag( restResponse );

0 comments on commit de91698

Please sign in to comment.
You can’t perform that action at this time.