<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxrs-client="http://cxf.apache.org/jaxrs-client" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
         http://cxf.apache.org/jaxrs-client http://cxf.apache.org/schemas/jaxrs-client.xsd
         http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
		 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
                 
	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
	<import resource="classpath:gov/va/med/cds/ejb/config/envSpecificContext.xml"/>
	
	<bean id="samlHandler" class="gov.va.med.cds.ws.saml.handler.SamlAuthorizationHeaderInHandler"/>
	<bean id="cleanupOutInterceptor" class="gov.va.med.cds.ws.saml.interceptor.CleanupOutInterceptor"/>
	<bean id="clientSoapInterceptor" class="gov.va.med.cds.ws.saml.interceptor.client.ClientSoapHeaderOutInterceptor"/>
	
	<bean id="routingXsltOutInterceptor" class="gov.va.med.repositories.fpds.interceptor.RoutingXsltOutInterceptor">
		<property name="outInterceptors">
			<map>
				<entry key="json" value="templates/response/GenericObservationRead1-json.xsl" />
				<entry key="xml" value="templates/response/GenericObservationRead1-xml.xsl" />
			</map>
		</property>
		<property name="linkDomainToResponseTypeOfRPC" ref="linkDomainToResponseTypeOfRPC" />
	</bean>

	<bean id="routingPgdXsltOutInterceptor" class="gov.va.med.repositories.fpds.interceptor.RoutingXsltOutInterceptor">
		<property name="outInterceptors">
			<map>
				<entry key="json" value="templates/response/PGDRead1-json.xsl" />
			</map>
		</property>
	</bean>

	<jaxrs:server id="fpds" address="/">
		<jaxrs:serviceBeans>
			<bean class="gov.va.med.repositories.fpds.webservice.FederatingPatientRecordRestService">
				<!-- <property name="clinicalDataService" ref="cdsStatelessSession" /> -->
				<property name="clinicalDataServiceWS" ref="cdsSoapService" />
				<property name="requestValidator">
					<bean class="gov.va.med.repositories.fpds.validator.DefaultRequestValidator" />
				</property>
				<property name="filterBuilder">
					<bean class="gov.va.med.repositories.fpds.filter.HmpReadRequestXsltFilterBuilder">
						<property name="filterTransformerTemplate" value="templates/filter/HmpFilter100.xsl" />
					</bean>
				</property>
				<property name="applicationName" value="FPDS" />
				<property name="errorTemplateDocument" value="templates/response/HmpGenericObservationRead1.xml" />
			</bean>
		</jaxrs:serviceBeans>
		<jaxrs:providers>
      		<ref bean="samlHandler"/>
   		</jaxrs:providers>
		<jaxrs:outInterceptors>
			<ref bean="cleanupOutInterceptor"/>
			<ref bean="routingXsltOutInterceptor" />
		</jaxrs:outInterceptors>
	</jaxrs:server>

	<jaxrs:server id="fpds-pubsub" address="/vpr">
		<jaxrs:serviceBeans>
			<bean class="gov.va.med.repositories.fpds.webservice.FederatingPatientRecordRestService">
				<!-- <property name="clinicalDataService" ref="cdsStatelessSession" /> -->
				<!-- <property name="clinicalDataService" ref="cdsRestClientProxy" />-->
				<property name="clinicalDataServiceWS" ref="cdsSoapService" />
 			
				<property name="requestValidator">
					<bean class="gov.va.med.repositories.fpds.validator.VprCommandRequestValidator">
						<property name="maxValue" value="500" />
					</bean>
				</property>
				<property name="filterBuilder">
					<bean class="gov.va.med.repositories.fpds.filter.VprSubscribeUpdatesCancelRequestXsltFilterBuilder">
						<property name="filterTransformerTemplate" value="templates/filter/VprSubscribeUpdatesCancelFilter100.xsl" />
					</bean>
				</property>
				<property name="applicationName" value="FPDS-PUBSUB" />
				<property name="errorTemplateDocument" value="templates/response/HmpGenericObservationRead1.xml" />
				<property name="linkDomainToResponseTypeOfRPC" ref="linkDomainToResponseTypeOfRPC" />
			</bean>
		</jaxrs:serviceBeans>
		<jaxrs:providers>
      		<ref bean="samlHandler"/>
   		</jaxrs:providers>
		<jaxrs:outInterceptors>
			<ref bean="cleanupOutInterceptor"/>
			<ref bean="routingXsltOutInterceptor" />
		</jaxrs:outInterceptors>
	</jaxrs:server>

	<util:map id="linkDomainToResponseTypeOfRPC">
		<entry key="RAD" value="xml" />
		<entry key="FLAGS" value="xml" />
	</util:map>

	<jaxrs:server id="fpds-pgd" address="/pgd">
		<jaxrs:serviceBeans>
			<bean class="gov.va.med.repositories.fpds.webservice.FederatedPatientGeneratedDataRestService">
				<!-- <property name="clinicalDataService" ref="cdsStatelessSession" />-->
				<property name="clinicalDataServiceWS" ref="cdsSoapService" />
				<property name="requestValidator">
					<bean class="gov.va.med.repositories.fpds.validator.DefaultRequestValidator" />
				</property>
				<property name="filterBuilderMap">
					<map>
						<entry>
							<key>
								<util:constant
									static-field="gov.va.med.repositories.fpds.webservice.FederatedPatientGeneratedDataRestService.PATIENT_FILTER_KEY" />
							</key>
							<bean class="gov.va.med.repositories.fpds.filter.GenericReadRequestXsltFilterBuilder">
								<property name="filterTransformerTemplate" value="templates/filter/GenericFilter100.xsl" />
							</bean>
						</entry>
						<entry>
							<key>
								<util:constant
									static-field="gov.va.med.repositories.fpds.webservice.FederatedPatientGeneratedDataRestService.RECORD_IDENTIFIER_FILTER_KEY" />
							</key>
							<bean class="gov.va.med.repositories.fpds.filter.RecordIdentifierReadRequestXsltFilterBuilder">
								<property name="filterTransformerTemplate" value="templates/filter/RecordIdentifierFilter.xsl" />
							</bean>
						</entry>
					</map>
				</property>
				<property name="applicationName" value="FPDS-PGD" />
				<property name="errorTemplateDocument" value="templates/response/PGDRead1ErrorDocument.xml" />
			</bean>
		</jaxrs:serviceBeans>
		<jaxrs:outInterceptors>
			<ref bean="routingPgdXsltOutInterceptor" />
		</jaxrs:outInterceptors>
	</jaxrs:server>
  
  <!-- The SOAP client bean -->	  	
  <bean id="cdsClientproxyFactory"
    class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
    <property name="serviceClass" value="gov.va.med.cds.client.webservice.ClinicalDataServiceSynchronousInterface"/>
    <property name="address" ref="CDS_SVC_ID"/>
    <property name="outInterceptors" ref="soapOutInterceptors"/>
  </bean>

  <util:list id="soapOutInterceptors" value-type="org.apache.cxf.interceptor.Interceptor">
  	<ref bean="clientSoapInterceptor"/>
  </util:list>
  
  <bean id="cdsSoapService" class="gov.va.med.cds.client.webservice.ClinicalDataServiceSynchronousInterface"
    factory-bean="cdsClientproxyFactory" factory-method="create"/>
   	
  <!-- <jee:remote-slsb id="cdsStatelessSession"
		jndi-name="ejb/remote/gov/va/med/cds/ClinicalDataServiceSynchronousSession" business-interface="gov.va.med.cds.client.ClinicalDataServiceInterface" />
   -->

</beans>
