Package org.wymiwyg.wrhapi.util

Examples of org.wymiwyg.wrhapi.util.AcceptLanguagesIterator


     */
    public void setBody(Object body) throws HandlerException {
        if (transform) {
         
            final URL requestBaseURL = ehRequest.getRequestURLWithoutParams();
            AcceptLanguagesIterator langIter = ehRequest.getAcceptLanguages();
            final List<Locale> localeList = new ArrayList<Locale>();
            while (langIter.hasNext()) {
                AcceptLanguageHeaderEntry current = (AcceptLanguageHeaderEntry) langIter
                        .next();
                Locale locale = current.getLocaleRange().getLocale();
                //TODO use ranges
                if (locale != null) {
                  localeList.add(locale);
View Full Code Here


      } catch (Exception e) {
        log.error("invalid language " + current, e);
      }
    }
    List languageSelectionList = new ArrayList();
    AcceptLanguagesIterator acceptIter = request.getAcceptLanguages();
    while (acceptIter.hasNext()) {
      AcceptLanguageHeaderEntry current = acceptIter.nextAcceptLanguageHeader();
      Locale locale = current.getLocaleRange().getLocale();
      if (locale == null) {
        continue;
      }
      String abbreviation = locale.getLanguage();
View Full Code Here

    if ((cookieValue != null) && (!cookieValue.equals(""))) {
      request = new RequestWrapper(ehRequest, cookieValue);
    } else {
      //silly, this is set only because adobe reader < 7 used together with Internet Explorer does not sent the accept-language header
      List languagesForCookie = new ArrayList();
      AcceptLanguagesIterator langIter = ehRequest.getAcceptLanguages();
      while (langIter.hasNext()) {
        languagesForCookie.add(langIter.nextAcceptLanguageHeader().getLocaleRange());
      }
      CookieLangSetter.setCookieLang(response, languagesForCookie);
    }
    try {
      cookieValue = CookieLangSetter.setCookieLangFromParams(request, response);
View Full Code Here

                languagesForCookie.add(replaceLang[i]);

            }
        }
        if (languagesForCookie.size() == 0) {
            AcceptLanguagesIterator iterator = new EnhancedRequest(request)
                    .getAcceptLanguages();
            while (iterator.hasNext()) {
                languagesForCookie.add(iterator.nextAcceptLanguageHeader()
                        .getLocaleRange().getLocale().getLanguage());
            }
        }
        if (appendLang != null) {
            for (int i = 0; i < appendLang.length; i++) {
View Full Code Here

      } else {
        forceShow = false;
      }
    }
    List localesList = new ArrayList();
    AcceptLanguagesIterator iterator = request.getAcceptLanguages();
    while (iterator.hasNext()) {
      LocaleRange localeRange = iterator.nextAcceptLanguageHeader()
      .getLocaleRange();
      Locale current = localeRange.getLocale();
      if (current == null) {
        forceShow = true;
        continue;
View Full Code Here

        if (!model.contains(item, RDF.type, RSS.item)) {
            chain.doNext(request, response);
            return;
        }
        TopicGetHandler.checkLanguageAvailability(item, ehRequest);
        AcceptLanguagesIterator acceptedLanguages = ehRequest
                .getAcceptLanguages();
        List acceptLanguagesStringList = new ArrayList();
        while (acceptedLanguages.hasNext()) {
            String current = acceptedLanguages.nextAcceptLanguageHeader()
                    .getLocaleRange().getLocale().getLanguage();
            acceptLanguagesStringList.add(current);
        }
        int maxBackwardLinks;
        try {
View Full Code Here

   * @param resultModel
   * @throws HandlerException
   */
  private void removeNotMatchingLangAttach(Model resultModel,
      EnhancedRequest ehRequest) throws HandlerException {
    AcceptLanguagesIterator langIter = ehRequest.getAcceptLanguages();
    Collection acceptedLang = new HashSet();
    while (langIter.hasNext()) {
      acceptedLang.add(langIter.nextAcceptLanguageHeader()
          .getLocaleRange().getLocale().getLanguage());
    }
    StmtIterator attachments = resultModel.listStatements(null,
        ATTACH.attachments, (Resource) null);
    while (attachments.hasNext()) {
View Full Code Here

      log.warn("topic/item " + resource
          + " has no dc-langugae attribute, assuming en");
      languageSet.add("en");

    }
    AcceptLanguagesIterator acceptLanguages = ehRequest
        .getAcceptLanguages();
    while (acceptLanguages.hasNext()) {
      if (languageSet.contains(acceptLanguages.nextAcceptLanguageHeader()
          .getLocaleRange().getLocale().getLanguage())) {
        return;
      }
    }
    LanguageUnavailableException langEx = new LanguageUnavailableException(
View Full Code Here

   * @param resultModel
   * @throws HandlerException
   */
  private void removeNotMatchingLangAttach(Model resultModel,
      EnhancedRequest ehRequest) throws HandlerException {
    AcceptLanguagesIterator langIter = ehRequest.getAcceptLanguages();
    /*Collection acceptedLang = new HashSet();
    while (langIter.hasNext()) {
      acceptedLang.add(langIter.nextAcceptLanguageHeader()
          .getLocaleRange().getLocale().getLanguage());
    }*/
    StmtIterator attachments = resultModel.listStatements(null,
        ATTACH.attachments, (Resource) null);
    while (attachments.hasNext()) {
      Seq currentSeq = attachments.nextStatement().getSeq();
      for (int i = 1; i <= currentSeq.size(); i++) {
        Resource currentAttachment;
        try {
          currentAttachment = currentSeq.getResource(i);
        } catch (PropertyNotFoundException ex) {
          log.warn("inconsisten seq");
          continue;
        }
        Statement langStmt = currentAttachment.getProperty(DC.language);
        if (langStmt == null) {
          continue;
        }
        String lang = langStmt.getString();
        Locale locale = new Locale(lang);
        boolean matches = false;
        while (langIter.hasNext()) {
          if (langIter.nextAcceptLanguageHeader()
              .getLocaleRange().match(locale)) {
            matches = true;
          }
        }
        if (!matches) {
View Full Code Here

      log.warn("topic/item " + resource
          + " has no dc-langugae attribute, assuming en");
      languageSet.add("en");

    }
    AcceptLanguagesIterator acceptLanguages = ehRequest
        .getAcceptLanguages();
    while (acceptLanguages.hasNext()) {
      Locale acceptedLocale = acceptLanguages.nextAcceptLanguageHeader()
          .getLocaleRange().getLocale();
      if (acceptedLocale == null) {
        return;
      }
      if (languageSet.contains(acceptedLocale.getLanguage())) {
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.util.AcceptLanguagesIterator

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.