Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version.arctic-sea from 9.7.0 to 9.8.0 #1443

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@
*
*/
public class AbstractServiceResponseWriter extends AbstractResponseWriter<OwsServiceResponse> {
private static final ResponseWriterKey KEY
= new ResponseWriterKey(OwsServiceResponse.class);
private static final ResponseWriterKey KEY = new ResponseWriterKey(OwsServiceResponse.class);

private final ResponseWriterRepository responseWriterRepository;

public AbstractServiceResponseWriter(EncoderRepository encoderRepository,
ResponseWriterRepository responseWriterRepository) {
ResponseWriterRepository responseWriterRepository) {
super(encoderRepository);
this.responseWriterRepository = responseWriterRepository;
}


public ResponseWriterRepository getResponseWriterRepository() {
return responseWriterRepository;
}
Expand All @@ -83,29 +81,49 @@ public void write(OwsServiceResponse asr, OutputStream out, ResponseProxy respon
// use encoded Object specific writer, e.g. XmlResponseWriter
Object encode = encoder.encode(asr);
if (encode != null) {
ResponseWriter<Object> writer = this.responseWriterRepository.getWriter(encode.getClass());
if (writer == null) {
throw new RuntimeException("no writer for " + encode.getClass() + " found!");
}
writer.write(encode, out, responseProxy);
getWriter(encoder).write(encode, out);
}
}
}
}

@Override
public void write(OwsServiceResponse asr, OutputStream out) throws IOException, EncodingException {
Encoder<Object, OwsServiceResponse> encoder = getEncoder(asr);
if (encoder != null) {
if (encoder instanceof StreamingEncoder) {
((StreamingEncoder<?, OwsServiceResponse>) encoder).encode(asr, out);
} else {
// use encoded Object specific writer, e.g. XmlResponseWriter
Object encode = encoder.encode(asr);
if (encode != null) {
getWriter(encoder).write(encode, out);
}
}
}
}

private ResponseWriter<Object> getWriter(Object encode) {
ResponseWriter<Object> writer = this.responseWriterRepository.getWriter(encode.getClass());
if (writer == null) {
throw new RuntimeException("no writer for " + encode.getClass() + " found!");
}
return writer;
}

@Override
public boolean supportsGZip(OwsServiceResponse asr) {
return !isStreaming(asr);
}

/**
* Get the {@link Encoder} for the {@link OwsServiceResponse} and the
* requested contentType
* Get the {@link Encoder} for the {@link OwsServiceResponse} and the requested contentType
*
* @param asr
* {@link OwsServiceResponse} to get {@link Encoder} for
* @return {@link Encoder} for the {@link OwsServiceResponse}
* @throws org.n52.svalbard.encode.exception.NoEncoderForKeyException if no encoder could be found
* @throws org.n52.svalbard.encode.exception.NoEncoderForKeyException
* if no encoder could be found
*/
private Encoder<Object, OwsServiceResponse> getEncoder(OwsServiceResponse asr) throws NoEncoderForKeyException {
OperationResponseEncoderKey key = getEncoderKey(asr);
Expand All @@ -125,15 +143,13 @@ private MediaType getEncodedContentType(OwsServiceResponse asr) {
}

/**
* Check if streaming encoding is forced and the {@link Encoder} for the
* {@link OwsServiceResponse} is a {@link StreamingEncoder}
* Check if streaming encoding is forced and the {@link Encoder} for the {@link OwsServiceResponse} is a
* {@link StreamingEncoder}
*
* @param asr
* {@link OwsServiceResponse} to check the {@link Encoder}
* for
* @return <code>true</code>, if streaming encoding is forced and the
* {@link Encoder} for the {@link OwsServiceResponse} is a
* {@link StreamingEncoder}
* {@link OwsServiceResponse} to check the {@link Encoder} for
* @return <code>true</code>, if streaming encoding is forced and the {@link Encoder} for the
* {@link OwsServiceResponse} is a {@link StreamingEncoder}
*/
private boolean isStreaming(OwsServiceResponse asr) {
return getEncoder(getEncoderKey(asr)) instanceof StreamingEncoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ public void write(BinaryAttachmentResponse response, OutputStream out, ResponseP

}

@Override
public void write(BinaryAttachmentResponse response, OutputStream out) throws IOException {
if (response == null) {
return;
}
byte[] bytes = response.getBytes();
//write output now that headers and content length are in place
out.write(bytes);
}

@Override
public boolean supportsGZip(BinaryAttachmentResponse t) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<version.jts>1.19.0</version.jts>
<!-- 52N dependency versions -->
<version.n52.common.xml>2.7.0</version.n52.common.xml>
<version.arctic-sea>9.7.0</version.arctic-sea>
<version.arctic-sea>9.8.0</version.arctic-sea>
<version.helgoland.api>3.4.3</version.helgoland.api>
<version.dao-impl>3.6.0</version.dao-impl>
<version.db-model>3.2.0</version.db-model>
Expand Down