diff --git a/MySQL_conf_pbx/test1/Rest-API-Postman/CezenPBX_API.postman_collection.json b/MySQL_conf_pbx/test1/Rest-API-Postman/CezenPBX_API.postman_collection.json new file mode 100644 index 0000000..9745f8c --- /dev/null +++ b/MySQL_conf_pbx/test1/Rest-API-Postman/CezenPBX_API.postman_collection.json @@ -0,0 +1,39 @@ +{ + "info": { + "_postman_id": "721d5504-301f-488d-a25b-5e78769eac5a", + "name": "CezenPBX_API", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "29498098" + }, + "item": [ + { + "name": "create a new endpoint", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"1001\",\n \"transport\": \"transport-udp\",\n \"aors\": \"1001\",\n \"auth\": \"1001\",\n \"context\": \"from-internal\",\n \"disallow\": \"all\",\n \"allow\": \"ulaw\",\n \"directMedia\": \"no\",\n \"connectedLineMethod\": \"invite\",\n \"callerid\": \"User <1001>\",\n \"dtmfMode\": \"rfc4733\",\n \"mohsuggest\": \"default\",\n \"mailboxes\": \"1001@default\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8081/cezen/add_user", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8081", + "path": [ + "cezen", + "add_user" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/MySQL_conf_pbx/test1/docker-compose.yml b/MySQL_conf_pbx/test1/docker-compose.yml index a4a15d2..7f046d7 100755 --- a/MySQL_conf_pbx/test1/docker-compose.yml +++ b/MySQL_conf_pbx/test1/docker-compose.yml @@ -43,10 +43,10 @@ services: volumes: - ./springCezenPBX:/app # Mount your Spring Boot project - maven_repo:/root/.m2 # Store Maven dependencies - # environment: - # SPRING_DATASOURCE_URL: jdbc:mariadb://host.docker.internal:3308/asterisk_db # Use host.docker.internal - # SPRING_DATASOURCE_USERNAME: asterisk_user # ${DB_USER} - # SPRING_DATASOURCE_PASSWORD: 12345 # ${DB_PASS} + environment: + SPRING_DATASOURCE_URL: jdbc:mariadb://localhost:3308/asterisk_db # Use host.docker.internal + SPRING_DATASOURCE_USERNAME: ${DB_USER} + SPRING_DATASOURCE_PASSWORD: ${DB_PASS} network_mode: "host" # Run in host mode volumes: diff --git a/MySQL_conf_pbx/test1/mariadb_data/aria_log.00000001 b/MySQL_conf_pbx/test1/mariadb_data/aria_log.00000001 index 6862381..e2ba8bf 100644 Binary files a/MySQL_conf_pbx/test1/mariadb_data/aria_log.00000001 and b/MySQL_conf_pbx/test1/mariadb_data/aria_log.00000001 differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/aria_log_control b/MySQL_conf_pbx/test1/mariadb_data/aria_log_control index 99049a8..9fd86f2 100644 Binary files a/MySQL_conf_pbx/test1/mariadb_data/aria_log_control and b/MySQL_conf_pbx/test1/mariadb_data/aria_log_control differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log b/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log new file mode 100644 index 0000000..fc3fd79 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/ibtmp1 b/MySQL_conf_pbx/test1/mariadb_data/ibtmp1 new file mode 100644 index 0000000..202d95c Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/ibtmp1 differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/tc.log b/MySQL_conf_pbx/test1/mariadb_data/tc.log new file mode 100644 index 0000000..0ca0162 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/tc.log differ diff --git a/MySQL_conf_pbx/test1/recordings/1001-1743658252.4.wav b/MySQL_conf_pbx/test1/recordings/1001-1743658252.4.wav new file mode 100644 index 0000000..64ec696 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1001-1743658252.4.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1001-1743658275.9.wav b/MySQL_conf_pbx/test1/recordings/1001-1743658275.9.wav new file mode 100644 index 0000000..64ec696 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1001-1743658275.9.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1001-1743658299.14.wav b/MySQL_conf_pbx/test1/recordings/1001-1743658299.14.wav new file mode 100644 index 0000000..b93129a Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1001-1743658299.14.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1002-1743658114.0.wav b/MySQL_conf_pbx/test1/recordings/1002-1743658114.0.wav new file mode 100644 index 0000000..64ec696 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1002-1743658114.0.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1002-1743658252.4.wav b/MySQL_conf_pbx/test1/recordings/1002-1743658252.4.wav new file mode 100644 index 0000000..64ec696 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1002-1743658252.4.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1002-1743658275.9.wav b/MySQL_conf_pbx/test1/recordings/1002-1743658275.9.wav new file mode 100644 index 0000000..64ec696 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1002-1743658275.9.wav differ diff --git a/MySQL_conf_pbx/test1/recordings/1002-1743658299.14.wav b/MySQL_conf_pbx/test1/recordings/1002-1743658299.14.wav new file mode 100644 index 0000000..4b85cd8 Binary files /dev/null and b/MySQL_conf_pbx/test1/recordings/1002-1743658299.14.wav differ diff --git a/MySQL_conf_pbx/test1/springCezenPBX/pom.xml b/MySQL_conf_pbx/test1/springCezenPBX/pom.xml index c29e3a8..0df826d 100644 --- a/MySQL_conf_pbx/test1/springCezenPBX/pom.xml +++ b/MySQL_conf_pbx/test1/springCezenPBX/pom.xml @@ -30,10 +30,10 @@ 21 - - - - + + org.springframework.boot + spring-boot-starter-data-jpa + org.springframework.boot spring-boot-starter-web @@ -45,17 +45,11 @@ runtime true - - - - - - - - - - - + + org.mariadb.jdbc + mariadb-java-client + runtime + org.springframework.boot spring-boot-starter-test diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/CezenPbxApplication.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/CezenPbxApplication.java index 82e1bed..e97fd21 100644 --- a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/CezenPbxApplication.java +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/CezenPbxApplication.java @@ -11,3 +11,4 @@ public class CezenPbxApplication { } } + diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/BasicAsteriskOpsDAO.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/BasicAsteriskOpsDAO.java new file mode 100644 index 0000000..f1ee799 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/BasicAsteriskOpsDAO.java @@ -0,0 +1,28 @@ +package com.example.cezenPBX.DAO; + +import com.example.cezenPBX.entity.PsEndPoints; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class BasicAsteriskOpsDAO implements CezenPbxOpsDAO { + + + @Autowired + private EntityManager entityManager; + + // takes the required data from the service class and persists the entity to the database + // returns true if operation was carried out without an exception + @Override + public boolean addNewEndPoint(PsEndPoints psEndPoints) { + + try{ + this.entityManager.persist(psEndPoints); + }catch (Exception e){ + return false; + } + return true; + } +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/CezenPbxOpsDAO.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/CezenPbxOpsDAO.java new file mode 100644 index 0000000..199e3e8 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DAO/CezenPbxOpsDAO.java @@ -0,0 +1,8 @@ +package com.example.cezenPBX.DAO; + +import com.example.cezenPBX.entity.PsEndPoints; + +public interface CezenPbxOpsDAO { + + boolean addNewEndPoint(PsEndPoints psEndPoints); +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DTO/PsEndPointsDTO.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DTO/PsEndPointsDTO.java new file mode 100644 index 0000000..378d7d3 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/DTO/PsEndPointsDTO.java @@ -0,0 +1,7 @@ +package com.example.cezenPBX.DTO; + +public record PsEndPointsDTO + (String id, String transport, String aors, String auth, String context, + String disallow, String allow, String directMedia, String connectedLineMethod, + String callerid, String dtmfMode, String mohsuggest, String mailboxes) { +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/controller/CezenPbxController.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/controller/CezenPbxController.java new file mode 100644 index 0000000..a4f336f --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/controller/CezenPbxController.java @@ -0,0 +1,27 @@ +package com.example.cezenPBX.controller; + +import com.example.cezenPBX.DTO.PsEndPointsDTO; +import com.example.cezenPBX.service.BasicPbxServiceInterface; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/cezen") +public class CezenPbxController { + + @Autowired + private BasicPbxServiceInterface basicPbxServiceInterface; + + + @PostMapping("/add_user") + // this method will accept json input fields, process them using jackson then pass them to the service + public boolean createNewEndPointController(@RequestBody PsEndPointsDTO psEndPointsRecordDTO){ + + System.out.println(psEndPointsRecordDTO); + + return false; + } +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/PsEndPoints.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/PsEndPoints.java new file mode 100644 index 0000000..a9a38b3 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/PsEndPoints.java @@ -0,0 +1,170 @@ +package com.example.cezenPBX.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Table(name = "ps_endpoints") +public class PsEndPoints { + + @Id + @Column(name = "id") + String id; + + @Column(name = "transport") + String transport; + + @Column(name = "aors") + String aors; + + @Column(name = "auth") + String auth; + + @Column(name = "context") + String context; + + @Column(name = "disallow") + String disallow; + + @Column(name = "allow") + String allow; + + @Column(name = "direct_media") + String directMedia; + + @Column(name = "connected_line_method") + String connectedLineMethod; + + @Column(name = "callerid") + String callerid; + + @Column(name = "dtmf_mode") + String dtmfMode; + + @Column(name = "mohsuggest") + String mohsuggest; + + @Column(name = "mailboxes") + String mailboxes; + + public PsEndPoints(String id, String transport, String aors, String auth, String context, + String disallow, String allow, String directMedia, String connectedLineMethod, + String callerid, String dtmfMode, String mohsuggest, String mailboxes) { + this.id = id; + this.transport = transport; + this.aors = aors; + this.auth = auth; + this.context = context; + this.disallow = disallow; + this.allow = allow; + this.directMedia = directMedia; + this.connectedLineMethod = connectedLineMethod; + this.callerid = callerid; + this.dtmfMode = dtmfMode; + this.mohsuggest = mohsuggest; + this.mailboxes = mailboxes; + } + + public PsEndPoints() { + } + + public String getId() { + return id; + } + + public String getTransport() { + return transport; + } + + public void setTransport(String transport) { + this.transport = transport; + } + + public String getAors() { + return aors; + } + + public void setAors(String aors) { + this.aors = aors; + } + + public String getAuth() { + return auth; + } + + public void setAuth(String auth) { + this.auth = auth; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getDisallow() { + return disallow; + } + + public void setDisallow(String disallow) { + this.disallow = disallow; + } + + public String getAllow() { + return allow; + } + + public void setAllow(String allow) { + this.allow = allow; + } + + public String getDirectMedia() { + return directMedia; + } + + public void setDirectMedia(String directMedia) { + this.directMedia = directMedia; + } + + public String getConnectedLineMethod() { + return connectedLineMethod; + } + + public void setConnectedLineMethod(String connectedLineMethod) { + this.connectedLineMethod = connectedLineMethod; + } + + public String getCallerid() { + return callerid; + } + + public void setCallerid(String callerid) { + this.callerid = callerid; + } + + public String getDtmfMode() { + return dtmfMode; + } + + public void setDtmfMode(String dtmfMode) { + this.dtmfMode = dtmfMode; + } + + public String getMohsuggest() { + return mohsuggest; + } + + public void setMohsuggest(String mohsuggest) { + this.mohsuggest = mohsuggest; + } + + public String getMailboxes() { + return mailboxes; + } + + public void setMailboxes(String mailboxes) { + this.mailboxes = mailboxes; + } +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxService.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxService.java new file mode 100644 index 0000000..eb7ec4d --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxService.java @@ -0,0 +1,40 @@ +package com.example.cezenPBX.service; + +import com.example.cezenPBX.DAO.CezenPbxOpsDAO; +import com.example.cezenPBX.entity.PsEndPoints; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class BasicPbxService implements BasicPbxServiceInterface { + + @Autowired + private CezenPbxOpsDAO cezenPbxOpsDAO; + + // the service method will create an instance of PsEndPoints entity for persistence + @Override + public boolean createANewEndpointService(String id, String transport, String aors, String auth, + String context, String disallow, String allow, String directMedia, + String connectedLineMethod, String callerid, String dtmfMode, + String mohsuggest, String mailboxes) { + + // create the persistence object + PsEndPoints psEndPoints = new PsEndPoints( + id, + transport, + aors, + auth, + context, + disallow, + allow, + directMedia, + connectedLineMethod, + callerid, + dtmfMode, + mohsuggest, + mailboxes + ); + + return cezenPbxOpsDAO.addNewEndPoint(psEndPoints); + } +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxServiceInterface.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxServiceInterface.java new file mode 100644 index 0000000..d1bb064 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/service/BasicPbxServiceInterface.java @@ -0,0 +1,9 @@ +package com.example.cezenPBX.service; + +public interface BasicPbxServiceInterface { + + public boolean createANewEndpointService(String id, String transport, String aors, String auth, + String context, String disallow, String allow, String directMedia, + String connectedLineMethod, String callerid, String dtmfMode, + String mohsuggest, String mailboxes); +}