Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UDR
Commits
11d0ae93
Commit
11d0ae93
authored
Jan 19, 2021
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SdmSubscriptions: add IndividualSdmSubscription and database
parent
85d44561
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
238 additions
and
25 deletions
+238
-25
api/SDMSubscriptionDocumentApi.h
api/SDMSubscriptionDocumentApi.h
+8
-8
impl/SDMSubscriptionDocumentApiImpl.cpp
impl/SDMSubscriptionDocumentApiImpl.cpp
+218
-8
impl/SDMSubscriptionDocumentApiImpl.h
impl/SDMSubscriptionDocumentApiImpl.h
+9
-6
impl/SMFRegistrationDocumentApiImpl.cpp
impl/SMFRegistrationDocumentApiImpl.cpp
+2
-2
main-api-server.cpp
main-api-server.cpp
+1
-1
No files found.
api/SDMSubscriptionDocumentApi.h
View file @
11d0ae93
...
...
@@ -100,7 +100,7 @@ private:
/// <param name="ueId"></param>
/// <param name="subsId"></param>
/// <param name="sdmSubscription"> (optional)</param>
virtual
void
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
const
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
)
=
0
;
virtual
void
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
)
=
0
;
};
...
...
impl/SDMSubscriptionDocumentApiImpl.cpp
View file @
11d0ae93
...
...
@@ -19,21 +19,231 @@ namespace api {
using
namespace
org
::
openapitools
::
server
::
model
;
SDMSubscriptionDocumentApiImpl
::
SDMSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
)
SDMSubscriptionDocumentApiImpl
::
SDMSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
MYSQL
*
mysql
)
:
SDMSubscriptionDocumentApi
(
rtr
)
{
}
{
mysql_WitcommUDRDB
=
mysql
;
}
void
SDMSubscriptionDocumentApiImpl
::
modifysdm_subscription
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
void
SDMSubscriptionDocumentApiImpl
::
querysdm_subscription
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
nlohmann
::
json
j
;
SdmSubscription
SdmSubscriptions
;
const
std
::
string
query
=
"SELECT * from SdmSubscriptions WHERE ueid="
+
ueId
+
" AND subsId="
+
subsId
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
std
::
cout
<<
"mysql_store_result failure!"
<<
std
::
endl
;
return
;
}
row
=
mysql_fetch_row
(
res
);
if
(
row
!=
NULL
)
{
for
(
int
i
=
0
;
field
=
mysql_fetch_field
(
res
);
i
++
)
{
if
(
!
strcmp
(
"nfInstanceId"
,
field
->
name
))
{
SdmSubscriptions
.
setNfInstanceId
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"implicitUnsubscribe"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
if
(
strcmp
(
row
[
i
],
"0"
))
SdmSubscriptions
.
setImplicitUnsubscribe
(
true
);
else
SdmSubscriptions
.
setImplicitUnsubscribe
(
false
);
}
else
if
(
!
strcmp
(
"expires"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
SdmSubscriptions
.
setExpires
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"callbackReference"
,
field
->
name
))
{
SdmSubscriptions
.
setCallbackReference
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"amfServiceName"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
// SdmSubscriptions.setAmfServiceName(row[i]);
}
else
if
(
!
strcmp
(
"monitoredResourceUris"
,
field
->
name
))
{
// SdmSubscriptions.setMonitoredResourceUris(row[i]);
}
else
if
(
!
strcmp
(
"singleNssai"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
// SdmSubscriptions.setSingleNssai(row[i]);
}
else
if
(
!
strcmp
(
"dnn"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
SdmSubscriptions
.
setDnn
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"subscriptionId"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
SdmSubscriptions
.
setSubscriptionId
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"plmnId"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
// SdmSubscriptions.setPlmnId(row[i]);
}
else
if
(
!
strcmp
(
"immediateReport"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
if
(
strcmp
(
row
[
i
],
"0"
))
SdmSubscriptions
.
setImmediateReport
(
true
);
else
SdmSubscriptions
.
setImmediateReport
(
false
);
}
else
if
(
!
strcmp
(
"report"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
// SdmSubscriptions.setReport(row[i]);
}
else
if
(
!
strcmp
(
"supportedFeatures"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
SdmSubscriptions
.
setSupportedFeatures
(
row
[
i
]);
}
else
if
(
!
strcmp
(
"contextInfo"
,
field
->
name
)
&&
row
[
i
]
!=
NULL
)
{
// SdmSubscriptions.setContextInfo(a);
}
}
to_json
(
j
,
SdmSubscriptions
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
j
.
dump
());
}
else
{
std
::
cout
<<
"SdmSubscription no data!"
<<
std
::
endl
;
}
mysql_free_result
(
res
);
}
void
SDMSubscriptionDocumentApiImpl
::
removesdm_subscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
MYSQL_RES
*
res
=
NULL
;
nlohmann
::
json
j
;
ProblemDetails
problemdetails
;
const
std
::
string
select_query
=
"SELECT * from SdmSubscriptions WHERE ueid="
+
ueId
+
" AND subsId="
+
subsId
;
const
std
::
string
query
=
"DELETE from SdmSubscriptions WHERE ueid="
+
ueId
+
" AND subsId="
+
subsId
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
select_query
.
c_str
(),
(
unsigned
long
)
select_query
.
size
()))
{
problemdetails
.
setCause
(
"USER_NOT_FOUND"
);
to_json
(
j
,
problemdetails
);
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j
.
dump
());
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
problemdetails
.
setCause
(
"USER_NOT_FOUND"
);
to_json
(
j
,
problemdetails
);
std
::
cout
<<
"mysql_store_result failure!"
<<
std
::
endl
;
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j
.
dump
());
return
;
}
if
(
!
mysql_num_rows
(
res
))
{
problemdetails
.
setCause
(
"DATA_NOT_FOUND"
);
to_json
(
j
,
problemdetails
);
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j
.
dump
());
return
;
}
mysql_free_result
(
res
);
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
problemdetails
.
setCause
(
"USER_NOT_FOUND"
);
to_json
(
j
,
problemdetails
);
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j
.
dump
());
return
;
}
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
}
void
SDMSubscriptionDocumentApiImpl
::
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
const
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
void
SDMSubscriptionDocumentApiImpl
::
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
const
std
::
string
select_query
=
"SELECT * from SdmSubscriptions WHERE ueid="
+
ueId
+
" AND subsId="
+
subsId
;
std
::
string
query
;
nlohmann
::
json
j
;
ProblemDetails
problemdetails
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
select_query
.
c_str
(),
(
unsigned
long
)
select_query
.
size
()))
{
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
std
::
cout
<<
"mysql_store_result failure!"
<<
std
::
endl
;
return
;
}
if
(
mysql_num_rows
(
res
))
{
nlohmann
::
json
MonitoredResourceUris_json
(
sdmSubscription
.
getMonitoredResourceUris
());
query
=
"update SdmSubscriptions set nfInstanceId='"
+
sdmSubscription
.
getNfInstanceId
()
+
"',"
+
\
(
sdmSubscription
.
implicitUnsubscribeIsSet
()
?
(
sdmSubscription
.
isImplicitUnsubscribe
()
?
"implicitUnsubscribe=1,"
:
"implicitUnsubscribe=0,"
)
:
""
)
+
\
(
sdmSubscription
.
expiresIsSet
()
?
"expires='"
+
sdmSubscription
.
getExpires
()
+
"',"
:
""
)
+
\
"callbackReference='"
+
sdmSubscription
.
getCallbackReference
()
+
"',"
+
\
// amfServiceName
// singleNssai
(
sdmSubscription
.
dnnIsSet
()
?
"dnn='"
+
sdmSubscription
.
getDnn
()
+
"',"
:
""
)
+
\
(
sdmSubscription
.
subscriptionIdIsSet
()
?
"subscriptionId='"
+
sdmSubscription
.
getSubscriptionId
()
+
"',"
:
""
)
+
\
// plmnId
(
sdmSubscription
.
immediateReportIsSet
()
?
(
sdmSubscription
.
isImmediateReport
()
?
"immediateReport=1,"
:
"immediateReport=0,"
)
:
""
)
+
\
// report
(
sdmSubscription
.
supportedFeaturesIsSet
()
?
"supportedFeatures='"
+
sdmSubscription
.
getSupportedFeatures
()
+
"',"
:
""
)
+
\
//contextInfo
//query += "monitoredResourceUris='[";
// std::vector<std::string> monitoredresourceuris_list = sdmSubscription.getMonitoredResourceUris();
// for(int i=0;i<monitoredresourceuris_list.size();i++)
// {
// if(i==monitoredresourceuris_list.size()-1)
// query += "\"" +monitoredresourceuris_list[i]+"\"";
// else
// query += "\"" +monitoredresourceuris_list[i]+"\",";
// }
//query += "]',";
//j[0]=sdmSubscription.getMonitoredResourceUris();
query
+=
"monitoredResourceUris='"
+
MonitoredResourceUris_json
.
dump
()
+
"'"
;
query
+=
" where ueid="
+
ueId
+
" AND subsId="
+
subsId
;
}
else
{
to_json
(
j
,
problemdetails
);
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
j
.
dump
());
mysql_free_result
(
res
);
return
;
}
mysql_free_result
(
res
);
// std::cout << query << std::endl;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
std
::
cout
<<
"mysql_real_query failure!"
<<
std
::
endl
;
return
;
}
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
,
""
);
}
}
...
...
impl/SDMSubscriptionDocumentApiImpl.h
View file @
11d0ae93
...
...
@@ -37,6 +37,8 @@
#include <string>
#include <vector>
#include <mysql/mysql.h>
namespace
org
{
namespace
openapitools
{
namespace
server
{
...
...
@@ -46,14 +48,15 @@ using namespace org::openapitools::server::model;
class
SDMSubscriptionDocumentApiImpl
:
public
org
::
openapitools
::
server
::
api
::
SDMSubscriptionDocumentApi
{
public:
SDMSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
SDMSubscriptionDocumentApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
~
SDMSubscriptionDocumentApiImpl
()
{}
void
modifysdm_subscription
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
const
Pistache
::
Optional
<
std
::
string
>
&
supportedFeatures
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
querysdm_subscription
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
removesdm_subscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
const
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
);
void
updatesdmsubscriptions
(
const
std
::
string
&
ueId
,
const
std
::
string
&
subsId
,
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
);
private:
MYSQL
*
mysql_WitcommUDRDB
;
};
}
...
...
impl/SMFRegistrationDocumentApiImpl.cpp
View file @
11d0ae93
...
...
@@ -47,7 +47,7 @@ void SMFRegistrationDocumentApiImpl::create_smf_context_non3gpp(const std::strin
if
(
mysql_num_rows
(
res
))
{
query
=
"update SmfRegistrations set smfInstanceId='"
+
smfRegistration
.
getSmfInstanceId
()
+
"',"
+
\
(
smfRegistration
.
smfSetIdIsSet
()
?
"smfSetId='"
+
smfRegistration
.
getS
upportedFeatures
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
smfSetIdIsSet
()
?
"smfSetId='"
+
smfRegistration
.
getS
mfSetId
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
supportedFeaturesIsSet
()
?
"supportedFeatures='"
+
smfRegistration
.
getSupportedFeatures
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
dnnIsSet
()
?
"dnn='"
+
smfRegistration
.
getDnn
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
emergencyServicesIsSet
()
?
(
smfRegistration
.
isEmergencyServices
()
?
"emergencyServices=1,"
:
"emergencyServices=0,"
)
:
""
)
+
\
...
...
@@ -69,7 +69,7 @@ void SMFRegistrationDocumentApiImpl::create_smf_context_non3gpp(const std::strin
query
=
"insert into SmfRegistrations set ueid="
+
ueId
+
","
+
\
"pduSessionId="
+
std
::
to_string
(
pduSessionId
)
+
","
+
\
"smfInstanceId='"
+
smfRegistration
.
getSmfInstanceId
()
+
"',"
+
\
(
smfRegistration
.
smfSetIdIsSet
()
?
"smfSetId='"
+
smfRegistration
.
getS
upportedFeatures
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
smfSetIdIsSet
()
?
"smfSetId='"
+
smfRegistration
.
getS
mfSetId
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
supportedFeaturesIsSet
()
?
"supportedFeatures='"
+
smfRegistration
.
getSupportedFeatures
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
dnnIsSet
()
?
"dnn='"
+
smfRegistration
.
getDnn
()
+
"',"
:
""
)
+
\
(
smfRegistration
.
emergencyServicesIsSet
()
?
(
smfRegistration
.
isEmergencyServices
()
?
"emergencyServices=1,"
:
"emergencyServices=0,"
)
:
""
)
+
\
...
...
main-api-server.cpp
View file @
11d0ae93
...
...
@@ -303,7 +303,7 @@ int main() {
QueryODBDataBySUPIOrGPSIDocumentApiserver
.
init
();
RetrievalOfSharedDataApiImpl
RetrievalOfSharedDataApiserver
(
router
);
RetrievalOfSharedDataApiserver
.
init
();
SDMSubscriptionDocumentApiImpl
SDMSubscriptionDocumentApiserver
(
router
);
SDMSubscriptionDocumentApiImpl
SDMSubscriptionDocumentApiserver
(
router
,
&
mysql
);
SDMSubscriptionDocumentApiserver
.
init
();
SDMSubscriptionsCollectionApiImpl
SDMSubscriptionsCollectionApiserver
(
router
);
SDMSubscriptionsCollectionApiserver
.
init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment