diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java index cc78e20..accb48e 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java @@ -7,6 +7,7 @@ */ package com.ozonehis.fhir; +import com.odoojava.api.OdooXmlRpcProxy; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -42,4 +43,14 @@ public void validateOdooProperties() { throw new IllegalArgumentException("OdooProtocol is required"); } } + + public OdooXmlRpcProxy.RPCProtocol getRPCProtocol() { + if (OdooProtocol.equalsIgnoreCase("http")) { + return OdooXmlRpcProxy.RPCProtocol.RPC_HTTP; + } else if (OdooProtocol.equalsIgnoreCase("https")) { + return OdooXmlRpcProxy.RPCProtocol.RPC_HTTPS; + } else { + throw new IllegalArgumentException("Invalid OdooProtocol"); + } + } } diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/SessionHolder.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/SessionHolder.java index 34e09e5..adf2faa 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/SessionHolder.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/SessionHolder.java @@ -8,9 +8,7 @@ package com.ozonehis.fhir.odoo; import com.odoojava.api.Session; -import lombok.NoArgsConstructor; -@NoArgsConstructor public class SessionHolder { public Session odooSession; diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/security/BasicAuthenticationInterceptor.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/security/BasicAuthenticationInterceptor.java index 5c40027..66f0480 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/security/BasicAuthenticationInterceptor.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/security/BasicAuthenticationInterceptor.java @@ -63,6 +63,7 @@ public boolean authenticate(HttpServletRequest request, HttpServletResponse resp private boolean authenticateWithUsernameAndPassword(String username, String password) { Session odooSession = new Session( + fhirOdooConfig.getRPCProtocol(), fhirOdooConfig.getOdooHost(), Integer.parseInt(fhirOdooConfig.getOdooPort()), fhirOdooConfig.getOdooDatabase(), diff --git a/fhir-odoo/src/main/resources/fhir-odoo.properties b/fhir-odoo/src/main/resources/fhir-odoo.properties index 0438704..e9d02a1 100644 --- a/fhir-odoo/src/main/resources/fhir-odoo.properties +++ b/fhir-odoo/src/main/resources/fhir-odoo.properties @@ -16,4 +16,4 @@ fhir.odoo.port=${ODOO_PORT:8069} fhir.odoo.database=${ODOO_DATABASE:odoo} # The protocol to use to connect to the Odoo server -fhir.odoo.protocol=${ODOO_PROTOCOL:RPC_HTTPS} +fhir.odoo.protocol=${ODOO_PROTOCOL:RPC_HTTP}