Package com.agiletec.aps.system.services.lang

Examples of com.agiletec.aps.system.services.lang.Lang


public class EntryContentInterceptor extends AbstractInterceptor {
 
  @Override
  public String intercept(ActionInvocation invocation) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    Lang currentLang = (Lang) request.getSession().getAttribute(JpFrontShortcutSystemConstants.CONTENT_LANG_SESSION_PARAM);
    if (null == currentLang) {
      ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, request);
      currentLang = langManager.getDefaultLang();
    }
    Locale locale = new Locale(currentLang.getCode(), "");
    invocation.getInvocationContext().setLocale(locale);
    return invocation.invoke();
  }
View Full Code Here


    }

  public String getRedirectUrl() {
    if (this.getStrutsAction() != ApsAdminSystemConstants.EDIT) {
      String langCode = this.getLangCode();
      Lang lang = (null != langCode) ? this.getLangManager().getLang(langCode) : this.getLangManager().getDefaultLang();
      if (null == lang) {
        lang = this.getLangManager().getDefaultLang();
      }
      String pageCode = this.getPageCode();
      IPage page = this.getPage(pageCode);
View Full Code Here

        attribute.setDisablingCodes(this.createNewCodes(attribute.getDisablingCodes()));
        if (null != this.getAttributeName() && !this.getAttributeName().contains(attribute.getName())) {
          attribute.disable(JpFrontShortcutSystemConstants.WIDGET_DISABLING_CODE);
        }
      }
      Lang currentLang = super.getCurrentLang();
      this.getRequest().getSession()
          .setAttribute(JpFrontShortcutSystemConstants.CONTENT_LANG_SESSION_PARAM, currentLang);
    } catch (Throwable t) {
            ApsSystemUtils.logThrowable(t, this, "edit");
            return FAILURE;
View Full Code Here

  }
   
  protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
    try {
      ApsProperties properties = new ApsProperties();
      Lang defaultLang = super.getLangManager().getDefaultLang();
      properties.put(defaultLang.getCode(), defaultValue);
      this.getI18nManager().addLabelGroup(key, properties);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
      throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
    }
View Full Code Here

      IFacetNavHelper facetNavHelper = (IFacetNavHelper) ApsWebApplicationUtils.getBean(JpFacetNavSystemConstants.CONTENT_FACET_NAV_HELPER, this.pageContext);
      ITreeNodeManager facetManager =  facetNavHelper.getTreeNodeManager();
      ITreeNode facetNode = facetManager.getNode(this.getFacetNodeCode());
      String separator = (this.getSeparator() == null) ? " / " : this.getSeparator();
      if (null != facetNode) {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String title = facetNode.getTitles().getProperty(currentLang.getCode());
        if (this.isFullTitle()) {
          title = facetNode.getFullTitle(currentLang.getCode(), separator);
        }
        if (null == title || title.trim().length() == 0) {
          ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
          Lang defaultLang = langManager.getDefaultLang();
          title = facetNode.getTitles().getProperty(defaultLang.getCode());
          if (this.isFullTitle()) {
            title = facetNode.getFullTitle(defaultLang.getCode(), separator);
          }
        }
        if (null == title || title.trim().length() == 0) {
          title = this.getFacetNodeCode();
        }
View Full Code Here

   * Create link for email confirmation
   */
  protected String createLink(String pageCode, String userName, String token, String langcode) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("token", token);
    Lang lang = this.getLangManager().getLang(langcode);
    IPage page = this.getPageManager().getPage(pageCode);
    if (null == page) {
      page = this.getPageManager().getRoot();
    }
    return this.getUrlManager().createUrl(page, lang, params);
View Full Code Here

  }

  private void checkTemplates(Map<String, Template> templates, String fieldName) {
    Iterator<Lang> langs = this.getLangManager().getLangs().iterator();
    while (langs.hasNext()) {
      Lang lang = langs.next();
      Template template = templates.get(lang.getCode());
      if (template==null) {
        this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
      } else {
        String subject = template.getSubject();
        if (subject==null || subject.trim().length()==0) {
          this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.subject.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
        }
        String body = template.getBody();
        if (body==null || body.trim().length()==0) {
          this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.body.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
        }
      }
    }
  }
View Full Code Here

  }

  protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
    try {
      ApsProperties properties = new ApsProperties();
      Lang defaultLang = super.getLangManager().getDefaultLang();
      properties.put(defaultLang.getCode(), defaultValue);
      this.getI18nManager().addLabelGroup(key, properties);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
      throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
    }
View Full Code Here

   */
  private StatsRecord loadStatsRecord(RequestContext reqCtx) {
    HttpServletRequest req = reqCtx.getRequest();
    HttpSession session = req.getSession();
    StatsRecord statsRecord = new StatsRecord(Calendar.getInstance());
    Lang lang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
    Page page = (Page) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
    statsRecord.setIp(reqCtx.getRequest().getRemoteAddr());
    statsRecord.setReferer(reqCtx.getRequest().getHeader("Referer"));
    statsRecord.setSessionId(session.getId());
    UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
    StringBuffer rolesBuffer = new StringBuffer();
    boolean isFirstRole = true;
    IApsAuthority[] auths = currentUser.getAuthorities();
    for (int i=0; i<auths.length; i++) {
      if (auths[i] instanceof Role) {
        Role role = (Role) auths[i];
        if (!isFirstRole) rolesBuffer.append(" - ");
        rolesBuffer.append(role.getName());
        isFirstRole = false;
      }
    }
    statsRecord.setRole(rolesBuffer.toString());
    NumberFormat formato = NumberFormat.getIntegerInstance(java.util.Locale.ITALIAN);
    formato.setMinimumIntegerDigits(2);
    String contentId = this.getContentId(page);
    statsRecord.setPageCode(page.getCode());
    statsRecord.setLangcode(lang.getCode());
    statsRecord.setUseragent(reqCtx.getRequest().getHeader("User-Agent"));
    statsRecord.setBrowserLang(reqCtx.getRequest().getHeader("accept-language"));
    statsRecord.setContentId(contentId);
    return statsRecord;
  }
View Full Code Here

   * Used to get all the localized field coming from the form
   */
  private void fetchLocalizedFields() {
    Iterator<Lang> itr = this.getLangManager().getLangs().iterator();
    while (itr.hasNext()) {
      Lang currentLang = itr.next();
      Lang defaultLanguage = this.getLangManager().getDefaultLang();
      String currentLangCode = currentLang.getCode();
      String questionKey = "question-" + currentLangCode;
      String question = this.getRequest().getParameter(questionKey);
      if (null != question && question.trim().length() > 0) {
        this.getQuestions().put(currentLangCode, question.trim());
      } else {
        if (currentLang.getCode().equals(defaultLanguage.getCode())) {
          this.addActionError(this.getText("message.jpsurvey.defaultLangRequired", new String[]{defaultLanguage.getDescr(),this.getText("question")}));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.agiletec.aps.system.services.lang.Lang

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.