forked from MathewFrancis/cezenGIT
Add a global asterisk feature
This commit is contained in:
parent
bab00e7f2b
commit
2784559113
@ -147,6 +147,35 @@
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Add_a_global_extension_feature",
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"context\": \"default\",\n \"extension\": \"w\",\n \"priority\": 5,\n \"app\": \"Dial\",\n \"appdata\": \"W conf\"\n}\n",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:8081/cezen/add_feature",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "8081",
|
||||
"path": [
|
||||
"cezen",
|
||||
"add_feature"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -112,4 +112,23 @@ public class BasicAsteriskOpsDAO implements CezenPbxOpsDAO {
|
||||
|
||||
return query.executeUpdate() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ReturnStatus saveAnExtensionByCharacters(ExtensionsTable extensionsTable) {
|
||||
|
||||
try{
|
||||
|
||||
this.entityManager.persist(extensionsTable);
|
||||
|
||||
return new ReturnStatus(true,
|
||||
extensionsTable.getExtension() +" configured as "+ extensionsTable.getContext() +" added",
|
||||
"");
|
||||
|
||||
}catch (Exception e){
|
||||
return new ReturnStatus(false,
|
||||
extensionsTable.getExtension() +" configured as "+ extensionsTable.getContext() +" Already exists",
|
||||
e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,4 +19,6 @@ public interface CezenPbxOpsDAO {
|
||||
int getTheHighestPriorityNumberByEndpoint(String endpoint);
|
||||
|
||||
boolean deleteAnExtensionPoint(String endpoint);
|
||||
|
||||
ReturnStatus saveAnExtensionByCharacters(ExtensionsTable extensionsTable);
|
||||
}
|
||||
|
||||
@ -80,4 +80,17 @@ public class CezenPbxController {
|
||||
|
||||
return this.basicPbxServiceInterface.deleteByExtension(sipNumber);
|
||||
}
|
||||
|
||||
// add global extension features like voicemail
|
||||
@PutMapping("/add_feature")
|
||||
public ReturnStatus addAGlobalFeatureToExtension(@RequestBody ExtensionsDTO extensionsDTO){
|
||||
|
||||
return this.basicPbxServiceInterface.addFeaturesToExtensionsForEndpoints(
|
||||
extensionsDTO.context(),
|
||||
extensionsDTO.extension(),
|
||||
extensionsDTO.priority(),
|
||||
extensionsDTO.app(),
|
||||
extensionsDTO.appdata());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -100,4 +100,35 @@ public class BasicPbxService implements BasicPbxServiceInterface {
|
||||
|
||||
return this.cezenPbxOpsDAO.deleteAnExtensionPoint(extensionNumber);
|
||||
}
|
||||
|
||||
// TODO make sure you check if the extension field is a literal character
|
||||
@Override
|
||||
public ReturnStatus addFeaturesToExtensionsForEndpoints(String context, String extension, int priority, String app, String appdata) {
|
||||
// check if extension is a character
|
||||
String extensionWordLiteral = "";
|
||||
|
||||
if(extension.chars().allMatch(Character::isLetter)){
|
||||
|
||||
extensionWordLiteral = extension;
|
||||
}else{
|
||||
|
||||
return new ReturnStatus(false, "Only Character type extension point allowed", "User entered a numerical character sequence expected an alphabetical one instead");
|
||||
}
|
||||
|
||||
|
||||
//if received input is empty
|
||||
if(extensionWordLiteral.isEmpty()) return new ReturnStatus(false, "Extension field is empty", "User entered an empty extension");
|
||||
|
||||
// if yes then add the feature to the database
|
||||
//return the status of the feature addition
|
||||
return this.cezenPbxOpsDAO.saveAnExtensionByCharacters(
|
||||
new ExtensionsTable(
|
||||
context,
|
||||
extension,
|
||||
priority,
|
||||
app,
|
||||
appdata
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,4 +18,7 @@ public interface BasicPbxServiceInterface {
|
||||
public ReturnStatus setAors(String id, int maxContacts);
|
||||
|
||||
public boolean deleteByExtension(String extensionNumber);
|
||||
|
||||
// this method will allow the creation of global features azs long as 'extension' field is a literal character
|
||||
public ReturnStatus addFeaturesToExtensionsForEndpoints(String context, String extension, int priority, String app, String appdata);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user