Reference13r1:Concept App Contacts

From innovaphone-wiki

Jump to: navigation, search

Contents


The App Service Contacts is an App Service which can be installed on an innovaphone App Platform. It is used for information retrieval of a database of contact entries.

Features

Database for contact entries. A user interface for retrieval purposes is available.

  • Import of comma-separated files
  • API for other apps

Requirements

  • innovaphone PBX and App Platform from on version 13r1

Details

Assign unique IDs for contacts entries

It is recommended to upload CSV files with an additional column extAnchor. The column extAnchor allows to identify individual entries uniquely and independent of renaming operations. The column extAnchor is supposed to contain an external unique database id, alike a guid. If extAnchor was provided the import procedure will perform an UPDATE of previously existing entries, instead of deleting and re-INSERTing the entries. Entries pinned on home are going to remain functional.

Upload Data by HTTP Post

A CSV file can be uploaded by means of an HTTP POST request. The following powershell script aims to demonstrate this procedure with the help of CURL[1][2] The required user and password content corresponds to the configuration underneath PBX Manager/AP Contacts/Configuration/User(HTTP Post) and Password(HTTP Post)

# csv.ps1
# Sample powershell script demonstrating how to HTTP POST a CSV file towards the Contacts App service.
# .\bin\curl must be present, e.g. from https://curl.haxx.se/download.html
# Examples:
# powershell -ExecutionPolicy Bypass -Command .\csv.ps1 -Dest 172.16.18.215 -File ".\myContacts.utf8" -User "contacts01" -Pw "pwd01" -Url "/example.com/contacts01/post/myContacts.utf8?op=csv"
 
param(
[Parameter(Mandatory=$false, HelpMessage="Destination host")]
[string]$Dest,
[Parameter(Mandatory=$false, HelpMessage="Name of file to be POSTed")]
[string]$File,
[Parameter(Mandatory=$false, HelpMessage="Authentication: User")]
[string]$User,
[Parameter(Mandatory=$false, HelpMessage="Authentication: Password")]
[string]$Pw,
[Parameter(Mandatory=$false, HelpMessage="URL, e.g.: /example.com/contacts01/post/myContacts.csv?op=csv&xml-stats=true")]
[string]$Url
)
 
Add-Type -AssemblyName System.Web
 
$Uri = "http://" + $Dest + $Url
 
function UploadToContacts {
# Ensure file's there and has content
if (!(Test-Path -Path $File)) {
echo $File+" not downloaded!"
exit 1
}
$lines = 0
Get-Content $File |%{ $lines++ }
echo "Lines of $File=$lines"
if($lines -le 2) {
echo "No Data to upload!"
exit 1
}
 
$auth = "${User}:${Pw}"
 
echo "POSTing towards $Uri"
.\bin\curl "--digest" -s -S --trace-time -u $auth -i -H "Content-Type:application/octet-stream" -X POST --data-binary "@${File}" "${Uri}"
echo "POSTed towards $Dest"
}
 
$timeStart = Get-Date
echo "===Begin: ${timeStart} ==="
UploadToContacts
$timeEnd = Get-Date
echo "===End: ${timeEnd} ==="
echo ""

App Services

  • innovaphone-contacts
    • The reqular app
  • innovaphone-contacts-admin
    • Features a menu (top-right) to manually upload a CSV file
  • innovaphone-contacts-searchapi
    • Provides a search API to other apps, e.g. for the Phone App

Troubleshooting

Manually Deleting an uploaded File

If multiple files or multiple versions of a CSV file were uploaded, it might not be clear how to delete an old data set. Here is an example for how to accomplish a deletion of a particular data set related to an imported CSV file:

  • 2 Files were previously imported
    • allcontacts.csv
    • brs%20testimport.csv
  • The file brs%20testimport.csv shall be deleted
  • Hints
    • Within the Contacts database, the table dbs contains the names of files once imported.
    • The database name, here: innovaphone.com_contacts can be retrieved from the settings within in the App Manager for the Contacts App.

Establish an SSH-session by means of e.g. putty[3]

#Login
#===================================================================
login as: admin
Using keyboard-interactive authentication.
Password:
 
#Elevate to super-user rights, Command 'su'
#===================================================================
admin@app-platform|/mnt/sda2/home/admin> su
Password:
 
#Command 'psql'. Printing the table 'dbs'. Contains 2 file names.
#===================================================================
root@app-platform|/mnt/sda2/home/admin> psql -d "innovaphone.com_contacts" -c "select * from dbs"
id | uri
----+----------------------
1 | allcontacts.csv
5 | brs%20testimport.csv
(2 rows)
 
#Delete the file "brs%20testimport.csv" via its table-ID 5.
#===================================================================
root@app-platform|/mnt/sda2/home/admin> psql -d "innovaphone.com_contacts" -c "delete from dbs where id=5"
DELETE 1
 
 
#Printing the table 'dbs'. Contains 1 file name.
#===================================================================
root@app-platform|/mnt/sda2/home/admin> psql -d "innovaphone.com_contacts" -c "select * from dbs"
id | uri
----+-----------------
1 | allcontacts.csv
(1 row)
 
root@app-platform|/mnt/sda2/home/admin>


Known Issues

Related Articles

  1. For a windows distribution: e.g.: https://curl.haxx.se/download.html
  2. CURL is recommended(rather required), because it supports the simple POST mechanism with an initial tentative POST with the data length of 0, in order to get through the authentication phase
  3. putty: https://putty.org
Personal tools