Search in sources :

Example 1 with FilterScript

use of com.enonic.xp.portal.filter.FilterScript in project xp by enonic.

the class MappingFilterHandlerWorker method execute.

@Override
public PortalResponse execute() throws Exception {
    final Trace trace = Tracer.current();
    if (trace != null) {
        trace.put("contentPath", this.request.getContentPath().toString());
        trace.put("type", "filter");
    }
    final FilterScript filterScript = getScript();
    return filterScript.execute(this.request, this.response, this.webHandlerChain);
}
Also used : Trace(com.enonic.xp.trace.Trace) FilterScript(com.enonic.xp.portal.filter.FilterScript)

Example 2 with FilterScript

use of com.enonic.xp.portal.filter.FilterScript in project xp by enonic.

the class FilterScriptImplTest method execute.

protected final void execute(final String script, final WebHandlerChain webHandlerChain) {
    final FilterScript controllerScript = this.factory.fromScript(ResourceKey.from(script));
    this.portalResponse = controllerScript.execute(this.portalRequest, this.portalResponse, webHandlerChain);
}
Also used : FilterScript(com.enonic.xp.portal.filter.FilterScript)

Example 3 with FilterScript

use of com.enonic.xp.portal.filter.FilterScript in project xp by enonic.

the class MappingHandlerTest method setup.

@BeforeEach
public final void setup() throws Exception {
    this.request = new PortalRequest();
    final ControllerScriptFactory controllerScriptFactory = mock(ControllerScriptFactory.class);
    ControllerScript controllerScript = mock(ControllerScript.class);
    when(controllerScriptFactory.fromDir(Mockito.any())).thenReturn(controllerScript);
    final PortalResponse portalResponse = PortalResponse.create().build();
    when(controllerScript.execute(Mockito.any())).thenReturn(portalResponse);
    FilterScriptFactory filterScriptFactory = mock(FilterScriptFactory.class);
    FilterScript filterScript = mock(FilterScript.class);
    when(filterScriptFactory.fromScript(Mockito.any())).thenReturn(filterScript);
    when(filterScript.execute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(portalResponse);
    this.resourceService = mock(ResourceService.class);
    final Resource resourceNotFound = mock(Resource.class);
    when(resourceNotFound.exists()).thenReturn(false);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(this.resourceService.getResource(ResourceKey.from("demo:/services/test"))).thenReturn(resource);
    this.contentService = mock(ContentService.class);
    this.rendererDelegate = mock(RendererDelegate.class);
    this.siteService = mock(SiteService.class);
    this.handler = new MappingHandler(resourceService, controllerScriptFactory, filterScriptFactory, rendererDelegate, new ControllerMappingsResolver(siteService), new ContentResolver(contentService));
    this.request.setMethod(HttpMethod.GET);
}
Also used : FilterScriptFactory(com.enonic.xp.portal.filter.FilterScriptFactory) ControllerScript(com.enonic.xp.portal.controller.ControllerScript) FilterScript(com.enonic.xp.portal.filter.FilterScript) ResourceService(com.enonic.xp.resource.ResourceService) Resource(com.enonic.xp.resource.Resource) ContentService(com.enonic.xp.content.ContentService) ControllerScriptFactory(com.enonic.xp.portal.controller.ControllerScriptFactory) PortalRequest(com.enonic.xp.portal.PortalRequest) ContentResolver(com.enonic.xp.portal.impl.ContentResolver) PortalResponse(com.enonic.xp.portal.PortalResponse) SiteService(com.enonic.xp.site.SiteService) RendererDelegate(com.enonic.xp.portal.impl.rendering.RendererDelegate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

FilterScript (com.enonic.xp.portal.filter.FilterScript)3 ContentService (com.enonic.xp.content.ContentService)1 PortalRequest (com.enonic.xp.portal.PortalRequest)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)1 ControllerScriptFactory (com.enonic.xp.portal.controller.ControllerScriptFactory)1 FilterScriptFactory (com.enonic.xp.portal.filter.FilterScriptFactory)1 ContentResolver (com.enonic.xp.portal.impl.ContentResolver)1 RendererDelegate (com.enonic.xp.portal.impl.rendering.RendererDelegate)1 Resource (com.enonic.xp.resource.Resource)1 ResourceService (com.enonic.xp.resource.ResourceService)1 SiteService (com.enonic.xp.site.SiteService)1 Trace (com.enonic.xp.trace.Trace)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1