Skip to content

Commit

Permalink
OZ-708: Set Odoo RPC protocol via properties file
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Sep 26, 2024
1 parent cd276f7 commit 2e32beb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
11 changes: 11 additions & 0 deletions fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
package com.ozonehis.fhir.odoo;

import com.odoojava.api.Session;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public class SessionHolder {

public Session odooSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion fhir-odoo/src/main/resources/fhir-odoo.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 2e32beb

Please sign in to comment.