Search in sources :

Example 6 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class BaseTestCase method setUp.

@Override
protected void setUp() throws Exception {
    try {
        super.setUp();
        ServletContext srvCtx = new MockServletContext("", new FileSystemResourceLoader());
        ApplicationContext applicationContext = this.getConfigUtils().createApplicationContext(srvCtx);
        this.setApplicationContext(applicationContext);
        RequestContext reqCtx = this.createRequestContext(applicationContext, srvCtx);
        this.setRequestContext(reqCtx);
        this.setUserOnSession("guest");
    } catch (Exception e) {
        throw e;
    }
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) FileSystemResourceLoader(org.springframework.core.io.FileSystemResourceLoader) ServletContext(javax.servlet.ServletContext) MockServletContext(org.springframework.mock.web.MockServletContext) RequestContext(com.agiletec.aps.system.RequestContext) MockServletContext(org.springframework.mock.web.MockServletContext)

Example 7 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class SystemInfoWrapper method getActionPathUrl.

public String getActionPathUrl(String actionPath) {
    String url = null;
    RequestContext reqCtx = this.getReqCtx();
    IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, reqCtx.getRequest());
    try {
        PageURL pageUrl = urlManager.createURL(reqCtx);
        IPage currPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        pageUrl.setPage(currPage);
        pageUrl.addParam(InternalServletTag.REQUEST_PARAM_ACTIONPATH, actionPath);
        pageUrl.addParam(InternalServletTag.REQUEST_PARAM_FRAMEDEST, currentFrame.toString());
        url = pageUrl.getURL();
    } catch (Throwable t) {
        _logger.error("Error getting path for action path: {}", actionPath, t);
        return null;
    }
    return url;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) PageURL(com.agiletec.aps.system.services.url.PageURL) IURLManager(com.agiletec.aps.system.services.url.IURLManager) RequestContext(com.agiletec.aps.system.RequestContext)

Example 8 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentListHelper method valueRequestContext.

private RequestContext valueRequestContext(String pageCode, int frame) throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    try {
        Widget widgetToAdd = this.getShowletForTest("content_viewer_list", null);
        this.setPageWidgets(pageCode, frame, widgetToAdd);
        IPage page = this._pageManager.getOnlinePage(pageCode);
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
        Widget widget = page.getWidgets()[frame];
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
    } catch (Throwable t) {
        this.setPageWidgets(pageCode, frame, null);
        throw t;
    }
    return reqCtx;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 9 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentListHelper method testGetContents_1.

public void testGetContents_1() throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    try {
        this.setUserOnSession("guest");
        RequestContext reqCtx = this.valueRequestContext(pageCode, frame);
        MockContentListTagBean bean = new MockContentListTagBean();
        bean.setContentType("EVN");
        EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true);
        filter.setOrder(EntitySearchFilter.DESC_ORDER);
        bean.addFilter(filter);
        List<String> contents = this._helper.getContentsId(bean, reqCtx);
        String[] expected = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
        assertEquals(expected.length, contents.size());
        for (int i = 0; i < expected.length; i++) {
            assertEquals(expected[i], contents.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this.setPageWidgets(pageCode, frame, null);
    }
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 10 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentDispenser method testGetRenderedContent_3.

public void testGetRenderedContent_3() throws Throwable {
    Content content = this._contentManager.loadContent("ART120", true);
    content.setId(null);
    try {
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        this._contentManager.insertOnLineContent(content);
        ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(content.getId(), 2, "it", reqCtx);
        assertNotNull(outputInfo);
        assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX + content.getId()));
        this._contentManager.insertOnLineContent(content);
        this.waitNotifyingThread();
        assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX + content.getId()));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != content.getId()) {
            this._contentManager.deleteContent(content);
        }
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)89 ServletRequest (javax.servlet.ServletRequest)25 JspException (javax.servlet.jsp.JspException)22 IPage (com.agiletec.aps.system.services.page.IPage)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Widget (com.agiletec.aps.system.services.page.Widget)5 NavigatorTarget (com.agiletec.aps.system.services.page.widget.NavigatorTarget)5 IURLManager (com.agiletec.aps.system.services.url.IURLManager)5 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)5 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)5 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)4 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ControllerManager (com.agiletec.aps.system.services.controller.ControllerManager)3 HeadInfoContainer (com.agiletec.aps.tags.util.HeadInfoContainer)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)3 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)3