Package org.wymiwyg.wrhapi.util

Examples of org.wymiwyg.wrhapi.util.AcceptHeaderEntry


  private boolean htmlPreferredInAccept(Request request) throws HandlerException {
    EnhancedRequest ehRequest = new EnhancedRequest(request);
    Iterator<AcceptHeaderEntry> iter = ehRequest.getAccept();
    while (iter.hasNext()) {
      AcceptHeaderEntry entry = iter.next();
      if (entry.getRange().match(xhtmlMimeType)) {
        return false;
      }
      if (entry.getRange().match(htmlMimeType)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here


   */
  private boolean isHtmlPreffered(EnhancedRequest request)
      throws HandlerException {
    Iterator<AcceptHeaderEntry> iterator = request.getAccept();
    while (iterator.hasNext()) {
      AcceptHeaderEntry element = iterator.next();
      MediaRange range = element.getRange();
      if (range.match(htmlType)) {
        return true;
      }
      if (range.match(xmlType)) {
        return false;
View Full Code Here

         * .getFullRequestURL().toString());
         */
        Resource requestedResource = model.getResource(ehRequest
                .getRequestURLWithoutParams().toString());
        if (!acceptIter.hasNext()) {
            currentBestChain = getHandlerChain(request, new AcceptHeaderEntry(
                    defaultMediaRange, 1), requestedResource,
                    authorizationInfo, ignoreAuthorization);
        } else {
            while ((currentBestChain == null) && acceptIter.hasNext()) {
                currentBestChain = getHandlerChain(request, acceptIter
View Full Code Here

  }
  private MimeType getPrefferedTarget(Request request) throws HandlerException {
    String[] acceptHeaderValues = request.getHeaderValues(HeaderName.ACCEPT);
    Iterator<AcceptHeaderEntry> acceptIter = new EnhancedRequest(request).getAccept();
    while (acceptIter.hasNext()) {
      AcceptHeaderEntry range = acceptIter.next();
      Iterator producedTargetIter = targetTypeSet.iterator();
      while (producedTargetIter.hasNext()) {
        MimeType currentTarget = (MimeType) producedTargetIter.next();
        if (range.getRange().match(currentTarget)) {
          return currentTarget;
        }
      }
    }
    log.warn("Content negotiation failed, using random");
View Full Code Here

      List<String> resultList = new ArrayList<String>();
      String[] original = super.getHeaderValues(headerName);
      for (int i = 0; i < original.length; i++) {
        String current = original[i];
        resultList.add(current);
        AcceptHeaderEntry headerEntry;
        try {
          headerEntry = new AcceptHeaderEntry(current);
        } catch (InvalidPatternException e) {
          log.warn(e.toString());
          continue;
        }
        MediaRange range = headerEntry.getRange();
        if (range.getAsterixCount() > 0) {
          continue;
        }
        StringBuffer buffer = new StringBuffer(40);
        buffer.append("application/xml; stylesheet=");
        try {
          buffer.append(URLEncoder.encode(range.toString(), "utf-8"));
        } catch (UnsupportedEncodingException e) {
          throw new RuntimeException(e);
        }
        buffer.append("; q=");
        buffer.append(headerEntry.getQ() * 0.9f);
        resultList.add(buffer.toString());
      }
      return resultList.toArray(new String[resultList.size()]);
    } else {
      return super.getHeaderValues(headerName);
View Full Code Here

      acceptIter = request.getAccept();
    } catch (HandlerException e) {
      throw new RuntimeException(e);
    }
    while (acceptIter.hasNext()) {
      AcceptHeaderEntry current = acceptIter.next();
      if (current.getRange().match(mimeType)) {
        return current.getQ();
      }
    }
    return 0;
  }
View Full Code Here

TOP

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

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.