use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class Iso19139GmdEncoderTest method setup.
@Before
public void setup() {
encoder = new Iso19139GmdEncoder();
encoder.setXmlOptions(XmlOptions::new);
Iso19139GcoEncoder iso19139GcoEncoder = new Iso19139GcoEncoder();
iso19139GcoEncoder.setXmlOptions(XmlOptions::new);
EncoderRepository encoderRepository = new EncoderRepository();
encoderRepository.setEncoders(Arrays.asList(encoder, iso19139GcoEncoder));
encoderRepository.init();
encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class SamplingEncoderv20Test method setup.
@Before
public void setup() throws InvalidSridException, ParseException {
EncoderRepository encoderRepository = new EncoderRepository();
OmEncoderv20 omEncoderv20 = new OmEncoderv20();
omEncoderv20.setXmlOptions(XmlOptions::new);
omEncoderv20.setEncoderRepository(encoderRepository);
GmlEncoderv321 gmlEncoderv321 = new GmlEncoderv321();
gmlEncoderv321.setEncoderRepository(encoderRepository);
gmlEncoderv321.setXmlOptions(XmlOptions::new);
SensorMLEncoderv20 sensorMLEncoderv20 = new SensorMLEncoderv20();
sensorMLEncoderv20.setXmlOptions(XmlOptions::new);
sensorMLEncoderv20.setEncoderRepository(encoderRepository);
SweCommonEncoderv20 sweCommonEncoderv20 = new SweCommonEncoderv20();
sweCommonEncoderv20.setEncoderRepository(encoderRepository);
sweCommonEncoderv20.setXmlOptions(XmlOptions::new);
encoder = new SamplingEncoderv20();
encoder.setEncoderRepository(encoderRepository);
encoder.setXmlOptions(XmlOptions::new);
encoderRepository.setEncoders(Arrays.asList(omEncoderv20, gmlEncoderv321, sensorMLEncoderv20, sweCommonEncoderv20, encoder));
encoderRepository.init();
featureOfInterest = new SamplingFeature(new CodeWithAuthority("test-feature"));
featureOfInterest.setIdentifier("test-feature-identifier");
featureOfInterest.setName(new CodeType("test-feature-name"));
featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT (30 10)", 4326));
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class SosInsertionMetadataTypeEncoderTest method prepare.
@Before
public void prepare() {
insertionMetadata = new SosInsertionMetadata();
insertionMetadata.setObservationTypes(CollectionHelper.list("type-1", "type-2"));
insertionMetadata.setFeatureOfInterestTypes(CollectionHelper.list("f-type-1", "f-type-2"));
encoder = new SosInsertionMetadataTypeEncoder();
encoder.setXmlOptions(() -> new XmlOptions());
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_throw_NoApplicableCodeException_with_DataRecord_and_field_with_not_supported_element.
@Test
public void should_throw_NoApplicableCodeException_with_DataRecord_and_field_with_not_supported_element() throws EncodingException {
thrown.expect(EncodingException.class);
thrown.expectMessage("The element type '" + getClass().getName() + "$1' " + "of the received '" + SweField.class.getName() + "' is not supported" + " by this encoder '" + SweCommonEncoderv101.class.getName() + "'.");
sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField("test", new SweAbstractDataComponent() {
@Override
public SweDataComponentType getDataComponentType() {
return null;
}
@Override
public <T, X extends Throwable> T accept(SweDataComponentVisitor<T, X> visitor) {
return null;
}
@Override
public <X extends Throwable> void accept(VoidSweDataComponentVisitor<X> visitor) {
}
@Override
public SweAbstractDataComponent copy() {
return null;
}
})));
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class Soap11Encoder method encode.
@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public SOAPMessage encode(SoapResponse soapResponse, EncodingContext additionalValues) throws EncodingException {
if (soapResponse == null) {
throw new UnsupportedEncoderInputException(this, soapResponse);
}
String soapVersion = soapResponse.getSoapVersion();
SOAPMessage soapResponseMessage;
String action = null;
try {
soapResponseMessage = SoapHelper.getSoapMessageForProtocol(soapVersion);
if (soapResponse.getSoapFault() != null) {
createSOAPFault(soapResponseMessage.getSOAPBody().addFault(), soapResponse.getSoapFault());
} else {
if (soapResponse.getException() != null) {
action = createSOAPFaultFromExceptionResponse(soapResponseMessage.getSOAPBody().addFault(), soapResponse.getException());
addSchemaLocationForExceptionToSOAPMessage(soapResponseMessage);
} else {
action = createSOAPBody(soapResponseMessage, soapResponse, soapResponse.getSoapAction());
}
}
if (soapResponse.getHeader() != null) {
List<SoapHeader> headers = soapResponse.getHeader();
for (SoapHeader header : headers) {
if (WsaConstants.NS_WSA.equals(header.getNamespace()) && header instanceof WsaActionHeader) {
((WsaHeader) header).setValue(action);
}
Encoder<Map<QName, String>, SoapHeader> encoder = getEncoder(CodingHelper.getEncoderKey(header.getNamespace(), header));
if (encoder != null) {
Map<QName, String> headerElements = encoder.encode(header);
for (Entry<QName, String> entry : headerElements.entrySet()) {
QName qName = entry.getKey();
soapResponseMessage.getSOAPHeader().addChildElement(qName).setTextContent(headerElements.get(qName));
}
}
}
} else {
soapResponseMessage.getSOAPHeader().detachNode();
}
soapResponseMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, String.valueOf(true));
return soapResponseMessage;
} catch (SOAPException soape) {
throw new EncodingException("Error while encoding SOAPMessage!", soape);
}
}
Aggregations