diff --git a/.gitignore b/.gitignore index dbfe05a7..28bd2f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ /target/ /.project /.gitignore +.idea +logs +*.iml diff --git a/dhx-adapter-core/pom.xml b/dhx-adapter-core/pom.xml index d1f07399..a6102042 100644 --- a/dhx-adapter-core/pom.xml +++ b/dhx-adapter-core/pom.xml @@ -6,7 +6,7 @@ ee.ria.dhx DHX-adapter - 1.0.4 + ${revision} dhx-adapter-core dhx-adapter-core @@ -45,6 +45,19 @@ false + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.2 + + + + test-jar + + + + diff --git a/dhx-adapter-core/src/main/resources/Dvk_kapsel_vers_2_1_eng_est.xsd b/dhx-adapter-core/src/main/resources/Dvk_kapsel_vers_2_1_eng_est.xsd index 75c73a6c..0677c64a 100644 --- a/dhx-adapter-core/src/main/resources/Dvk_kapsel_vers_2_1_eng_est.xsd +++ b/dhx-adapter-core/src/main/resources/Dvk_kapsel_vers_2_1_eng_est.xsd @@ -1,3 +1,4 @@ + @@ -643,7 +644,7 @@ - + diff --git a/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockStrategiesHelper.java b/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockStrategiesHelper.java new file mode 100644 index 00000000..5aee06ea --- /dev/null +++ b/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockStrategiesHelper.java @@ -0,0 +1,71 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package ee.ria.dhx.mock; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.BeanInitializationException; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Primary; +import org.springframework.core.type.StandardMethodMetadata; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Map.Entry; + +public class MockStrategiesHelper extends org.springframework.ws.test.support.MockStrategiesHelper { + private static final Log logger = LogFactory.getLog(MockStrategiesHelper.class); + private final ConfigurableListableBeanFactory beanFactory; + private ApplicationContext applicationContext; + + public MockStrategiesHelper(ApplicationContext applicationContext) { + super(applicationContext); + this.applicationContext = applicationContext; + this.beanFactory = ((ConfigurableApplicationContext) this.applicationContext).getBeanFactory(); + } + + @Override + public T getStrategy(Class type) { + Assert.notNull(type, "'type' must not be null"); + Map map = this.applicationContext.getBeansOfType(type); + if (map.isEmpty()) { + return null; + } else if (map.size() == 1) { + Entry entry = (Entry)map.entrySet().iterator().next(); + if (logger.isDebugEnabled()) { + logger.debug("Using " + ClassUtils.getShortName(type) + " [" + (String)entry.getKey() + "]"); + } + + return entry.getValue(); + } + + if (this.applicationContext instanceof ConfigurableApplicationContext) { + String[] beanNamesOfType = this.applicationContext.getBeanNamesForType(type); + for (String beanName : beanNamesOfType) { + if (isPrimaryBean(beanName)) { + return (T) this.applicationContext.getBean(beanName); + } + } + } + + throw new BeanInitializationException("Could not find exactly 1 " + ClassUtils.getShortName(type) + " in application context"); + } + + private boolean isPrimaryBean(String beanName) { + BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); + if (beanDefinition.getSource() instanceof StandardMethodMetadata) { + StandardMethodMetadata metadata = (StandardMethodMetadata) beanDefinition.getSource(); + Method method = metadata.getIntrospectedMethod(); + return method.isAnnotationPresent(Primary.class); + } + return false; + } +} diff --git a/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockWebServiceClient.java b/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockWebServiceClient.java new file mode 100644 index 00000000..e25228f3 --- /dev/null +++ b/dhx-adapter-core/src/test/java/ee/ria/dhx/mock/MockWebServiceClient.java @@ -0,0 +1,91 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package ee.ria.dhx.mock; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.util.Assert; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.WebServiceMessageFactory; +import org.springframework.ws.context.DefaultMessageContext; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; +import org.springframework.ws.soap.server.SoapMessageDispatcher; +import org.springframework.ws.test.server.RequestCreator; +import org.springframework.ws.test.server.ResponseActions; +import org.springframework.ws.test.server.ResponseMatcher; +import org.springframework.ws.test.support.AssertionErrors; +import org.springframework.ws.transport.WebServiceMessageReceiver; + +import java.io.IOException; + +public class MockWebServiceClient { + private static final Log logger = LogFactory.getLog(MockWebServiceClient.class); + private final WebServiceMessageReceiver messageReceiver; + private final WebServiceMessageFactory messageFactory; + + private MockWebServiceClient(WebServiceMessageReceiver messageReceiver, WebServiceMessageFactory messageFactory) { + Assert.notNull(messageReceiver, "'messageReceiver' must not be null"); + Assert.notNull(messageFactory, "'messageFactory' must not be null"); + this.messageReceiver = messageReceiver; + this.messageFactory = messageFactory; + } + + public static MockWebServiceClient createClient(WebServiceMessageReceiver messageReceiver, WebServiceMessageFactory messageFactory) { + return new MockWebServiceClient(messageReceiver, messageFactory); + } + + public static MockWebServiceClient createClient(ApplicationContext applicationContext) { + Assert.notNull(applicationContext, "'applicationContext' must not be null"); + MockStrategiesHelper strategiesHelper = new MockStrategiesHelper(applicationContext); + WebServiceMessageReceiver messageReceiver = (WebServiceMessageReceiver)strategiesHelper.getStrategy(WebServiceMessageReceiver.class, SoapMessageDispatcher.class); + WebServiceMessageFactory messageFactory = (WebServiceMessageFactory)strategiesHelper.getStrategy(WebServiceMessageFactory.class, AxiomSoapMessageFactory.class); + return new MockWebServiceClient(messageReceiver, messageFactory); + } + + public ResponseActions sendRequest(RequestCreator requestCreator) { + Assert.notNull(requestCreator, "'requestCreator' must not be null"); + + try { + WebServiceMessage request = requestCreator.createRequest(this.messageFactory); + MessageContext messageContext = new DefaultMessageContext(request, this.messageFactory); + this.messageReceiver.receive(messageContext); + return new MockWebServiceClient.MockWebServiceClientResponseActions(messageContext); + } catch (Exception var4) { + logger.error("Could not send request", var4); + AssertionErrors.fail(var4.getMessage()); + return null; + } + } + + private static class MockWebServiceClientResponseActions implements ResponseActions { + private final MessageContext messageContext; + + private MockWebServiceClientResponseActions(MessageContext messageContext) { + Assert.notNull(messageContext, "'messageContext' must not be null"); + this.messageContext = messageContext; + } + + public ResponseActions andExpect(ResponseMatcher responseMatcher) { + WebServiceMessage request = this.messageContext.getRequest(); + WebServiceMessage response = this.messageContext.getResponse(); + if (response == null) { + AssertionErrors.fail("No response received"); + return null; + } else { + try { + responseMatcher.match(request, response); + return this; + } catch (IOException var5) { + MockWebServiceClient.logger.error("Could not match request", var5); + AssertionErrors.fail(var5.getMessage()); + return null; + } + } + } + } +} diff --git a/dhx-adapter-core/src/test/java/ee/ria/dhx/types/DhxOrganisationTest.java b/dhx-adapter-core/src/test/java/ee/ria/dhx/types/DhxOrganisationTest.java index 4790f28f..2d975b10 100644 --- a/dhx-adapter-core/src/test/java/ee/ria/dhx/types/DhxOrganisationTest.java +++ b/dhx-adapter-core/src/test/java/ee/ria/dhx/types/DhxOrganisationTest.java @@ -1,7 +1,5 @@ package ee.ria.dhx.types; -import ee.ria.dhx.types.DhxOrganisation; - import org.junit.Test; import static org.junit.Assert.*; diff --git a/dhx-adapter-core/src/test/java/ee/ria/dhx/util/FileUtilTest.java b/dhx-adapter-core/src/test/java/ee/ria/dhx/util/FileUtilTest.java index 25250ddc..f3d0df7c 100644 --- a/dhx-adapter-core/src/test/java/ee/ria/dhx/util/FileUtilTest.java +++ b/dhx-adapter-core/src/test/java/ee/ria/dhx/util/FileUtilTest.java @@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue; import ee.ria.dhx.exception.DhxException; -import ee.ria.dhx.util.FileUtil; import org.junit.Rule; import org.junit.Test; @@ -25,10 +24,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import javax.activation.DataHandler; -import javax.activation.DataSource; -import javax.mail.util.ByteArrayDataSource; - public class FileUtilTest { @Rule diff --git a/dhx-adapter-server/pom.xml b/dhx-adapter-server/pom.xml index 2c2de59e..4c1c383d 100644 --- a/dhx-adapter-server/pom.xml +++ b/dhx-adapter-server/pom.xml @@ -6,7 +6,7 @@ ee.ria.dhx DHX-adapter - 1.0.4 + ${revision} dhx-adapter-server dhx-adapter-server @@ -80,6 +80,16 @@ commons-codec + + + + ee.ria.dhx + dhx-adapter-core + ${project.parent.version} + test-jar + test + + ${packageName} diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/Application.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/Application.java index f0f5a90c..1c28c914 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/Application.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/Application.java @@ -3,7 +3,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; @@ -21,11 +20,16 @@ */ @SpringBootApplication @EnableScheduling -@EnableAutoConfiguration @EnableWebMvc -@ComponentScan(basePackages = "ee.ria.dhx.ws.config,ee.ria.dhx.ws.schedule," - + "ee.ria.dhx.ws.service.impl,ee.ria.dhx.server.service,ee.ria.dhx.server.config" - + ",ee.ria.dhx.server.persistence.*,ee.ria.dhx.server.scheduler,ee.ria.dhx.ws") +@ComponentScan(basePackages = { + "ee.ria.dhx.server.config", + "ee.ria.dhx.server.service", + "ee.ria.dhx.server.persistence.*", + "ee.ria.dhx.server.scheduler", + "ee.ria.dhx.ws.config", + "ee.ria.dhx.ws.schedule", + "ee.ria.dhx.ws.service.impl" +}) @EnableAsync @PropertySource("classpath:dhx-application.properties") @Slf4j diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerConfig.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerConfig.java index 395af216..0040089b 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerConfig.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerConfig.java @@ -5,7 +5,6 @@ import ee.ria.dhx.exception.DhxException; import ee.ria.dhx.exception.DhxExceptionEnum; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerWebServiceConfig.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerWebServiceConfig.java index 1cf3cfd0..1054eb13 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerWebServiceConfig.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/config/DhxServerWebServiceConfig.java @@ -5,86 +5,106 @@ import ee.ria.dhx.server.endpoint.config.DhxServerEndpointConfig; import ee.ria.dhx.ws.config.endpoint.DhxEndpointConfig; +import lombok.Getter; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; +import org.springframework.ws.soap.SoapMessageFactory; +import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; import org.springframework.ws.transport.http.MessageDispatcherServlet; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.soap.SOAPMessage; +import java.io.File; /** * Class creates beans needed for web services. Those beans are meant to use only if there is no * other web services in application. Otherwise those beans might interfere with the ones already * defined. - * + * * @author Aleksei Kokarev * */ @Configuration public class DhxServerWebServiceConfig { + @Value("${soap.dhx.attachment.cache.threshold:#{null}}") + @Getter + Integer attachmentCacheThreshold; + + @Value("${soap.dhx.attachment.cache.dir:#{null}}") + @Getter + String attachmentCacheDir; + /** * Sets servlet registration bean. Registers web services on configured path - * + * * @param applicationContext - context of the application * @return ServletRegistrationBean */ @Bean(name = "dhxServlet") - public ServletRegistrationBean dhxMessageDispatcherServlet( - ApplicationContext applicationContext) { - MessageDispatcherServlet servlet = new MessageDispatcherServlet(); - AnnotationConfigWebApplicationContext applicationAnnotationContext = - new AnnotationConfigWebApplicationContext(); + public ServletRegistrationBean dhxMessageDispatcherServlet(ApplicationContext applicationContext) { + AnnotationConfigWebApplicationContext applicationAnnotationContext = new AnnotationConfigWebApplicationContext(); applicationAnnotationContext.setParent(applicationContext); applicationAnnotationContext.register(DhxEndpointConfig.class); - servlet.setApplicationContext(applicationAnnotationContext); - servlet.setTransformWsdlLocations(true); - servlet.setMessageFactoryBeanName("messageFactory"); - ServletRegistrationBean servletBean = new ServletRegistrationBean(servlet, "/" + "ws" + "/*"); - servletBean.setName("dhx"); - return servletBean; - } - /** - * Creates messageFactory and returns. - * @return messagefactory - */ - @Bean(name = "messageFactory") - public SaajSoapMessageFactory messageFactory() { - SaajSoapMessageFactory smf = new SaajSoapMessageFactory(); - Map props = new HashMap(); - props.put(SOAPMessage.WRITE_XML_DECLARATION, Boolean.toString(true)); - smf.setMessageProperties(props); - return smf; + MessageDispatcherServlet messageDispatcherServlet = + messageDispatcherServlet(applicationAnnotationContext, "axiomSoapMessageFactoryReceive"); + + return new ServletRegistrationBean(messageDispatcherServlet, "/" + "ws" + "/*") {{ + setName("dhx"); + }}; } /** * Sets servlet registration bean. Registers web services on configured path - * + * * @param applicationContext - context of the application * @return ServletRegistrationBean */ @Bean(name = "dhxServerServlet") - public ServletRegistrationBean dhxServerMessageDispatcherServlet( - ApplicationContext applicationContext) { - MessageDispatcherServlet servlet = new MessageDispatcherServlet(); - AnnotationConfigWebApplicationContext applicationAnnotationContext = - new AnnotationConfigWebApplicationContext(); + public ServletRegistrationBean dhxServerMessageDispatcherServlet(ApplicationContext applicationContext) { + AnnotationConfigWebApplicationContext applicationAnnotationContext = new AnnotationConfigWebApplicationContext(); applicationAnnotationContext.setParent(applicationContext); applicationAnnotationContext.register(DhxServerEndpointConfig.class); - servlet.setApplicationContext(applicationAnnotationContext); - servlet.setTransformWsdlLocations(true); - ServletRegistrationBean servletBean = - new ServletRegistrationBean(servlet, "/" + "wsServer" + "/*"); - servletBean.setName("dhxServer"); - return servletBean; + + MessageDispatcherServlet messageDispatcherServlet = + messageDispatcherServlet(applicationAnnotationContext, "axiomSoapMessageFactorySend"); + + return new ServletRegistrationBean(messageDispatcherServlet, "/" + "wsServer" + "/*") {{ + setName("dhxServer"); + }}; + } + + public MessageDispatcherServlet messageDispatcherServlet(final WebApplicationContext applicationContext, + final String messageFactoryBeanName) { + return new MessageDispatcherServlet(applicationContext) {{ + setTransformWsdlLocations(true); + setMessageFactoryBeanName(messageFactoryBeanName); + }}; + } + + /** + * Creates messageFactory for receiving and returns. + * @return messagefactory + */ + @Bean + public SoapMessageFactory axiomSoapMessageFactoryReceive() { + return new AxiomSoapMessageFactory() {{ + Integer attachmentCacheThreshold = DhxServerWebServiceConfig.this.getAttachmentCacheThreshold(); + if (attachmentCacheThreshold != null) { + setAttachmentCaching(true); + setAttachmentCacheThreshold(attachmentCacheThreshold /* MB */ * 1024 /* KB */ * 1024 /* Byte */); + + String attachmentCacheDir = DhxServerWebServiceConfig.this.getAttachmentCacheDir(); + if (attachmentCacheDir != null) { + setAttachmentCacheDir(new File(attachmentCacheDir)); + } + } + }}; } diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/endpoint/config/DhxServerEndpointConfig.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/endpoint/config/DhxServerEndpointConfig.java index dce26bdd..3bdd47ec 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/endpoint/config/DhxServerEndpointConfig.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/endpoint/config/DhxServerEndpointConfig.java @@ -46,28 +46,21 @@ public class DhxServerEndpointConfig extends WsConfigurationSupport { * @return DefaultMethodEndpointAdapter */ @Bean(name = "dhxServerMethodEndpointAdapter") - public DefaultMethodEndpointAdapter dhxMethodEndpointAdapter() { - List argumentResolvers = null; - List returnValueHandlers = null; - if (argumentResolvers == null) { - argumentResolvers = new ArrayList(); - } - if (returnValueHandlers == null) { - returnValueHandlers = new ArrayList(); - } - returnValueHandlers.addAll(methodProcessors()); - argumentResolvers.addAll(methodProcessors()); - + public DefaultMethodEndpointAdapter dhxServerMethodEndpointAdapter( + DefaultMethodEndpointAdapter defaultMethodEndpointAdapter, + List dhxServerMethodProcessors) { + final List argumentResolvers = new ArrayList(dhxServerMethodProcessors); + final List returnValueHandlers = new ArrayList(dhxServerMethodProcessors); argumentResolvers.add(new MessageContextMethodArgumentResolver()); - returnValueHandlers.addAll(defaultMethodEndpointAdapter().getMethodReturnValueHandlers()); - argumentResolvers.addAll(defaultMethodEndpointAdapter().getMethodArgumentResolvers()); + argumentResolvers.addAll(defaultMethodEndpointAdapter.getMethodArgumentResolvers()); + returnValueHandlers.addAll(defaultMethodEndpointAdapter.getMethodReturnValueHandlers()); - DefaultMethodEndpointAdapter adapter = new DefaultMethodEndpointAdapter(); - adapter.setMethodArgumentResolvers(argumentResolvers); - adapter.setMethodReturnValueHandlers(returnValueHandlers); - return adapter; + return new DefaultMethodEndpointAdapter() {{ + setMethodArgumentResolvers(argumentResolvers); + setMethodReturnValueHandlers(returnValueHandlers); + }}; } /** @@ -77,12 +70,9 @@ public DefaultMethodEndpointAdapter dhxMethodEndpointAdapter() { */ @Bean(name = "dhxServerMethodProcessors") public List methodProcessors() { - List retVal = - new ArrayList(); - Jaxb2Marshaller marshallerMtom = marshaller; - retVal.add(new MarshallingPayloadMethodProcessor(marshallerMtom)); - - return retVal; + return new ArrayList() {{ + add(new MarshallingPayloadMethodProcessor(marshaller)); + }}; } diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/CapsuleService.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/CapsuleService.java index 1f44a522..392333a2 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/CapsuleService.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/CapsuleService.java @@ -80,6 +80,10 @@ public class CapsuleService { @Setter OrganisationRepository organisationRepository; + @Autowired + @Setter + DhxOrganisationFactory dhxOrganisationFactory; + @Autowired @Setter PersistenceService persistenceService; @@ -136,7 +140,7 @@ public Document getDocumentFromIncomingContainer(IncomingDhxPackage pckg, Document document = new Document(); document.setCapsuleVersion(version.toString()); DhxOrganisation dhxSenderOrg = - DhxOrganisationFactory.createDhxOrganisation(pckg.getClient()); + dhxOrganisationFactory.createDhxOrganisation(pckg.getClient()); Organisation senderOrg = organisationRepository.findByRegistrationCodeAndSubSystem(dhxSenderOrg.getCode(), dhxSenderOrg.getSystem()); @@ -322,7 +326,7 @@ public Document getDocumentFromOutgoingContainer(InternalXroadMember senderMembe if (StringUtil.isNullOrEmpty(senderMember.getSubsystemCode())) { senderMember.setSubsystemCode(null); } - DhxOrganisation dhxSenderOrg = DhxOrganisationFactory.createDhxOrganisation(senderMember); + DhxOrganisation dhxSenderOrg = dhxOrganisationFactory.createDhxOrganisation(senderMember); Organisation senderOrg = organisationRepository.findByRegistrationCodeAndSubSystem(dhxSenderOrg.getCode(), dhxSenderOrg.getSystem()); diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceDhxSpecificService.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceDhxSpecificService.java index f20e456a..bb80fd15 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceDhxSpecificService.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceDhxSpecificService.java @@ -63,6 +63,9 @@ public class PersistenceDhxSpecificService implements DhxImplementationSpecificS @Autowired PersistenceService persistenceService; + @Autowired + DhxOrganisationFactory dhxOrganisationFactory; + /** * Returns all organisations from database that are active and marked as own representees. */ @@ -83,7 +86,7 @@ public List getRepresentationList() throws DhxException { @Loggable public boolean isDuplicatePackage(InternalXroadMember from, String consignmentId) throws DhxException { - DhxOrganisation dhxOrg = DhxOrganisationFactory.createDhxOrganisation(from); + DhxOrganisation dhxOrg = dhxOrganisationFactory.createDhxOrganisation(from); Organisation org = organisationRepository.findByRegistrationCodeAndSubSystem(dhxOrg.getCode(), dhxOrg.getSystem()); log.debug("checking duplicates for organisation: {}", org); diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceService.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceService.java index 78e41a4c..0f78aeb2 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceService.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/persistence/service/PersistenceService.java @@ -70,6 +70,10 @@ public class PersistenceService { @Setter DocumentRepository documentRepository; + @Autowired + @Setter + DhxOrganisationFactory dhxOrganisationFactory; + private static final String DEFAULT_FOLDERNAME = "/"; /** @@ -120,7 +124,7 @@ public Organisation findOrg(String capsuleOrganisationId) throws DhxException { "Unable to find member in addressregistry by regsitration code: " + capsuleOrganisationId); } - DhxOrganisation dhxOrganisation = DhxOrganisationFactory.createDhxOrganisation(member); + DhxOrganisation dhxOrganisation = dhxOrganisationFactory.createDhxOrganisation(member); org = organisationRepository.findByRegistrationCodeAndSubSystem(dhxOrganisation.getCode(), dhxOrganisation.getSystem()); } diff --git a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/service/util/WsUtil.java b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/service/util/WsUtil.java index bb7c8cc1..5e3e8cb2 100644 --- a/dhx-adapter-server/src/main/java/ee/ria/dhx/server/service/util/WsUtil.java +++ b/dhx-adapter-server/src/main/java/ee/ria/dhx/server/service/util/WsUtil.java @@ -4,28 +4,29 @@ import ee.ria.dhx.exception.DhxException; import ee.ria.dhx.exception.DhxExceptionEnum; -import ee.ria.dhx.server.config.DhxServerConfig; import ee.ria.dhx.util.FileUtil; -import ee.ria.dhx.ws.config.SoapConfig; -import ee.ria.dhx.ws.context.AppContext; import lombok.extern.slf4j.Slf4j; import org.springframework.ws.context.MessageContext; import org.springframework.ws.mime.Attachment; -import org.springframework.ws.soap.saaj.SaajSoapMessage; -import org.springframework.ws.transport.http.HttpTransportConstants; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.soap.axiom.AxiomSoapMessage; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -37,11 +38,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.soap.AttachmentPart; - -import org.apache.commons.codec.binary.Base64InputStream; - -import ee.ria.dhx.server.service.util.StreamTypeEnum; /** * Utility methods for web services and attachments. @@ -52,9 +48,6 @@ @Slf4j public class WsUtil { - private static String attachmentContentEncoding; - private static String attachmentContentType; - private static String attachmentContentTransferEncoding; private static final String ATTACHMENT_CONTENT_ID_PREFIX = "cid:"; /** @@ -121,6 +114,7 @@ public static InputStream base64Decode(InputStream stream) throws DhxException { * @throws DhxException thrown if error occurs */ public static InputStream base64MimeDecode(InputStream stream) throws DhxException { + stream = ensureInputStreamSpeedForBase64(stream); InputStream base64DecoderStream = Base64.getMimeDecoder().wrap(stream); return base64DecoderStream; } @@ -134,8 +128,8 @@ public static InputStream base64MimeDecode(InputStream stream) throws DhxExcepti * @throws DhxException thrown if error occurs */ public static OutputStream getBase64EncodeStream(OutputStream stream) throws DhxException { - BufferedOutputStream os = new BufferedOutputStream(stream); - OutputStream base64EncoderStream = Base64.getEncoder().wrap(os); + stream = ensureOutputStreamSpeedForBase64(stream); + OutputStream base64EncoderStream = Base64.getEncoder().wrap(stream); return base64EncoderStream; } @@ -147,26 +141,59 @@ public static OutputStream getBase64EncodeStream(OutputStream stream) throws Dhx * @throws DhxException thrown if error occurs */ private static InputStream base64DecodeAndUnzip(InputStream stream) throws DhxException { - InputStream decoded = stream; - decoded = base64Decode(decoded); - return gzipDecompress(decoded, StreamTypeEnum.BASE64BASIC); + return base64DecodeAndUnzip(stream, StreamTypeEnum.BASE64BASIC); } /** * Creates InputStream that will BASE64 Mime decode the stream from input. - * + * * @param stream stream to decode * @return decoded stream * @throws DhxException thrown if error occurs */ private static InputStream base64MimeDecodeAndUnzip(InputStream stream) throws DhxException { - InputStream decoded = stream; - decoded = base64MimeDecode(decoded); - return gzipDecompress(decoded, StreamTypeEnum.BASE64MIME); + return base64DecodeAndUnzip(stream, StreamTypeEnum.BASE64MIME); } - + + /** + * Creates InputStream that will decode the stream from input. + * + * @param stream stream to decode + * @return decoded stream + * @throws DhxException thrown if error occurs + */ + private static InputStream base64DecodeAndUnzip(InputStream stream, StreamTypeEnum streamType) throws DhxException { + InputStream decoded = base64MimeDecode(stream); + return gzipDecompress(decoded, streamType); + } + + /** + * PipedInputStream and FileInputStream do not play well with Base64 encoding/decoding. + * Wrap these streams into BufferedInputStream to increase Base64 operations performance. + * + * @param stream stream to decode + * @return + */ + private static InputStream ensureInputStreamSpeedForBase64(InputStream stream) { + return stream instanceof PipedInputStream || stream instanceof FileInputStream + ? new BufferedInputStream(stream) + : stream; + } + + /** + * PipedInputStream and FileInputStream do not play well with Base64 encoding/decoding. + * Wrap these streams into BufferedInputStream to increase Base64 operations performance. + * + * @param stream stream to decode + * @return + */ + private static OutputStream ensureOutputStreamSpeedForBase64(OutputStream stream) { + return stream instanceof PipedOutputStream || stream instanceof FileOutputStream + ? new BufferedOutputStream(stream) + : stream; + } /** * Method reads inputstream into string. @@ -284,7 +311,7 @@ public static InputStream base64DecodeIfNeededAndUnzip(DataHandler handler) @Loggable public static DataHandler extractAttachment( MessageContext messageContext, String attachmentContentId) throws DhxException { - SaajSoapMessage soapRequest = (SaajSoapMessage) messageContext + SoapMessage soapRequest = (SoapMessage) messageContext .getRequest(); if (attachmentContentId.startsWith("cid:")) { attachmentContentId = attachmentContentId.substring(4); @@ -323,29 +350,11 @@ public static DataHandler extractAttachment( @Loggable public static String addAttachment( MessageContext messageContext, DataHandler attachmentHandler) throws DhxException { - SaajSoapMessage soapResponse = (SaajSoapMessage) messageContext - .getResponse(); - AttachmentPart part = soapResponse.getSaajMessage().createAttachmentPart(attachmentHandler); - if (attachmentContentType == null) { - DhxServerConfig config = AppContext.getApplicationContext().getBean(DhxServerConfig.class); - attachmentContentType = config.getAttachmentContentType(); - } - if (attachmentContentEncoding == null) { - DhxServerConfig config = AppContext.getApplicationContext().getBean(DhxServerConfig.class); - attachmentContentEncoding = config.getAttachmentContentEncoding(); - } - if (attachmentContentTransferEncoding == null) { - DhxServerConfig config = AppContext.getApplicationContext().getBean(DhxServerConfig.class); - attachmentContentTransferEncoding = config.getAttachmentContentTransferEncoding(); - } - part.addMimeHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, attachmentContentType); - part.addMimeHeader(HttpTransportConstants.HEADER_CONTENT_ENCODING, - attachmentContentEncoding); - part.addMimeHeader(HttpTransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, - attachmentContentTransferEncoding); String contentId = UUID.randomUUID().toString(); - part.setContentId(contentId); - soapResponse.getSaajMessage().addAttachmentPart(part); + + AxiomSoapMessage soapResponse = (AxiomSoapMessage) messageContext.getResponse(); + soapResponse.addAttachment(contentId, attachmentHandler); + return ATTACHMENT_CONTENT_ID_PREFIX + contentId; } diff --git a/dhx-adapter-server/src/main/resources/dhl_new.wsdl b/dhx-adapter-server/src/main/resources/dhl_new.wsdl index 1cd9641c..515c85d9 100644 --- a/dhx-adapter-server/src/main/resources/dhl_new.wsdl +++ b/dhx-adapter-server/src/main/resources/dhl_new.wsdl @@ -11,7 +11,7 @@ xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"> - + diff --git a/dhx-adapter-server/src/main/resources/dhl_new_v2.wsdl b/dhx-adapter-server/src/main/resources/dhl_new_v2.wsdl index 4a193b3b..48ea503a 100644 --- a/dhx-adapter-server/src/main/resources/dhl_new_v2.wsdl +++ b/dhx-adapter-server/src/main/resources/dhl_new_v2.wsdl @@ -7,7 +7,7 @@ xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"> + xmlns="https://www.w3.org/2001/XMLSchema"> diff --git a/dhx-adapter-server/src/main/resources/dhl_new_v3.wsdl b/dhx-adapter-server/src/main/resources/dhl_new_v3.wsdl index 360ae93e..b4b4a2c4 100644 --- a/dhx-adapter-server/src/main/resources/dhl_new_v3.wsdl +++ b/dhx-adapter-server/src/main/resources/dhl_new_v3.wsdl @@ -11,7 +11,7 @@ xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"> - + diff --git a/dhx-adapter-server/src/main/resources/dhl_new_v4.wsdl b/dhx-adapter-server/src/main/resources/dhl_new_v4.wsdl index 0db02829..3822fe9a 100644 --- a/dhx-adapter-server/src/main/resources/dhl_new_v4.wsdl +++ b/dhx-adapter-server/src/main/resources/dhl_new_v4.wsdl @@ -12,7 +12,7 @@ xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"> - + @@ -285,7 +285,7 @@ - + Dokumendihoidla Document repository diff --git a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/TestApp.java b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/TestApp.java index 9b8cb4de..5df6dcfd 100644 --- a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/TestApp.java +++ b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/TestApp.java @@ -17,15 +17,24 @@ import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.ws.soap.SoapMessageFactory; +import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; import java.io.IOException; // @SpringBootApplication @TestPropertySource("classpath:test-application.properties") -@ComponentScan(basePackages = "ee.ria.dhx.ws.config,ee.ria.dhx.ws.schedule," - + "ee.ria.dhx.ws.service.impl,ee.ria.dhx.server.service,ee.ria.dhx.server.config" - + ",ee.ria.dhx.server.persistence.*,ee.ria.dhx.server.scheduler," - + "ee.ria.dhx.ws,ee.ria.dhx.server.endpoint.config") +@ComponentScan(basePackages = { + "ee.ria.dhx.ws.config", + "ee.ria.dhx.ws.schedule", + "ee.ria.dhx.ws.service.impl", + "ee.ria.dhx.server.service", + "ee.ria.dhx.server.config", + "ee.ria.dhx.server.persistence.*", + "ee.ria.dhx.server.scheduler", + "ee.ria.dhx.ws", + "ee.ria.dhx.server.endpoint.config" +}) @EnableTransactionManagement @Slf4j // @EnableAutoConfiguration @@ -64,4 +73,10 @@ public FolderRepository getFodlerRepository(FolderRepository repository) { return repository; } + @Bean + @Primary + public SoapMessageFactory messageFactory(SoapMessageFactory axiomSoapMessageFactoryReceive) { + return Mockito.spy(axiomSoapMessageFactoryReceive); + } + } diff --git a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/integration/ServerIT.java b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/integration/ServerIT.java index 68dc86f7..1f4a838d 100644 --- a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/integration/ServerIT.java +++ b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/integration/ServerIT.java @@ -11,6 +11,7 @@ import ee.ria.dhx.server.RepoFactory4Test; import ee.ria.dhx.server.TestApp; import ee.ria.dhx.server.config.DhxServerConfig; +import ee.ria.dhx.mock.MockWebServiceClient; import ee.ria.dhx.server.persistence.entity.Document; import ee.ria.dhx.server.persistence.entity.Organisation; import ee.ria.dhx.server.persistence.entity.Recipient; @@ -85,7 +86,6 @@ import org.springframework.ws.test.client.MockWebServiceServer; import org.springframework.ws.test.client.RequestMatchers; import org.springframework.ws.test.client.ResponseCreators; -import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.ws.test.server.RequestCreators; import org.springframework.ws.test.server.ResponseMatchers; import org.springframework.ws.test.server.ResponseMatcher; diff --git a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/CapsuleServiceTest.java b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/CapsuleServiceTest.java index 567b70da..421faeb3 100644 --- a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/CapsuleServiceTest.java +++ b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/CapsuleServiceTest.java @@ -31,6 +31,7 @@ import ee.ria.dhx.ws.DhxOrganisationFactory; import ee.ria.dhx.ws.config.CapsuleConfig; import ee.ria.dhx.ws.config.DhxConfig; +import ee.ria.dhx.ws.config.SoapConfig; import ee.ria.dhx.ws.service.DhxMarshallerService; import org.junit.Before; @@ -38,6 +39,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -81,10 +83,18 @@ public class CapsuleServiceTest { @Mock DhxConfig config; + + @Mock + SoapConfig soapConfig; @Mock DhxServerConfig serverConfig; + @InjectMocks + DhxOrganisationFactory dhxOrganisationFactory = new DhxOrganisationFactory(); + + + CapsuleService capsuleService; @Rule @@ -100,10 +110,10 @@ public void init() throws DhxException, IOException { capsuleService.setDhxMarshallerService(dhxMarshallerService); capsuleService.setOrganisationRepository(organisationRepository); capsuleService.setPersistenceService(persistenceService); + capsuleService.setDhxOrganisationFactory(dhxOrganisationFactory); when(capsuleConfig.getCurrentCapsuleVersion()).thenReturn(CapsuleVersionEnum.V21); when(capsuleConfig.getXsdForVersion(CapsuleVersionEnum.V21)) .thenReturn("jar://Dvk_kapsel_vers_2_1_eng_est.xsd"); - DhxOrganisationFactory.setDhxSubsystemPrefix("DHX"); List addressees = new ArrayList(); CapsuleAdressee adressee = new CapsuleAdressee("401", null, null); addressees.add(adressee); @@ -115,6 +125,7 @@ public void init() throws DhxException, IOException { when(persistenceService.getFolderByNameOrDefaultFolder("/")).thenReturn(folder); capsuleService.setConfig(config); when(config.getCapsuleValidate()).thenReturn(true); + when(soapConfig.getDhxSubsystemPrefix()).thenReturn("DHX"); capsuleService.setDhxServerConfig(serverConfig); testFile = testFolder.newFile(filename); when(serverConfig.createDocumentFile()).thenReturn(testFile); @@ -178,7 +189,7 @@ public void getDocumentFromIncomingContainer() throws DhxException, IOException InternalXroadMember client = getMember("400", null); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -257,7 +268,7 @@ public void getDocumentFromIncomingContainerRepresentee() throws DhxException, I DhxRepresentee serviceRepresentee = new DhxRepresentee("500", null, null, null, "system"); InternalXroadMember service = getMember("401", serviceRepresentee); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -302,7 +313,7 @@ public void getDocumentFromIncomingContainerSenderNotFound() throws DhxException InternalXroadMember client = getMember("400", null); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -350,7 +361,7 @@ public void getDocumentFromIncomingContainerSenderRepresenteeNotFound() InternalXroadMember client = getMember("400", clientRepresentee); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -404,7 +415,7 @@ public void getDocumentFromIncomingContainerManyRecipients() throws DhxException InternalXroadMember client = getMember("400", null); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -449,7 +460,7 @@ public void getDocumentFromIncomingContainerPersonalCode() throws DhxException, InternalXroadMember client = getMember("400", null); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container @@ -498,7 +509,7 @@ public void getDocumentFromIncomingContainerStructuralUnit() throws DhxException InternalXroadMember client = getMember("400", null); InternalXroadMember service = getMember("401", null); SendDocument sendDocument = getSendDocument(null, null, handler); - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(service); + DhxOrganisation recipient = dhxOrganisationFactory.createDhxOrganisation(service); IncomingDhxPackage pckg = new IncomingDhxPackage(client, service, sendDocument, recipient); // mock container DecContainer container = getDecContainer(client, service); diff --git a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/PersistenceServiceTest.java b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/PersistenceServiceTest.java index a4330146..ee6b5e80 100644 --- a/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/PersistenceServiceTest.java +++ b/dhx-adapter-server/src/test/java/ee/ria/dhx/server/persistence/service/PersistenceServiceTest.java @@ -16,6 +16,7 @@ import ee.ria.dhx.server.persistence.repository.OrganisationRepository; import ee.ria.dhx.types.DhxRepresentee; import ee.ria.dhx.types.InternalXroadMember; +import ee.ria.dhx.ws.DhxOrganisationFactory; import ee.ria.dhx.ws.config.SoapConfig; import ee.ria.dhx.ws.service.AddressService; @@ -23,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -42,6 +44,9 @@ public class PersistenceServiceTest { PersistenceService persistenceService; + @InjectMocks + DhxOrganisationFactory dhxOrganisationFactory; + @Mock SoapConfig config; @@ -55,6 +60,7 @@ public void init() throws DhxException { persistenceService.setAddressService(addressService); persistenceService.setFolderRepository(folderRepository); persistenceService.setOrganisationRepository(organisationRepository); + persistenceService.setDhxOrganisationFactory(dhxOrganisationFactory); Folder folder = new Folder(); folder.setName("folder"); persistenceService.setSpecialOrganisations("adit,kovtp,rt,eelnoud"); diff --git a/dhx-adapter-ws/doc/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.html b/dhx-adapter-ws/doc/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.html index 62377825..51726dba 100644 --- a/dhx-adapter-ws/doc/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.html +++ b/dhx-adapter-ws/doc/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.html @@ -106,7 +106,7 @@

Class DhxHttpComp
  • org.springframework.ws.transport.http.HttpComponentsMessageSender
    • -
    • ee.ria.dhx.ws.DhxHttpComponentsMessageSender
    • +
    • ee.ria.dhx.ws.connection.DhxHttpComponentsMessageSender
  • diff --git a/dhx-adapter-ws/doc/ee/ria/dhx/ws/class-use/DhxHttpComponentsMessageSender.html b/dhx-adapter-ws/doc/ee/ria/dhx/ws/class-use/DhxHttpComponentsMessageSender.html index a76bb503..5de40f29 100644 --- a/dhx-adapter-ws/doc/ee/ria/dhx/ws/class-use/DhxHttpComponentsMessageSender.html +++ b/dhx-adapter-ws/doc/ee/ria/dhx/ws/class-use/DhxHttpComponentsMessageSender.html @@ -3,7 +3,7 @@ -Uses of Class ee.ria.dhx.ws.DhxHttpComponentsMessageSender +Uses of Class ee.ria.dhx.ws.connection.DhxHttpComponentsMessageSender @@ -70,9 +70,9 @@
    -

    Uses of Class
    ee.ria.dhx.ws.DhxHttpComponentsMessageSender

    +

    Uses of Class
    ee.ria.dhx.ws.DhxHttpComponentsMessageSender

    -
    No usage of ee.ria.dhx.ws.DhxHttpComponentsMessageSender
    +
    No usage of ee.ria.dhx.ws.connection.DhxHttpComponentsMessageSender
    diff --git a/dhx-adapter-ws/pom.xml b/dhx-adapter-ws/pom.xml index 4026055c..a4c8092c 100644 --- a/dhx-adapter-ws/pom.xml +++ b/dhx-adapter-ws/pom.xml @@ -6,7 +6,7 @@ ee.ria.dhx DHX-adapter - 1.0.4 + ${revision} dhx-adapter-ws Web services @@ -37,8 +37,58 @@ xerces xercesImpl - 2.8.1 + 2.12.0 + + org.codehaus.woodstox + stax2-api + 4.2 + + + com.fasterxml.woodstox + woodstox-core + 5.3.0 + + + + net.java.dev.msv + msv-core + 2013.6.1 + + + + org.apache.ws.commons.axiom + axiom-api + 1.2.22 + + + org.apache.ws.commons.axiom + axiom-impl + 1.2.22 + + + org.codehaus.woodstox + woodstox-core-asl + + + + + + org.apache.commons + commons-lang3 + 3.9 + + + + + + ee.ria.dhx + dhx-adapter-core + ${project.parent.version} + test-jar + test + + diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataHandler.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataHandler.java index 4c0d9a31..f67d3ed6 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataHandler.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataHandler.java @@ -61,7 +61,7 @@ protected abstract void handleBigDataStartElement(Field dataField, Stack Stack currentObjPath, String uri, String localName, String qname, Attributes attributes) throws DhxException; - protected abstract void handleBigDataCharacters(char[] chars) throws IOException; + protected abstract void handleBigDataCharacters(char[] chars, int start, int length) throws IOException; protected abstract void handleBigDataEndElement(String uri, String localName, String qname) throws IOException, SAXException; @@ -154,13 +154,7 @@ public void startElement(String uri, String localName, String qname, Attributes public void characters(char[] ch, int start, int length) throws SAXException { if (isDocument) { try { - char[] charSub; - if (start > 0 || ch.length > length) { - charSub = Arrays.copyOfRange(ch, start, start + length); - } else { - charSub = ch; - } - handleBigDataCharacters(charSub); + handleBigDataCharacters(ch, start, length); } catch (IOException ex) { throw new SAXException("Error occured while reading document." + ex.getMessage(), ex); } diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataMarshallHandler.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataMarshallHandler.java index c59ba091..3b8f9b54 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataMarshallHandler.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataMarshallHandler.java @@ -124,7 +124,7 @@ public void startDocument() throws SAXException { @Override public void endDocument() throws SAXException { - log.info("document started !!!!"); + log.info("document ended !!!!"); if (!nonamespaces) super.endDocument(); } @@ -209,7 +209,7 @@ protected void handleBigDataStartElement(Field dataField, Stack currentP @Override @Loggable - protected void handleBigDataCharacters(char[] chars) throws IOException { + protected void handleBigDataCharacters(char[] chars, int start, int length) throws IOException { log.error("CHARECTER CANNOT BE HERE!!!!"); } diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataUnmarshallHandler.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataUnmarshallHandler.java index 45138e63..fb537421 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataUnmarshallHandler.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/bigdata/BigDataUnmarshallHandler.java @@ -79,8 +79,8 @@ protected void handleBigDataStartElement(Field dataField, Stack currentP @Override @Loggable(Loggable.TRACE) - protected void handleBigDataCharacters(char[] chars) throws IOException { - writer.write(chars); + protected void handleBigDataCharacters(char[] chars, int start, int length) throws IOException { + writer.write(chars, start, length); } @Override diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.java deleted file mode 100644 index 6050e76e..00000000 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxHttpComponentsMessageSender.java +++ /dev/null @@ -1,24 +0,0 @@ -package ee.ria.dhx.ws; - -import org.apache.http.client.methods.HttpPost; -import org.springframework.ws.transport.WebServiceConnection; -import org.springframework.ws.transport.http.HttpComponentsConnection; -import org.springframework.ws.transport.http.HttpComponentsMessageSender; -import org.springframework.ws.transport.http.HttpTransportConstants; - -import java.io.IOException; -import java.net.URI; - -public class DhxHttpComponentsMessageSender extends HttpComponentsMessageSender { - - @Override - public WebServiceConnection createConnection(URI uri) throws IOException { - HttpComponentsConnection connection = (HttpComponentsConnection) super.createConnection(uri); - HttpPost postMethod = connection.getHttpPost(); - postMethod.addHeader( - HttpTransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, - "base64"); - return super.createConnection(uri); - } - -} diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxOrganisationFactory.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxOrganisationFactory.java index fcb98151..5dff71af 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxOrganisationFactory.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/DhxOrganisationFactory.java @@ -5,9 +5,8 @@ import ee.ria.dhx.types.eu.x_road.dhx.producer.SendDocument; import ee.ria.dhx.util.StringUtil; import ee.ria.dhx.ws.config.SoapConfig; -import ee.ria.dhx.ws.context.AppContext; -import lombok.Setter; +import org.springframework.beans.factory.annotation.Autowired; /** * Class for creating DhxOrganisation. Simplifies object creation by setting dhxSubsystemPrefix @@ -18,8 +17,8 @@ */ public class DhxOrganisationFactory { - @Setter - private static String dhxSubsystemPrefix; + @Autowired + SoapConfig soapConfig; /** * Method for creating DhxOrganisation. Simplifies object creation by setting dhxSubsystemPrefix @@ -29,11 +28,8 @@ public class DhxOrganisationFactory { * @param system - system of the organisation(either Xroad subsystem or representee system) * @return DhxOrganisation object */ - public static DhxOrganisation createDhxOrganisation(String memberCode, String system) { - if (dhxSubsystemPrefix == null) { - SoapConfig config = AppContext.getApplicationContext().getBean(SoapConfig.class); - dhxSubsystemPrefix = config.getDhxSubsystemPrefix(); - } + public DhxOrganisation createDhxOrganisation(String memberCode, String system) { + String dhxSubsystemPrefix = soapConfig.getDhxSubsystemPrefix(); return new DhxOrganisation(memberCode, system, dhxSubsystemPrefix); } @@ -44,11 +40,8 @@ public static DhxOrganisation createDhxOrganisation(String memberCode, String sy * @param member - Xroad member of the organisation * @return DhxOrganisation object */ - public static DhxOrganisation createDhxOrganisation(InternalXroadMember member) { - if (dhxSubsystemPrefix == null) { - SoapConfig config = AppContext.getApplicationContext().getBean(SoapConfig.class); - dhxSubsystemPrefix = config.getDhxSubsystemPrefix(); - } + public DhxOrganisation createDhxOrganisation(InternalXroadMember member) { + String dhxSubsystemPrefix = soapConfig.getDhxSubsystemPrefix(); return new DhxOrganisation(member, dhxSubsystemPrefix); } @@ -60,7 +53,7 @@ public static DhxOrganisation createDhxOrganisation(InternalXroadMember member) * @param service - recipient of the request * @return DhxOrganisation object */ - public static DhxOrganisation createIncomingRecipientOrgnisation(SendDocument document, + public DhxOrganisation createIncomingRecipientOrgnisation(SendDocument document, InternalXroadMember service) { String code; String system; @@ -71,7 +64,7 @@ public static DhxOrganisation createIncomingRecipientOrgnisation(SendDocument do code = service.getMemberCode(); system = service.getSubsystemCode(); } - DhxOrganisation recipient = DhxOrganisationFactory.createDhxOrganisation(code, system); + DhxOrganisation recipient = createDhxOrganisation(code, system); return recipient; } diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxConfig.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxConfig.java index b7378183..789c7484 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxConfig.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxConfig.java @@ -1,7 +1,7 @@ package ee.ria.dhx.ws.config; +import ee.ria.dhx.ws.DhxOrganisationFactory; import org.springframework.beans.factory.annotation.Value; -// import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -124,10 +124,12 @@ public String getAcceptedDhxProtocolVersions() { */ @Bean public JAXBContext getJaxbContext() throws JAXBException { - if (this.jaxbContext == null) { - this.jaxbContext = JAXBContext.newInstance(marshallContext); - } - return jaxbContext; + return JAXBContext.newInstance(marshallContext); + } + + @Bean + public DhxOrganisationFactory dhxOrganisationFactory() { + return new DhxOrganisationFactory(); } diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxWebServiceConfig.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxWebServiceConfig.java new file mode 100644 index 00000000..4d3078c1 --- /dev/null +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/DhxWebServiceConfig.java @@ -0,0 +1,50 @@ +package ee.ria.dhx.ws.config; + +import lombok.Getter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.ws.soap.SoapMessageFactory; +import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory; + +import java.io.File; + +/** + * + * @author Kaarel Raspel + * + */ +@Configuration +public class DhxWebServiceConfig { + + @Value("${soap.dhx.attachment.cache.threshold:#{null}}") + @Getter + Integer attachmentCacheThreshold; + + @Value("${soap.dhx.attachment.cache.dir:#{null}}") + @Getter + String attachmentCacheDir; + + /** + * Creates messageFactory for sending and returns. + * @return messagefactory + */ + @Bean + @Primary + public SoapMessageFactory axiomSoapMessageFactorySend() { + return new AxiomSoapMessageFactory() {{ + Integer attachmentCacheThreshold = DhxWebServiceConfig.this.getAttachmentCacheThreshold(); + if (attachmentCacheThreshold != null) { + setAttachmentCaching(true); + setAttachmentCacheThreshold(attachmentCacheThreshold /* MB */ * 1024 /* KB */ * 1024 /* Byte */); + + String attachmentCacheDir = DhxWebServiceConfig.this.getAttachmentCacheDir(); + if (attachmentCacheDir != null) { + setAttachmentCacheDir(new File(attachmentCacheDir)); + } + } + }}; + } + +} diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/SoapConfig.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/SoapConfig.java index f1959ead..5f69bb71 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/SoapConfig.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/SoapConfig.java @@ -2,6 +2,16 @@ import ee.ria.dhx.types.InternalXroadMember; +import org.apache.http.HeaderElement; +import org.apache.http.HeaderElementIterator; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.conn.ConnectionKeepAliveStrategy; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicHeaderElementIterator; +import org.apache.http.protocol.HTTP; +import org.apache.http.protocol.HttpContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Bean; @@ -172,6 +182,50 @@ public String addPrefixIfNeeded(String system) { return system.toUpperCase(); } + @Bean + public ConnectionKeepAliveStrategy soapHttpClientKeepAliveStrategy() { + return new ConnectionKeepAliveStrategy() { + + public long getKeepAliveDuration(HttpResponse response, HttpContext context) { + + HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE)); + + while (it.hasNext()) { + HeaderElement he = it.nextElement(); + String param = he.getName(); + String value = he.getValue(); + if (value != null && param.equalsIgnoreCase("timeout")) { + + try { + return Long.parseLong(value) * 1000; + } catch(NumberFormatException ignore) { + } + + } + } + // otherwise keep alive for seconds + return getHttpTimeout() * 1000; + } + }; + } + + @Bean + public RequestConfig defaultRequestConfig() { + return RequestConfig.custom() + .setConnectTimeout(getConnectionTimeout()) + .setConnectionRequestTimeout(getReadTimeout()) + .build(); + } + + @Bean + public HttpClient soapHttpClient(ConnectionKeepAliveStrategy soapHttpClientKeepAliveStrategy, + RequestConfig defaultRequestConfig) { + return HttpClientBuilder.create() + .setKeepAliveStrategy(soapHttpClientKeepAliveStrategy) + .setDefaultRequestConfig(defaultRequestConfig) + .build(); + } + /** * Method returns default xroad client. That client will be used as sender when sending documents. * diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/endpoint/DhxEndpointConfig.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/endpoint/DhxEndpointConfig.java index 16e3838c..0a8cd852 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/endpoint/DhxEndpointConfig.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/endpoint/DhxEndpointConfig.java @@ -44,22 +44,16 @@ public class DhxEndpointConfig extends WsConfigurationSupport { * @return DefaultMethodEndpointAdapter */ @Bean(name = "dhxMethodEndpointAdapter") - public DefaultMethodEndpointAdapter dhxMethodEndpointAdapter() { - List argumentResolvers = null; - List returnValueHandlers = null; - if (argumentResolvers == null) { - argumentResolvers = new ArrayList(); - } - if (returnValueHandlers == null) { - returnValueHandlers = new ArrayList(); - } - returnValueHandlers.addAll(methodProcessors()); - argumentResolvers.addAll(methodProcessors()); + public DefaultMethodEndpointAdapter dhxMethodEndpointAdapter(List dhxMethodProcessors) { + final List argumentResolvers = new ArrayList(dhxMethodProcessors); + final List returnValueHandlers = new ArrayList(dhxMethodProcessors); + argumentResolvers.add(new MessageContextMethodArgumentResolver()); - DefaultMethodEndpointAdapter adapter = new DefaultMethodEndpointAdapter(); - adapter.setMethodArgumentResolvers(argumentResolvers); - adapter.setMethodReturnValueHandlers(returnValueHandlers); - return adapter; + + return new DefaultMethodEndpointAdapter() {{ + setMethodArgumentResolvers(argumentResolvers); + setMethodReturnValueHandlers(returnValueHandlers); + }}; } /** diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/marshaller/MarshallerConfig.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/marshaller/MarshallerConfig.java index 9da23d6d..70a1ee61 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/marshaller/MarshallerConfig.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/config/marshaller/MarshallerConfig.java @@ -49,12 +49,6 @@ import org.xml.sax.helpers.XMLReaderFactory; -//import org.apache.axiom.om.OMException; -//import org.apache.axiom.om.OMXMLStreamReader; -//import javax.xml.stream.XMLStreamReader; - - - /** * Contains beans needed for marshalling. * @@ -78,10 +72,10 @@ public class MarshallerConfig { public Jaxb2Marshaller getDhxJaxb2Marshaller() { DhxJaxb2Marshaller dhxJaxb2Marshaller = null; dhxJaxb2Marshaller = new DhxJaxb2Marshaller(); - //dhxJaxb2Marshaller.setMtomEnabled(true); log.debug("Creating marshaller for folowing paths: " + dhxConfig.getMarshallContext()); dhxJaxb2Marshaller.setContextPaths(dhxConfig.getMarshallContextAsList()); + dhxJaxb2Marshaller.setMtomEnabled(true); return dhxJaxb2Marshaller; } @@ -295,7 +289,7 @@ public String addSwaRefAttachment(DataHandler dataHandler) { String contentId = UUID.randomUUID() + "@" + dataHandler.getName(); this.mimeContainer.addAttachment(contentId, dataHandler); log.debug("DhxJaxb2AttachmentMarshaller.addSwaRefAttachment contentId={}", contentId); - return contentId; + return CID + contentId; } @Override diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/ChunkedHttpComponentsConnection.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/ChunkedHttpComponentsConnection.java new file mode 100644 index 00000000..97fc4645 --- /dev/null +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/ChunkedHttpComponentsConnection.java @@ -0,0 +1,66 @@ +package ee.ria.dhx.ws.connection; + +import lombok.SneakyThrows; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.FileEntity; +import org.apache.http.protocol.HttpContext; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.transport.http.HttpComponentsConnection; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; + +public class ChunkedHttpComponentsConnection extends HttpComponentsConnection { + + private final HttpClient httpClient; + private final HttpContext httpContext; + + private FileOutputStream requestOutputBuffer; + private File tempFile; + + protected ChunkedHttpComponentsConnection(HttpClient httpClient, HttpPost httpPost, HttpContext httpContext) { + super(httpClient, httpPost, httpContext); + this.httpClient = httpClient; + this.httpContext = httpContext; + } + + @Override + protected void onSendBeforeWrite(WebServiceMessage message) throws IOException { + this.tempFile = File.createTempFile("dhx_chunked_", ".tmp"); + this.requestOutputBuffer = new FileOutputStream(tempFile); + } + + @Override + protected OutputStream getRequestOutputStream() throws IOException { + return this.requestOutputBuffer; + } + + @Override + protected void onSendAfterWrite(WebServiceMessage message) throws IOException { + FileEntity chunkedEntity = new DeleteOnCloseChunkedFileEntity(this.tempFile); + this.getHttpPost().setEntity(chunkedEntity); + this.requestOutputBuffer = null; + this.tempFile = null; + if (this.httpContext != null) { + setHttpResponse(this.httpClient.execute(this.getHttpPost(), this.httpContext)); + } else { + setHttpResponse(this.httpClient.execute(this.getHttpPost())); + } + } + + @SneakyThrows + private void setHttpResponse(HttpResponse httpResponse) { + setParentField("httpResponse", httpResponse); + } + + private void setParentField(String fieldName, Object newValue) throws NoSuchFieldException, IllegalAccessException { + Field field = getClass().getSuperclass().getDeclaredField(fieldName); + FieldUtils.writeField(field, this, newValue, true); + } +} \ No newline at end of file diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DeleteOnCloseChunkedFileEntity.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DeleteOnCloseChunkedFileEntity.java new file mode 100644 index 00000000..dc48a598 --- /dev/null +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DeleteOnCloseChunkedFileEntity.java @@ -0,0 +1,20 @@ +package ee.ria.dhx.ws.connection; + +import org.apache.http.entity.FileEntity; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; + +public class DeleteOnCloseChunkedFileEntity extends FileEntity { + public DeleteOnCloseChunkedFileEntity(File file) { + super(file); + setChunked(true); + } + + public InputStream getContent() throws IOException { + return Files.newInputStream(file.toPath(), StandardOpenOption.DELETE_ON_CLOSE); + } +} diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DhxHttpComponentsMessageSender.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DhxHttpComponentsMessageSender.java new file mode 100644 index 00000000..0918ea4e --- /dev/null +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/connection/DhxHttpComponentsMessageSender.java @@ -0,0 +1,31 @@ +package ee.ria.dhx.ws.connection; + +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.protocol.HttpContext; +import org.springframework.ws.transport.WebServiceConnection; +import org.springframework.ws.transport.http.HttpComponentsMessageSender; +import org.springframework.ws.transport.http.HttpTransportConstants; + +import java.io.IOException; +import java.net.URI; + +public class DhxHttpComponentsMessageSender extends HttpComponentsMessageSender { + + public DhxHttpComponentsMessageSender(HttpClient httpClient) { + super(httpClient); + } + + @Override + public WebServiceConnection createConnection(URI uri) throws IOException { + HttpPost httpPost = new HttpPost(uri); + if (this.isAcceptGzipEncoding()) { + httpPost.addHeader("Accept-Encoding", "gzip"); + httpPost.addHeader(HttpTransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, "base64"); + } + + HttpContext httpContext = this.createContext(uri); + return new ChunkedHttpComponentsConnection(this.getHttpClient(), httpPost, httpContext); + } + +} diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/AddressServiceImpl.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/AddressServiceImpl.java index 8d91523d..c09f6c11 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/AddressServiceImpl.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/AddressServiceImpl.java @@ -72,6 +72,10 @@ public class AddressServiceImpl implements AddressService { @Setter DhxImplementationSpecificService dhxImplementationSpecificService; + @Autowired + @Setter + DhxOrganisationFactory dhxOrganisationFactory; + @Autowired DhxConfig dhxConfig; @@ -346,12 +350,12 @@ public InternalXroadMember getClientForMemberCode(String memberCode, List members = getAdresseeList(); Date curDate = new Date(); DhxOrganisation soughtOrganisation = - DhxOrganisationFactory.createDhxOrganisation(memberCode, system); + dhxOrganisationFactory.createDhxOrganisation(memberCode, system); if (members != null && members.size() > 0) { log.debug("local adressee list size: {}", members.size()); for (InternalXroadMember member : members) { DhxOrganisation addresslistOrganisation = - DhxOrganisationFactory.createDhxOrganisation(member); + dhxOrganisationFactory.createDhxOrganisation(member); if (addresslistOrganisation.equals(soughtOrganisation)) { if (member.getRepresentee() == null || (member.getRepresentee().getStartDate().getTime() <= curDate.getTime() diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxGateway.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxGateway.java index bc664dbf..29dd7aa9 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxGateway.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxGateway.java @@ -16,7 +16,7 @@ import ee.ria.dhx.types.eu.x_road.xsd.identifiers.XRoadServiceIdentifierType; import ee.ria.dhx.types.eu.x_road.xsd.representation.XRoadRepresentedPartyType; import ee.ria.dhx.util.StringUtil; -import ee.ria.dhx.ws.DhxHttpComponentsMessageSender; +import ee.ria.dhx.ws.connection.DhxHttpComponentsMessageSender; import ee.ria.dhx.ws.config.DhxConfig; import ee.ria.dhx.ws.config.SoapConfig; import ee.ria.dhx.ws.service.DhxMarshallerService; @@ -24,7 +24,9 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.apache.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.stereotype.Component; import org.springframework.ws.WebServiceMessage; @@ -36,8 +38,7 @@ import org.springframework.ws.soap.SoapHeader; import org.springframework.ws.soap.SoapHeaderElement; import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.soap.saaj.SaajSoapMessage; -import org.springframework.ws.transport.http.HttpTransportConstants; +import org.springframework.ws.soap.SoapMessageFactory; import org.springframework.xml.transform.StringSource; import java.io.IOException; @@ -47,20 +48,10 @@ import javax.annotation.PostConstruct; import javax.xml.bind.JAXBElement; -import javax.xml.soap.AttachmentPart; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; -import org.apache.http.impl.client.AbstractHttpClient; -import org.apache.http.conn.ConnectionKeepAliveStrategy; -import org.apache.http.HeaderElement; -import org.apache.http.HeaderElementIterator; -import org.apache.http.HttpResponse; -import org.apache.http.protocol.HTTP; -import org.apache.http.protocol.HttpContext; -import org.apache.http.message.BasicHeaderElementIterator; - @Slf4j @@ -88,44 +79,22 @@ public class DhxGateway extends WebServiceGatewaySupport { @Autowired Jaxb2Marshaller dhxJaxb2Marshaller; + @Autowired + HttpClient soapHttpClient; + + @Autowired + @Qualifier("axiomSoapMessageFactorySend") + SoapMessageFactory messageFactory; + /** * Postconstruct method which sets marshaller and unmarshaller. */ @PostConstruct public void init() { + setMessageFactory(messageFactory); setMarshaller(dhxJaxb2Marshaller); setUnmarshaller(dhxJaxb2Marshaller); - DhxHttpComponentsMessageSender messageSender = new DhxHttpComponentsMessageSender(); - messageSender.setConnectionTimeout(soapConfig.getConnectionTimeout()); - messageSender.setReadTimeout(soapConfig.getReadTimeout()); - - - AbstractHttpClient httpClient = (AbstractHttpClient)messageSender.getHttpClient(); - - httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { - - public long getKeepAliveDuration(HttpResponse response, HttpContext context) { - - HeaderElementIterator it = new BasicHeaderElementIterator( - response.headerIterator(HTTP.CONN_KEEP_ALIVE)); - - while (it.hasNext()) { - HeaderElement he = it.nextElement(); - String param = he.getName(); - String value = he.getValue(); - if (value != null && param.equalsIgnoreCase("timeout")) { - - try { - return Long.parseLong(value) * 1000; - } catch(NumberFormatException ignore) { - } - - } - } - // otherwise keep alive for seconds - return soapConfig.getHttpTimeout() * 1000; - } - }); + DhxHttpComponentsMessageSender messageSender = new DhxHttpComponentsMessageSender(soapHttpClient); getWebServiceTemplate().setMessageSender(messageSender); /* @@ -166,16 +135,6 @@ public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException { try { SoapHeader header = ((SoapMessage) message).getSoapHeader(); - for (Iterator it = ((SaajSoapMessage) message).getSaajMessage() - .getAttachments(); it.hasNext();) { - AttachmentPart attachment = (AttachmentPart) it.next(); - log.debug("attachment part: {}", - attachment.getContentType()); - attachment - .setMimeHeader( - HttpTransportConstants.HEADER_CONTENT_TRANSFER_ENCODING, - "base64"); - } // Transformer transformer = // SAXTransformerFactory.newInstance().newTransformer(); TransformerFactory fact = TransformerFactory @@ -326,6 +285,10 @@ protected SendDocumentResponse sendDocument(OutgoingDhxPackage document, + " faultString:" + response.getFault().getFaultString())); } catch (WebServiceFaultException ex) { + log.warn("Document send failed: {} ReceiptId: {} Fault: {}", + document.getService().toString(), + document.getService().getRepresentee(), + ex.getMessage()); Fault fault = new Fault(); fault.setFaultCode(ex.getWebServiceMessage().getFaultCode() .getLocalPart()); @@ -427,10 +390,10 @@ public InternalXroadMember getXroadClientAndSetRersponseHeader( MessageContext messageContext) throws DhxException { try { InternalXroadMember client = null; - SaajSoapMessage soapRequest = (SaajSoapMessage) messageContext + SoapMessage soapRequest = (SoapMessage) messageContext .getRequest(); SoapHeader reqheader = soapRequest.getSoapHeader(); - SaajSoapMessage soapResponse = (SaajSoapMessage) messageContext + SoapMessage soapResponse = (SoapMessage) messageContext .getResponse(); SoapHeader respheader = soapResponse.getSoapHeader(); TransformerFactory transformerFactory = TransformerFactory @@ -488,7 +451,7 @@ public InternalXroadMember getXroadClientAndSetRersponseHeader( public InternalXroadMember getXroadService(MessageContext messageContext) throws DhxException { InternalXroadMember service = null; - SaajSoapMessage soapRequest = (SaajSoapMessage) messageContext + SoapMessage soapRequest = (SoapMessage) messageContext .getRequest(); SoapHeader reqheader = soapRequest.getSoapHeader(); Iterator itr = reqheader.examineAllHeaderElements(); diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxMarshallerServiceImpl.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxMarshallerServiceImpl.java index 2d901672..65186a35 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxMarshallerServiceImpl.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxMarshallerServiceImpl.java @@ -17,6 +17,10 @@ import lombok.extern.slf4j.Slf4j; import org.apache.xml.serialize.XMLSerializer; +import org.codehaus.stax2.XMLStreamReader2; +import org.codehaus.stax2.validation.XMLValidationException; +import org.codehaus.stax2.validation.XMLValidationSchema; +import org.codehaus.stax2.validation.XMLValidationSchemaFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.w3c.dom.Node; @@ -43,13 +47,13 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLInputFactory; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; /** * Version DhxMarshallerService for capsules with big data files. No limitation on data file size is @@ -586,20 +590,27 @@ public void validate(final InputStream fileStream, InputStream schemaStream) throws DhxException { try { log.info("Starting validating document capsule."); - Source schemaSource = new StreamSource(schemaStream); // to prevent original inpustream closing crete a new one - Source xmlFile = new StreamSource(fileStream); - SchemaFactory schemaFactory = SchemaFactory - .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = schemaFactory.newSchema(schemaSource); - Validator validator = schema.newValidator(); - validator.validate(xmlFile); + XMLValidationSchemaFactory schemaFactory = XMLValidationSchemaFactory.newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA); + XMLValidationSchema validationSchema = schemaFactory.createSchema(schemaStream); + XMLStreamReader2 xmlStreamReader = (XMLStreamReader2) XMLInputFactory.newInstance().createXMLStreamReader(fileStream); + xmlStreamReader.validateAgainst(validationSchema); + + try { + while (xmlStreamReader.hasNext()) { + xmlStreamReader.next(); + } + } finally { + xmlStreamReader.close(); + } + log.info("Document capsule is validated."); - } catch (Exception ex) { + } catch (XMLValidationException ex) { throw new DhxException(DhxExceptionEnum.CAPSULE_VALIDATION_ERROR, - "Error occured while validating capsule. " - + ex.getMessage(), - ex); + "Error occurred while validating capsule. " + ex.getMessage(), ex); + } catch (Exception ex) { + throw new DhxException(DhxExceptionEnum.TECHNICAL_ERROR, + "Error occurred while preparing for capsule validation. " + ex.getMessage(), ex); } } diff --git a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxPackageServiceImpl.java b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxPackageServiceImpl.java index 180cb05f..7f146a89 100644 --- a/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxPackageServiceImpl.java +++ b/dhx-adapter-ws/src/main/java/ee/ria/dhx/ws/service/impl/DhxPackageServiceImpl.java @@ -71,6 +71,9 @@ public class DhxPackageServiceImpl implements DhxPackageService { @Autowired DhxImplementationSpecificService dhxImplementationSpecificService; + @Autowired + DhxOrganisationFactory dhxOrganisationFactory; + private void checkProtocolVersion(String protocolVersion) throws DhxException { log.debug("checking protocol version " + protocolVersion); @@ -237,7 +240,7 @@ protected IncomingDhxPackage extractAndValidateDocument( } log.info("Document received."); DhxOrganisation recipient = - DhxOrganisationFactory.createIncomingRecipientOrgnisation(document, service); + dhxOrganisationFactory.createIncomingRecipientOrgnisation(document, service); IncomingDhxPackage dhxDocument = new IncomingDhxPackage(client, service, document, container, CapsuleVersionEnum.forClass(container.getClass()), recipient); @@ -299,7 +302,7 @@ protected IncomingDhxPackage extractAndValidateDocumentNoParsing( log.debug("Validating capsule is disabled"); } DhxOrganisation recipient = - DhxOrganisationFactory.createIncomingRecipientOrgnisation(document, service); + dhxOrganisationFactory.createIncomingRecipientOrgnisation(document, service); IncomingDhxPackage dhxDocument = new IncomingDhxPackage(client, service, document, recipient); if (config.getCheckRecipient()) { @@ -348,13 +351,13 @@ protected void checkRecipient(DhxOrganisation recipient, if (representee.getStartDate().getTime() <= curDate.getTime() && (representee.getEndDate() == null || representee .getEndDate().getTime() >= curDate.getTime())) { - recipientList.add(DhxOrganisationFactory.createDhxOrganisation(representee + recipientList.add(dhxOrganisationFactory.createDhxOrganisation(representee .getRepresenteeCode(), representee.getRepresenteeSystem())); } } } for (String subSystem : soapConfig.getAcceptedSubsystemsAsList()) { - recipientList.add(DhxOrganisationFactory.createDhxOrganisation(soapConfig.getMemberCode(), + recipientList.add(dhxOrganisationFactory.createDhxOrganisation(soapConfig.getMemberCode(), subSystem)); } Boolean found = false; @@ -403,7 +406,7 @@ protected void checkRecipient(DhxOrganisation recipient, protected void checkSender(InternalXroadMember client, CapsuleAdressee capsuleSender) throws DhxException { log.info("Checking sender."); - DhxOrganisation sender = DhxOrganisationFactory.createDhxOrganisation(client); + DhxOrganisation sender = dhxOrganisationFactory.createDhxOrganisation(client); if (client.getRepresentee() != null) { InternalXroadMember member = addressService.getClientForMemberCode( client.getMemberCode(), client.getSubsystemCode()); diff --git a/dhx-adapter-ws/src/main/resources/application.properties.example b/dhx-adapter-ws/src/main/resources/application.properties.example index 01eba7bf..813945d2 100644 --- a/dhx-adapter-ws/src/main/resources/application.properties.example +++ b/dhx-adapter-ws/src/main/resources/application.properties.example @@ -54,6 +54,14 @@ soap.accepted-subsystems=DHX,DHX.subsystem #soap.read-timeout=120000 #soap.http-timeout=300 +# # # # # +# Increasing memory efficiency while sending large documents +# # # # # +# Tells DHX to use filesystem caching instead of memory if attachment size is bigger than following value in MB. +#soap.dhx.attachment.cache.threshold=10 +# Specify directory to be used for caching. By default Java temp directory. +#soap.dhx.attachment.cache.dir= + #template representing how many times and with how bug timeouts document will be resent. #for example 5,10,15 means that after first failed try application will wait 5 seconds and try again. #If second attempt fails, then there will be 10 seconds timeout before third attempt and so on diff --git a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/TestApp.java b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/TestApp.java index 5f278330..81fc789b 100644 --- a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/TestApp.java +++ b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/TestApp.java @@ -13,10 +13,16 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.test.context.TestPropertySource; +import org.springframework.ws.soap.SoapMessageFactory; // @SpringBootApplication @TestPropertySource("classpath:test-application.properties") -@ComponentScan(basePackages = "ee.ria.dhx.ws.config,ee.ria.dhx.ws.config.endpoint,ee.ria.dhx.ws,ee.ria.dhx.ws.service.impl") +@ComponentScan(basePackages = { + "ee.ria.dhx.ws.config", + "ee.ria.dhx.ws.config.endpoint", + "ee.ria.dhx.ws", + "ee.ria.dhx.ws.service.impl" +}) @Slf4j // @EnableAutoConfiguration public class TestApp { @@ -49,4 +55,10 @@ public DhxImplementationSpecificService getDhxImplementationSpecificService() return specificService; } + @Bean + @Primary + public SoapMessageFactory messageFactory(SoapMessageFactory axiomSoapMessageFactorySend) { + return Mockito.spy(axiomSoapMessageFactorySend); + } + } diff --git a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/integration/DhxServerIT.java b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/integration/DhxServerIT.java index 6633720f..350f382e 100644 --- a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/integration/DhxServerIT.java +++ b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/integration/DhxServerIT.java @@ -5,6 +5,7 @@ import static org.springframework.ws.test.server.RequestCreators.withSoapEnvelope; import ee.ria.dhx.exception.DhxException; +import ee.ria.dhx.mock.MockWebServiceClient; import ee.ria.dhx.types.DhxRepresentee; import ee.ria.dhx.types.IncomingDhxPackage; import ee.ria.dhx.types.InternalXroadMember; @@ -17,11 +18,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -/* - * import org.springframework.ws.test.server.MockWebServiceClient; import - * org.springframework.ws.test.server.RequestCreator; import - * org.springframework.ws.test.server.RequestCreators; - */ import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -32,7 +28,6 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.ws.context.MessageContext; -import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.ws.test.server.ResponseMatchers; import java.util.ArrayList; @@ -46,8 +41,6 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -// import org.springframework.test.context.junit4.SpringRunner; - /** * Tests on DhxEndpoint. Real XML-s are sent to endpoint and received response is being validated. * diff --git a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/AddressServiceImplTest.java b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/AddressServiceImplTest.java index dadee1b1..84cab902 100644 --- a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/AddressServiceImplTest.java +++ b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/AddressServiceImplTest.java @@ -25,6 +25,8 @@ import ee.ria.dhx.ws.service.DhxImplementationSpecificService; import ee.ria.dhx.ws.service.DhxMarshallerService; +import org.mockito.InjectMocks; +import org.mockito.Spy; import org.springframework.core.io.ClassPathResource; import org.junit.Before; @@ -39,7 +41,6 @@ import java.io.IOException; import java.io.InputStream; -import java.io.FileInputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -64,6 +65,9 @@ public class AddressServiceImplTest { @Mock DhxGateway dhxGateway; + @InjectMocks + DhxOrganisationFactory dhxOrganisationFactory; + AddressServiceImpl addressService; @Mock @@ -80,11 +84,11 @@ public void init() { addressService.setDhxGateway(dhxGateway); addressService.setDhxMarshallerService(dhxMarshallerService); addressService.setDhxImplementationSpecificService(specificService); + addressService.setDhxOrganisationFactory(dhxOrganisationFactory); when(config.getXroadInstance()).thenReturn("ee"); when(config.getDhxRepresentationGroupName()).thenReturn("DHX vahendajad"); when(config.getDhxSubsystemPrefix()).thenReturn("DHX"); //when(config.getGlobalConfLocation()).thenReturn("http://x-road.eu/packages/EE_public-anchor.xml"); - DhxOrganisationFactory.setDhxSubsystemPrefix("DHX"); } @Test diff --git a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/DhxPackageServceImplTest.java b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/DhxPackageServceImplTest.java index 37c93ff5..94dcab60 100644 --- a/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/DhxPackageServceImplTest.java +++ b/dhx-adapter-ws/src/test/java/ee/ria/dhx/ws/service/impl/DhxPackageServceImplTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertNull; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -21,6 +22,7 @@ import ee.ria.dhx.types.eu.x_road.dhx.producer.SendDocument; import ee.ria.dhx.types.eu.x_road.dhx.producer.SendDocumentResponse; import ee.ria.dhx.util.CapsuleVersionEnum; +import ee.ria.dhx.util.FileDataHandler; import ee.ria.dhx.util.FileUtil; import ee.ria.dhx.ws.DhxOrganisationFactory; import ee.ria.dhx.ws.config.CapsuleConfig; @@ -29,59 +31,76 @@ import ee.ria.dhx.ws.service.DhxImplementationSpecificService; import ee.ria.dhx.ws.service.DhxMarshallerService; +import org.assertj.core.util.Lists; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.springframework.core.io.ClassPathResource; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.util.ResourceUtils; import org.springframework.ws.context.MessageContext; -import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; + +@RunWith(MockitoJUnitRunner.class) public class DhxPackageServceImplTest { - @Mock - DhxGateway dhxGateway; + private static final String FILE_NAME_KAPSEL_21_XML = "kapsel_21.xml"; + private FileDataHandler FILE_HANDLER_KAPSEL_21_XML = FileUtil.getDatahandlerFromFile( + ResourceUtils.getFile("classpath:" + FILE_NAME_KAPSEL_21_XML) + ); + + private final SendDocument REQUEST = new SendDocument() {{ + consignmentId = "consignmentId"; + documentAttachment = FILE_HANDLER_KAPSEL_21_XML; + dhxVersion = "1.0"; + }}; + private final InternalXroadMember CLIENT = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); + private final InternalXroadMember SERVICE = new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + private final InternalXroadMember SERVICE_SUBSYSTEM = new InternalXroadMember("ee", "GOV", "401", "DHX.subsystem", "Name", null); @Mock - DhxImplementationSpecificService dhxImplementationSpecificService; + private DhxGateway dhxGateway; @Mock - DhxConfig dhxConfig; + private DhxImplementationSpecificService dhxImplementationSpecificService; - DhxPackageServiceImpl dhxPackageService; + @Mock + private DhxConfig dhxConfig; @Mock - DhxMarshallerService dhxMarshallerService; + private DhxMarshallerService dhxMarshallerService; @Mock - CapsuleConfig capsuleConfig; + private CapsuleConfig capsuleConfig; @Mock - SoapConfig soapConfig; + private SoapConfig soapConfig; + + @InjectMocks + private DhxOrganisationFactory dhxOrganisationFactory = spy(DhxOrganisationFactory.class); + + @InjectMocks + private DhxPackageServiceImpl dhxPackageService; @Rule public ExpectedException expectedEx = ExpectedException.none(); + public DhxPackageServceImplTest() throws FileNotFoundException {} + @Before public void init() throws DhxException { - MockitoAnnotations.initMocks(this); - dhxPackageService = new DhxPackageServiceImpl(); - dhxPackageService.setDocumentGateway(dhxGateway); - dhxPackageService.setDhxImplementationSpecificService(dhxImplementationSpecificService); - dhxPackageService.setConfig(dhxConfig); - dhxPackageService.setDhxMarshallerService(dhxMarshallerService); - dhxPackageService.setCapsuleConfig(capsuleConfig); - dhxPackageService.setSoapConfig(soapConfig); when(dhxConfig.getCapsuleValidate()).thenReturn(true); when(dhxConfig.getCheckDhxVersion()).thenReturn(true); when(dhxConfig.getCheckDuplicate()).thenReturn(true); @@ -90,25 +109,23 @@ public void init() throws DhxException { when(dhxConfig.getParseCapsule()).thenReturn(true); when(dhxConfig.getParseCapsule()).thenReturn(true); when(dhxConfig.getAcceptedDhxProtocolVersions()).thenReturn(",1.0,"); + when(capsuleConfig.getCurrentCapsuleVersion()).thenReturn(CapsuleVersionEnum.V21); - when(capsuleConfig.getXsdForVersion(CapsuleVersionEnum.V21)).thenReturn( - "jar://Dvk_kapsel_vers_2_1_eng_est.xsd"); - DhxOrganisationFactory.setDhxSubsystemPrefix("DHX"); - List subsystems = new ArrayList(); - subsystems.add("DHX"); + when(capsuleConfig.getXsdForVersion(CapsuleVersionEnum.V21)).thenReturn("jar://Dvk_kapsel_vers_2_1_eng_est.xsd"); + + List subsystems = Lists.newArrayList("DHX"); when(soapConfig.getAcceptedSubsystemsAsList()).thenReturn(subsystems); when(soapConfig.getMemberCode()).thenReturn("401"); + when(soapConfig.getDhxSubsystemPrefix()).thenReturn("DHX"); - List adressees = new ArrayList(); - CapsuleAdressee adressee = new CapsuleAdressee("401"); - adressees.add(adressee); - when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); + CapsuleAdressee addressee = new CapsuleAdressee("401"); + List addressees = Lists.newArrayList(addressee); + when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(addressees); CapsuleAdressee sender = new CapsuleAdressee("400"); when(capsuleConfig.getSenderFromContainer(any())).thenReturn(sender); - when( - dhxImplementationSpecificService.isDuplicatePackage(any(InternalXroadMember.class), - anyString())).thenReturn(false); + when(dhxImplementationSpecificService.isDuplicatePackage(any(InternalXroadMember.class), anyString())) + .thenReturn(false); } @@ -116,10 +133,13 @@ public void init() throws DhxException { @Test public void sendPackage() throws DhxException { + // Prepare OutgoingDhxPackage pckg = new OutgoingDhxPackage(null, null, null, null, null); SendDocumentResponse resp = new SendDocumentResponse(); when(dhxGateway.sendDocument(pckg)).thenReturn(resp); + // Test DhxSendDocumentResult result = dhxPackageService.sendPackage(pckg); + // Verify assertEquals(pckg, result.getSentPackage()); assertEquals(resp, result.getResponse()); verify(dhxGateway, times(1)).sendDocument(pckg); @@ -127,13 +147,16 @@ public void sendPackage() throws DhxException { @Test public void sendMultiplePackages() throws DhxException { + // Prepare List pckgs = new ArrayList(); OutgoingDhxPackage pckg = new OutgoingDhxPackage(null, null, null, null, null); pckgs.add(pckg); pckgs.add(pckg); SendDocumentResponse resp = new SendDocumentResponse(); when(dhxGateway.sendDocument(pckg)).thenReturn(resp); + // Test List results = dhxPackageService.sendMultiplePackages(pckgs); + // Verify assertEquals(2, results.size()); assertEquals(pckg, results.get(0).getSentPackage()); assertEquals(resp, results.get(0).getResponse()); @@ -159,45 +182,29 @@ private DecContainer getContainer() { @Test public void receiveDocumentFromEndpoint() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + SendDocumentResponse response = dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify assertEquals("id1", response.getReceiptId()); assertNull(response.getFault()); - verify(dhxMarshallerService, times(1)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + verify(dhxMarshallerService, times(1)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointToRepresentee() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("410"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setRecipient("410"); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", new Date(), null, null, null); representees.add(representee); @@ -207,38 +214,29 @@ public void receiveDocumentFromEndpointToRepresentee() throws DhxException, IOEx when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + SendDocumentResponse response = dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify assertEquals("id1", response.getReceiptId()); assertNull(response.getFault()); - verify(dhxMarshallerService, times(1)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + verify(dhxMarshallerService, times(1)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointToRepresenteeSubsystem() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("410"); - request.setRecipientSystem("subsystem"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setRecipient("410"); + REQUEST.setRecipientSystem("subsystem"); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", new Date(), null, null, "subsystem"); representees.add(representee); @@ -248,519 +246,367 @@ public void receiveDocumentFromEndpointToRepresenteeSubsystem() throws DhxExcept when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + SendDocumentResponse response = dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify assertEquals("id1", response.getReceiptId()); assertNull(response.getFault()); - verify(dhxMarshallerService, times(1)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + verify(dhxMarshallerService, times(1)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointToRepresenteeOutdated() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("410"); - request.setRecipientSystem("subsystem"); + // Prepare + REQUEST.setRecipient("410"); + REQUEST.setRecipientSystem("subsystem"); Date date = new Date(); Date date2 = new Date(date.getTime()-10000); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", date, date2, null, "subsystem"); representees.add(representee); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx .expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointToRepresenteeWrongCapsuleAdressee() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("410"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setRecipient("410"); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", new Date(), null, null, null); representees.add(representee); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); - expectedEx - .expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + expectedEx.expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointToWrongRepresentee() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("420"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setRecipient("420"); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", new Date(), null, null, "subsystem"); representees.add(representee); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx .expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointToWrongRepresenteeSubsystem() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - request.setRecipient("410"); - request.setRecipientSystem("subsystem2"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setRecipient("410"); + REQUEST.setRecipientSystem("subsystem2"); List representees = new ArrayList(); DhxRepresentee representee = new DhxRepresentee("410", new Date(), null, null, "subsystem"); representees.add(representee); when(dhxImplementationSpecificService.getRepresentationList()).thenReturn(representees); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class),any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx .expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointNonDefaultSubsystem() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX.subsystem", "Name", null); - DhxOrganisationFactory.setDhxSubsystemPrefix("DHX"); - List subsystems = new ArrayList(); - subsystems.add("DHX.subsystem"); + // Prepare + List subsystems = Lists.newArrayList("DHX.subsystem"); when(soapConfig.getAcceptedSubsystemsAsList()).thenReturn(subsystems); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE_SUBSYSTEM, null); + // Verify assertEquals("id1", response.getReceiptId()); assertNull(response.getFault()); - verify(dhxMarshallerService, times(1)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + verify(dhxMarshallerService, times(1)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointWrongSubsystem() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX.subsystem", "Name", null); + // Prepare when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx .expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE_SUBSYSTEM, null); } @Test public void receiveDocumentFromEndpointNoParsing() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getParseCapsule()).thenReturn(false); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); - verify(dhxMarshallerService, times(1)).validate(any(InputStream.class), - any(InputStream.class)); - verify(dhxMarshallerService, times(0)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class),any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify + verify(dhxMarshallerService, times(1)) + .validate(any(InputStream.class), any(InputStream.class)); + verify(dhxMarshallerService, times(0)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); } @Test public void receiveDocumentFromEndpointNovalidation() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getCapsuleValidate()).thenReturn(false); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); - verify(dhxMarshallerService, times(1)).unmarshallAndValidate(any(InputStream.class), - Mockito.isNull(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify + verify(dhxMarshallerService, times(1)) + .unmarshallAndValidate(any(InputStream.class), Mockito.isNull(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointNoValidationNoParsing() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getCapsuleValidate()).thenReturn(false); when(dhxConfig.getParseCapsule()).thenReturn(false); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); - verify(dhxMarshallerService, times(0)).unmarshallAndValidate(any(InputStream.class), - any(InputStream.class)); - verify(dhxMarshallerService, times(0)).validate(any(InputStream.class), - Mockito.isNull(InputStream.class)); - verify(dhxImplementationSpecificService, times(1)).receiveDocument( - any(IncomingDhxPackage.class), any(MessageContext.class)); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify + verify(dhxMarshallerService, times(0)) + .unmarshallAndValidate(any(InputStream.class), any(InputStream.class)); + verify(dhxMarshallerService, times(0)) + .validate(any(InputStream.class), Mockito.isNull(InputStream.class)); + verify(dhxImplementationSpecificService, times(1)) + .receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class)); + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointDuplicate() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - when( - dhxImplementationSpecificService.isDuplicatePackage(any(InternalXroadMember.class), - anyString())).thenReturn(true); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + when(dhxImplementationSpecificService.isDuplicatePackage(any(InternalXroadMember.class), anyString())) + .thenReturn(true); + // Verify expectedEx.expect(DhxException.class); expectedEx.expectMessage("DHX.Duplicate Already got package with this consignmentID"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); - verify(dhxImplementationSpecificService, times(1)).isDuplicatePackage( - any(InternalXroadMember.class), anyString()); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify + verify(dhxImplementationSpecificService, times(1)) + .isDuplicatePackage(any(InternalXroadMember.class), anyString()); } @Test public void receiveDocumentFromEndpointRepresenteeSender() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); + // Prepare List adressees = new ArrayList(); CapsuleAdressee adressee = new CapsuleAdressee("500"); adressees.add(adressee); when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); DhxRepresentee representee = new DhxRepresentee("400", null, null, null, null); representee.setRepresenteeCode("400"); - InternalXroadMember client = - new InternalXroadMember("ee", "GOV", "420", "DHX", "Name", representee); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); - expectedEx - .expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + expectedEx.expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointWrongCapsuleAdressee() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); + // Prepare List adressees = new ArrayList(); CapsuleAdressee adressee = new CapsuleAdressee("500"); adressees.add(adressee); when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); - expectedEx - .expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + expectedEx.expectMessage("DHX.InvalidAddressee Recipient not found in capsule recipient list"); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointWrongAdressee() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "501", "DHX", "Name", null); + InternalXroadMember service = new InternalXroadMember("ee", "GOV", "501", "DHX", "Name", null); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); - expectedEx - .expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + expectedEx.expectMessage("DHX.InvalidAddressee Recipient not found in representativesList and own member code"); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, service, null); } @Test public void receiveDocumentFromEndpointNoRecipientCheck() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); + // Prepare List adressees = new ArrayList(); CapsuleAdressee adressee = new CapsuleAdressee("500"); adressees.add(adressee); when(capsuleConfig.getAdresseesFromContainer(any())).thenReturn(adressees); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); when(dhxConfig.getCheckRecipient()).thenReturn(false); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Test + SendDocumentResponse response = dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify assertEquals("id1", response.getReceiptId()); assertNull(response.getFault()); } @Test public void receiveDocumentFromEndpointWrongSender() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); InternalXroadMember client = new InternalXroadMember("ee", "GOV", "500", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx.expectMessage("DHX.SenderDoesNotMatch Xroad sender not found in capsule"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, client, SERVICE, null); } @Test public void receiveDocumentFromEndpointNoSenderCheck() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "500", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare when(dhxConfig.getCheckSender()).thenReturn(false); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); - SendDocumentResponse response = - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + SendDocumentResponse response = dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); + // Verify assertEquals("id1", response.getReceiptId()); + // Test assertNull(response.getFault()); } @Test public void receiveDocumentFromEndpointWrongVersion() throws DhxException, IOException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - request.setDHXVersion("2.0"); - File file = new ClassPathResource("kapsel_21.xml").getFile(); - request.setDocumentAttachment(FileUtil.getDatahandlerFromFile(file)); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setDHXVersion("2.0"); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx.expectMessage("DHX.UnsupportedVersion Version not supported"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } @Test public void receiveDocumentFromEndpointNoDocument() throws DhxException { - SendDocument request = new SendDocument(); - request.setConsignmentId("consignmentId"); - request.setDHXVersion("1.0"); - InternalXroadMember client = new InternalXroadMember("ee", "GOV", "400", "DHX", "Name", null); - InternalXroadMember service = - new InternalXroadMember("ee", "GOV", "401", "DHX", "Name", null); + // Prepare + REQUEST.setDocumentAttachment(null); when(dhxConfig.getParseCapsule()).thenReturn(true); - when( - dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), - any(MessageContext.class))).thenReturn("id1"); - when( - dhxMarshallerService - .unmarshallAndValidate(any(InputStream.class), any(InputStream.class))).thenReturn( - new DecContainer()); + when(dhxImplementationSpecificService.receiveDocument(any(IncomingDhxPackage.class), any(MessageContext.class))) + .thenReturn("id1"); + when(dhxMarshallerService.unmarshallAndValidate(any(InputStream.class), any(InputStream.class))) + .thenReturn(new DecContainer()); + // Verify expectedEx.expect(DhxException.class); expectedEx.expectMessage("Attached capsule is not found in request"); - dhxPackageService.receiveDocumentFromEndpoint(request, client, service, null); + // Test + dhxPackageService.receiveDocumentFromEndpoint(REQUEST, CLIENT, SERVICE, null); } } diff --git a/dhx-adapter-ws/src/test/resources/Dvk_kapsel_vers_2_1_eng_est.xsd b/dhx-adapter-ws/src/test/resources/Dvk_kapsel_vers_2_1_eng_est.xsd index 75c73a6c..041e9b5a 100644 --- a/dhx-adapter-ws/src/test/resources/Dvk_kapsel_vers_2_1_eng_est.xsd +++ b/dhx-adapter-ws/src/test/resources/Dvk_kapsel_vers_2_1_eng_est.xsd @@ -643,7 +643,7 @@ - + diff --git a/dhx-adapter-ws/src/test/resources/test-application.properties b/dhx-adapter-ws/src/test/resources/test-application.properties index ea642976..40c1b642 100644 --- a/dhx-adapter-ws/src/test/resources/test-application.properties +++ b/dhx-adapter-ws/src/test/resources/test-application.properties @@ -29,7 +29,7 @@ dhx.parse-capsule=true #soap.security-server-appender=/cgi-bin/consumer_proxy -soap.security-server=https://try +soap.security-server=http://try soap.xroad-instance=ee-dev soap.member-class=GOV soap.protocol-version=4.0 diff --git a/pom.xml b/pom.xml index ce9eccb8..75384416 100644 --- a/pom.xml +++ b/pom.xml @@ -5,9 +5,11 @@ ee.ria.dhx DHX-adapter - 1.0.4 + ${revision} pom + 1.0.4-SNAPSHOT + UTF-8 1.7 @@ -77,7 +79,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M1 + 3.0.0-M3 org.apache.maven.plugins @@ -185,7 +187,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M1 + 3.0.0-M3