diff --git a/odoo16-client/pom.xml b/odoo16-client/pom.xml new file mode 100644 index 00000000..1bb1ef3d --- /dev/null +++ b/odoo16-client/pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + openerp-service + org.bahmni.openerp + 0.94-SNAPSHOT + + org.bahmni.openerp + odoo16-client + jar + 0.94-SNAPSHOT + odoo16-client + http://maven.apache.org + + ${project.version} + + + + org.springframework + spring-webmvc + + + org.springframework + spring-web + provided + + + org.apache.velocity + velocity + 1.7 + provided + + + org.apache.velocity + velocity-tools + 2.0 + provided + + + org.apache.httpcomponents + httpclient + ${httpClient.version} + provided + + + + org.aspectj + aspectjrt + 1.6.12 + + + org.apache.xmlrpc + xmlrpc-client + 3.1.3 + + + xml-apis + xml-apis + + + + + commons-beanutils + commons-beanutils + 1.8.3 + + + commons-logging + commons-logging + + + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + com.fasterxml.jackson.core + jackson-databind + provided + + + org.apache.commons + commons-lang3 + 3.0 + + + + odoo16-client + + + + diff --git a/odoo16-client/src/main/java/org/bahmni/odoo/web/DemoApplication.java b/odoo16-client/src/main/java/org/bahmni/odoo/web/DemoApplication.java new file mode 100644 index 00000000..daaeffe6 --- /dev/null +++ b/odoo16-client/src/main/java/org/bahmni/odoo/web/DemoApplication.java @@ -0,0 +1,16 @@ +package org.bahmni.odoo.web; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.bahmni.odoo.web.controller.OpenERPLogin; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + // This is the main entry point for the Spring Boot application. + OpenERPLogin openERPLogin = new OpenERPLogin(); + openERPLogin.login("admin", "admin"); + SpringApplication.run(DemoApplication.class, args); + } +} \ No newline at end of file diff --git a/odoo16-client/src/main/java/org/bahmni/odoo/web/client/OpenERPLoginRequest.java b/odoo16-client/src/main/java/org/bahmni/odoo/web/client/OpenERPLoginRequest.java new file mode 100644 index 00000000..5a4021c2 --- /dev/null +++ b/odoo16-client/src/main/java/org/bahmni/odoo/web/client/OpenERPLoginRequest.java @@ -0,0 +1,21 @@ +package org.bahmni.odoo.web.client; +public class OpenERPLoginRequest { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/odoo16-client/src/main/java/org/bahmni/odoo/web/controller/OpenERPLogin.java b/odoo16-client/src/main/java/org/bahmni/odoo/web/controller/OpenERPLogin.java new file mode 100644 index 00000000..942147c9 --- /dev/null +++ b/odoo16-client/src/main/java/org/bahmni/odoo/web/controller/OpenERPLogin.java @@ -0,0 +1,22 @@ +package org.bahmni.odoo.web.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; + import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +public class OpenERPLogin { + + @Value("${external.api.url}") + private String externalApiUrl; + + public ResponseEntity login(String username, String password) { + RestTemplate restTemplate = new RestTemplate(); + String requestBody = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}"; + HttpEntity requestEntity = new HttpEntity<>(requestBody); + String requestUrl = externalApiUrl + "/api/login"; // Adjust the URL + ResponseEntity response = restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, String.class); + + return response; + } +} \ No newline at end of file diff --git a/odoo16-client/src/main/resources/application.properties b/odoo16-client/src/main/resources/application.properties new file mode 100644 index 00000000..e9cce1b8 --- /dev/null +++ b/odoo16-client/src/main/resources/application.properties @@ -0,0 +1,3 @@ +external.api.url=http://localhost:8069 +server: + port: 8080 \ No newline at end of file diff --git a/odoo16-client/src/main/resources/applicationContext-openerp-client.xml b/odoo16-client/src/main/resources/applicationContext-openerp-client.xml new file mode 100644 index 00000000..0b0cb625 --- /dev/null +++ b/odoo16-client/src/main/resources/applicationContext-openerp-client.xml @@ -0,0 +1,31 @@ + + + + + + + + + + UTF-8 + UTF-8 + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index a7261c33..13ce2076 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ openerp-atomfeed-service openerp-client + odoo16-client pom