Search in sources :

Example 36 with Lang

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

the class AbstractPageActionHelper method getVirtualRoot.

/**
 * Metodo a servizio della costruzione dell'albero delle pagine. Nel caso
 * che l'utente corrente non sia abilitato alla visualizzazione del nodo
 * root, fornisce un nodo "virtuale" nel quale inserire gli eventuali nodi
 * visibili.
 *
 * @return Il nodo root virtuale.
 */
private PageTreeNodeWrapper getVirtualRoot() {
    PageTreeNodeWrapper virtualRoot = new PageTreeNodeWrapper();
    virtualRoot.setCode(AbstractPortalAction.VIRTUAL_ROOT_CODE);
    List<Lang> langs = this.getLangManager().getLangs();
    for (int i = 0; i < langs.size(); i++) {
        Lang lang = langs.get(i);
        virtualRoot.setTitle(lang.getCode(), "ROOT");
    }
    return virtualRoot;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) PageTreeNodeWrapper(org.entando.entando.apsadmin.portal.node.PageTreeNodeWrapper)

Example 37 with Lang

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

the class LangAction method remove.

public String remove() {
    try {
        Lang langToRemove = this.getLangManager().getLang(this.getLangCode());
        if (null == langToRemove || langToRemove.isDefault()) {
            this.addActionError(this.getText("error.lang.removeDefault"));
            return INPUT;
        }
        this.getLangManager().removeLang(this.getLangCode());
    } catch (Throwable t) {
        _logger.error("error in remove", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 38 with Lang

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

the class ContentPreviewAction method prepareForward.

private void prepareForward(String pageDestCode) throws IOException {
    Lang currentLang = this.getLangManager().getLang(this.getPreviewLangCode());
    if (null == currentLang) {
        currentLang = this.getLangManager().getDefaultLang();
    }
    IPageManager pageManager = this.getPageManager();
    IPage pageDest = pageManager.getOnlinePage(pageDestCode);
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("contentOnSessionMarker", this.getContentOnSessionMarker());
    String redirectUrl = this.getUrlManager().createURL(pageDest, currentLang, parameters, false);
    this.getServletResponse().sendRedirect(redirectUrl);
}
Also used : IPageManager(com.agiletec.aps.system.services.page.IPageManager) IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 39 with Lang

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

the class TestRequestValidator method testService.

public void testService() throws ApsSystemException {
    RequestContext reqCtx = this.getRequestContext();
    ((MockHttpServletRequest) reqCtx.getRequest()).setServletPath("/it/homepage.wp");
    int status = this._requestValidator.service(reqCtx, ControllerManager.CONTINUE);
    assertEquals(ControllerManager.CONTINUE, status);
    Lang lang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
    IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
    assertNotNull(page);
    assertNotNull(lang);
    assertEquals("it", lang.getCode());
    assertEquals("homepage", page.getCode());
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext)

Example 40 with Lang

use of com.agiletec.aps.system.services.lang.Lang 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)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4