Skip to content

Commit

Permalink
add write method without responseproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenHollmann committed Sep 6, 2022
1 parent eecf2f2 commit 80489bb
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ default boolean isSetContentType() {
*/
void write(T t, OutputStream out, ResponseProxy responseProxy) throws IOException, EncodingException;

/**
* Write object t to {@link OutputStream} out
*
* @param t Object to write
* @param out {@link OutputStream} to be written to
*
* @throws IOException If an error occurs during writing
* @throws EncodingException if an errors occurs during encoding
*
*/
void write(T t, OutputStream out) throws IOException, EncodingException;

/**
* Check if GZip is supported by this writer
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public Set<ResponseWriterKey> getKeys() {
@Override
public void write(EXIObject<XmlObject> exiObject, OutputStream out, ResponseProxy responseProxy)
throws IOException, EncodingException {
write(exiObject, out);
}

@Override
public void write(EXIObject<XmlObject> exiObject, OutputStream out) throws IOException, EncodingException {
byte[] bytes = getBytes(exiObject);
try (InputStream is = new ByteArrayInputStream(bytes)) {
EXIResult result = new EXIResult(this.exiFactory.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public Set<ResponseWriterKey> getKeys() {
@Override
public void write(JsonNode t, OutputStream out, ResponseProxy responseProxy)
throws IOException {
write(t, out);
}

@Override
public void write(JsonNode t, OutputStream out) throws IOException {
Json.print(out, t);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.n52.iceland.service.CommunicationObjectWithSoapHeader;
import org.n52.janmayen.http.HTTPStatus;
import org.n52.janmayen.http.MediaType;
import org.n52.shetland.w3c.soap.SoapHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public void write(SoapChain chain, OutputStream out, ResponseProxy responseProxy
}
}

private void write(SoapChain chain, OutputStream out) throws EncodingException, IOException {
@Override
public void write(SoapChain chain, OutputStream out) throws EncodingException, IOException {
String namespace = chain.getSoapResponse().getSoapNamespace();
EncoderKey key = CodingHelper.getEncoderKey(namespace, chain.getSoapResponse());
Encoder<?, SoapResponse> encoder = getEncoder(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public Set<ResponseWriterKey> getKeys() {
@Override
public void write(XmlObject xml, OutputStream out,
ResponseProxy responseProxy) throws IOException {
write(xml, out);
}

@Override
public void write(XmlObject xml, OutputStream out) throws IOException {
xml.save(out, this.xmlOptions.get());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;

import org.n52.iceland.coding.encode.ResponseWriter;
import org.n52.iceland.coding.encode.ResponseWriterFactory;
import org.n52.iceland.coding.encode.ResponseWriterKey;
Expand Down

0 comments on commit 80489bb

Please sign in to comment.