示例#1
0
 @Override
 public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {
   delegate.writeAsEncodedUnicode(writer);
 }
示例#2
0
  public void doFilter(
      ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) servletRequest;
    RequestURIParts parts = parseParts(request);
    if (parts != null) {
      String realBaseAddress = parts.getBaseAddress();
      String idlPath = parts.getFilePath();
      InputStream idl = this.servletContext.getResourceAsStream(idlPath);
      if (idl != null) {
        servletResponse.setContentType("text/xml");
        String assumedBaseAddress = null;
        try {
          XMLEventReader eventReader = this.inputFactory.createXMLEventReader(idl);
          XMLEventWriter eventWriter =
              this.outputFactory.createXMLEventWriter(servletResponse.getWriter());
          while (eventReader.hasNext()) {
            XMLEvent event = eventReader.nextEvent();
            if (event.isProcessingInstruction()) {
              String target = ((ProcessingInstruction) event).getTarget();
              if ("enunciate-assumed-base-uri".equals(target)) {
                assumedBaseAddress = ((ProcessingInstruction) event).getData();
                if (assumedBaseAddress.endsWith("/")) {
                  assumedBaseAddress =
                      assumedBaseAddress.substring(0, assumedBaseAddress.length() - 1);
                }
              }
              continue;
            } else if (event.getEventType() == XMLStreamConstants.CDATA
                || event.getEventType() == XMLStreamConstants.CHARACTERS) {
              String data = ((Characters) event).getData();
              if (assumedBaseAddress != null && data.contains(assumedBaseAddress)) {
                data = data.replace(assumedBaseAddress, realBaseAddress);
                event = new DelegatingCharacters(((Characters) event), data);
              }
            } else if (event.getEventType() == XMLStreamConstants.START_ELEMENT) {
              List<Attribute> attributes = new ArrayList<Attribute>();
              Iterator attributesIt = ((StartElement) event).getAttributes();
              while (attributesIt.hasNext()) {
                Attribute attribute = (Attribute) attributesIt.next();
                String value = attribute.getValue();
                if (assumedBaseAddress != null && value.contains(assumedBaseAddress)) {
                  value = value.replace(assumedBaseAddress, realBaseAddress);
                  attribute = new DelegatingAttribute(attribute, value);
                  event = new DelegatingStartElement(((StartElement) event), attributes);
                }
                attributes.add(attribute);
              }
            }

            eventWriter.add(event);
          }

          eventReader.close();
          eventWriter.flush();
          eventWriter.close();
          return;
        } catch (XMLStreamException e) {
          throw new ServletException(e);
        }
      }
    }

    chain.doFilter(servletRequest, servletResponse);
  }
示例#3
0
 @Override
 public Characters asCharacters() {
   return delegate.asCharacters();
 }
示例#4
0
 @Override
 public QName getSchemaType() {
   return delegate.getSchemaType();
 }
示例#5
0
 @Override
 public StartElement asStartElement() {
   return delegate.asStartElement();
 }
示例#6
0
 @Override
 public EndElement asEndElement() {
   return delegate.asEndElement();
 }
示例#7
0
 @Override
 public boolean isCharacters() {
   return delegate.isCharacters();
 }
示例#8
0
 @Override
 public boolean isEndDocument() {
   return delegate.isEndDocument();
 }
示例#9
0
 @Override
 public boolean isEntityReference() {
   return delegate.isEntityReference();
 }
示例#10
0
 @Override
 public boolean isProcessingInstruction() {
   return delegate.isProcessingInstruction();
 }
示例#11
0
 @Override
 public boolean isNamespace() {
   return delegate.isNamespace();
 }
示例#12
0
 @Override
 public boolean isAttribute() {
   return delegate.isAttribute();
 }
示例#13
0
 @Override
 public boolean isStartElement() {
   return delegate.isStartElement();
 }
示例#14
0
 @Override
 public Location getLocation() {
   return delegate.getLocation();
 }
示例#15
0
 @Override
 public int getEventType() {
   return delegate.getEventType();
 }