Search in sources :

Example 6 with ILangManager

use of com.agiletec.aps.system.services.lang.ILangManager in project entando-core by entando.

the class ResourceAttributeActionHelper method removeResource.

private static void removeResource(AttributeInterface attribute, HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        removeResource(includedAttribute, request);
    } else if (attribute instanceof AbstractResourceAttribute) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, request);
        String langCode = (String) session.getAttribute(RESOURCE_LANG_CODE_SESSION_PARAM);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) attribute;
        if (langCode == null || langCode.length() == 0 || langManager.getDefaultLang().getCode().equals(langCode)) {
            resourceAttribute.getResources().clear();
            resourceAttribute.getTextMap().clear();
        } else {
            resourceAttribute.setResource(null, langCode);
            resourceAttribute.setText(null, langCode);
        }
    } else if (attribute instanceof MonoListAttribute) {
        int elementIndex = ((Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM)).intValue();
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex);
        removeResource(attributeElement, request);
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) HttpSession(javax.servlet.http.HttpSession) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 7 with ILangManager

use of com.agiletec.aps.system.services.lang.ILangManager in project entando-core by entando.

the class TracerFactoryTag method getBean.

@Override
public Component getBean(ValueStack valueStack, HttpServletRequest req, HttpServletResponse res) {
    String langCode = this.getActualValue(this.getLang());
    ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, req);
    Lang lang = langManager.getLang(langCode);
    TracerFactory tracerFactory = new TracerFactory(valueStack, lang);
    valueStack.getContext().put(this.getVar(), tracerFactory.getAttributeTracer());
    return tracerFactory;
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 8 with ILangManager

use of com.agiletec.aps.system.services.lang.ILangManager in project entando-core by entando.

the class BaseTestCase method createRequestContext.

protected RequestContext createRequestContext(ApplicationContext applicationContext, ServletContext srvCtx) {
    RequestContext reqCtx = new RequestContext();
    srvCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(RequestContext.REQCTX, reqCtx);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockHttpSession session = new MockHttpSession(srvCtx);
    request.setSession(session);
    reqCtx.setRequest(request);
    reqCtx.setResponse(response);
    ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
    Lang defaultLang = langManager.getDefaultLang();
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, defaultLang);
    return reqCtx;
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpSession(org.springframework.mock.web.MockHttpSession) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 9 with ILangManager

use of com.agiletec.aps.system.services.lang.ILangManager in project entando-core by entando.

the class TestApplicationContext method testGetServices.

public void testGetServices() {
    ConfigInterface configManager = (ConfigInterface) this.getService(SystemConstants.BASE_CONFIG_MANAGER);
    assertNotNull(configManager);
    ICacheInfoManager cacheInfoManager = (ICacheInfoManager) this.getService(SystemConstants.CACHE_INFO_MANAGER);
    assertNotNull(cacheInfoManager);
    ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
    assertNotNull(langManager);
    IWidgetTypeManager showletTypeManager = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
    assertNotNull(showletTypeManager);
    IPageModelManager pageModelManager = (IPageModelManager) this.getService(SystemConstants.PAGE_MODEL_MANAGER);
    assertNotNull(pageModelManager);
    IPageManager pageManager = (IPageManager) this.getService(SystemConstants.PAGE_MANAGER);
    assertNotNull(pageManager);
    IRoleManager roleManager = (IRoleManager) this.getService(SystemConstants.ROLE_MANAGER);
    assertNotNull(roleManager);
    IUserManager userManager = (IUserManager) this.getService(SystemConstants.USER_MANAGER);
    assertNotNull(userManager);
    IURLManager urlManager = (IURLManager) this.getService(SystemConstants.URL_MANAGER);
    assertNotNull(urlManager);
    II18nManager i18nManager = (II18nManager) this.getService(SystemConstants.I18N_MANAGER);
    assertNotNull(i18nManager);
    // ControllerManager controller = (ControllerManager) this.getService(SystemConstants.CONTROLLER_MANAGER);
    // assertNotNull(controller);
    IKeyGeneratorManager keyGeneratorManager = (IKeyGeneratorManager) this.getService(SystemConstants.KEY_GENERATOR_MANAGER);
    assertNotNull(keyGeneratorManager);
    ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
    assertNotNull(categoryManager);
}
Also used : IPageManager(com.agiletec.aps.system.services.page.IPageManager) ICacheInfoManager(org.entando.entando.aps.system.services.cache.ICacheInfoManager) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) IUserManager(com.agiletec.aps.system.services.user.IUserManager) IRoleManager(com.agiletec.aps.system.services.role.IRoleManager) IURLManager(com.agiletec.aps.system.services.url.IURLManager) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) IKeyGeneratorManager(com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager) II18nManager(com.agiletec.aps.system.services.i18n.II18nManager) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 10 with ILangManager

use of com.agiletec.aps.system.services.lang.ILangManager in project entando-core by entando.

the class ApiRestServer method extractProperties.

protected Properties extractProperties(String langCode, UriInfo ui, HttpServletRequest request) throws Throwable {
    ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, request);
    Properties properties = this.extractRequestParameters(ui);
    if (null == langManager.getLang(langCode)) {
        langCode = langManager.getDefaultLang().getCode();
    }
    String applicationBaseUrl = this.extractApplicationBaseUrl(request);
    if (null != applicationBaseUrl) {
        properties.put(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER, applicationBaseUrl);
    }
    properties.put(SystemConstants.API_LANG_CODE_PARAMETER, langCode);
    properties.put(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER, this.extractProducesMediaType(request));
    return properties;
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager)

Aggregations

ILangManager (com.agiletec.aps.system.services.lang.ILangManager)17 Lang (com.agiletec.aps.system.services.lang.Lang)8 RequestContext (com.agiletec.aps.system.RequestContext)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 ConfigInterface (com.agiletec.aps.system.services.baseconfig.ConfigInterface)3 ServletRequest (javax.servlet.ServletRequest)3 DataSource (javax.sql.DataSource)3 IURLManager (com.agiletec.aps.system.services.url.IURLManager)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)2 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)1 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)1 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)1 II18nManager (com.agiletec.aps.system.services.i18n.II18nManager)1 IKeyGeneratorManager (com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)1 IRoleManager (com.agiletec.aps.system.services.role.IRoleManager)1