Commit db6793c8 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding response status code as parameter in resource handler functions


Signed-off-by: Miguel Angel Reina Ortega's avatarreinaortega <miguelangel.reinaortega@etsi.org>
parent 28315f5a
......@@ -2363,7 +2363,7 @@ module OneM2M_Functions {
* @param p_resourceIndex Internal resource index which indicates the resource to be updated
* @verdict
*/
function f_cse_createResourceHandler(template RequestPrimitive p_request := mw_create) runs on CseSimu return integer{
function f_cse_createResourceHandler(template RequestPrimitive p_request := mw_create, in ResponseStatusCode p_responseStatusCode := int2001) runs on CseSimu return integer{
var integer v_localResourceIndex;
......@@ -2374,7 +2374,7 @@ module OneM2M_Functions {
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_localResourceIndex := f_processCreateRequestPrimitive(vc_request.primitive.requestPrimitive);
v_localResourceIndex := f_processCreateRequestPrimitive(vc_request.primitive.requestPrimitive, p_responseStatusCode);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
......@@ -2478,7 +2478,7 @@ module OneM2M_Functions {
* @param p_requestPrimitive UPDATE request primitive to be used
* @verdict
*/
function f_cse_updateResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_update) runs on CseSimu {
function f_cse_updateResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_update, in ResponseStatusCode p_responseStatusCode := int2004) runs on CseSimu {
var integer v_targetResourceIndex := -1;
......@@ -2490,7 +2490,7 @@ module OneM2M_Functions {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processUpdateRequestPrimitive(vc_request.primitive.requestPrimitive);
v_targetResourceIndex := f_processUpdateRequestPrimitive(vc_request.primitive.requestPrimitive, p_responseStatusCode);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource updated successfuly");
} else {
......@@ -2514,7 +2514,7 @@ module OneM2M_Functions {
* @param p_requestPrimitive RETRIEVE request primitive to be used
* @verdict
*/
function f_cse_retrieveResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_retrieve(?)) runs on CseSimu {
function f_cse_retrieveResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_retrieve(?), in ResponseStatusCode p_responseStatusCode := int2000) runs on CseSimu {
var integer v_targetResourceIndex := -1;
......@@ -2525,7 +2525,7 @@ module OneM2M_Functions {
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processRetrieveRequestPrimitive(vc_request.primitive.requestPrimitive);
v_targetResourceIndex := f_processRetrieveRequestPrimitive(vc_request.primitive.requestPrimitive, p_responseStatusCode);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
} else {
......@@ -2588,6 +2588,8 @@ module OneM2M_Functions {
f_checkCseSimuStatus();
}// end f_cse_memberTypeValidationHandler
/**
* @desc Message exchange for the retrieval of a child resource refs
* @param p_resourceType ResourceType of children of the resource to be retrieved
* @param p_resourceIndex Resource index of the resource to be retrieved
......@@ -2626,7 +2628,7 @@ module OneM2M_Functions {
* @param p_requestPrimitive DELETE request primitive to be used
* @verdict
*/
function f_cse_deleteResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_delete) runs on CseSimu {
function f_cse_deleteResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_delete, in ResponseStatusCode p_responseStatusCode := int2002) runs on CseSimu {
var integer v_targetResourceIndex := -1;
......@@ -2637,7 +2639,7 @@ module OneM2M_Functions {
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processDeleteRequestPrimitive(vc_request.primitive.requestPrimitive);
v_targetResourceIndex := f_processDeleteRequestPrimitive(vc_request.primitive.requestPrimitive, p_responseStatusCode);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource deleted successfuly");
} else {
......@@ -5541,7 +5543,7 @@ module OneM2M_Functions {
* @param p_request Request primitive to be processed
* @return Local resource index
*/
function f_processCreateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
function f_processCreateRequestPrimitive(in RequestPrimitive p_request, in ResponseStatusCode p_responseStatusCode := int2001) runs on CseSimu return integer {
var integer v_parentIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_localResource;
......@@ -5552,12 +5554,15 @@ module OneM2M_Functions {
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource created successfuly");
v_localResource := f_generateLocalResource(p_request.primitiveContent, v_parentIndex, p_request.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_request.resourceType, v_parentIndex);
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2001,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,p_request.requestIdentifier));
if(p_responseStatusCode == int2001) {
setverdict(pass, __SCOPE__&":INFO: Resource created successfuly");
v_localResource := f_generateLocalResource(p_request.primitiveContent, v_parentIndex, p_request.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_request.resourceType, v_parentIndex);
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
} else {
setverdict(pass, __SCOPE__&":INFO: Resource creation rejected");
}
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
......@@ -5569,7 +5574,7 @@ module OneM2M_Functions {
* @desc Proccessing of the UPDATE request primitive
* @param p_request Request primitive to be processed
*/
function f_processUpdateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
function f_processUpdateRequestPrimitive(in RequestPrimitive p_request, in ResponseStatusCode p_responseStatusCode := int2004) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
......@@ -5578,10 +5583,14 @@ module OneM2M_Functions {
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource updated successfuly");
f_updateLocalResource(v_targetLocalResourceIndex, p_request.primitiveContent);
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2004,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,p_request.requestIdentifier));
if(p_responseStatusCode == int2001) {
setverdict(pass, __SCOPE__&":INFO: Resource updated successfuly");
f_updateLocalResource(v_targetLocalResourceIndex, p_request.primitiveContent);
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
} else {
setverdict(pass, __SCOPE__&":INFO: Resource update rejected");
}
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
......@@ -5593,7 +5602,7 @@ module OneM2M_Functions {
* @desc Proccessing of the RETRIEVE request primitive
* @param p_request Request primitive to be processed
*/
function f_processRetrieveRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
function f_processRetrieveRequestPrimitive(in RequestPrimitive p_request, in ResponseStatusCode p_responseStatusCode := int2000) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
......@@ -5603,8 +5612,10 @@ module OneM2M_Functions {
} else {
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2000,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,p_request.requestIdentifier));
if(p_responseStatusCode == int2000) {
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
}
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
......@@ -5616,7 +5627,7 @@ module OneM2M_Functions {
* @desc Proccessing of the DELETE request primitive
* @param p_request Request primitive to be processed
*/
function f_processDeleteRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
function f_processDeleteRequestPrimitive(in RequestPrimitive p_request, in ResponseStatusCode p_responseStatusCode := int2002) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
......@@ -5625,8 +5636,12 @@ module OneM2M_Functions {
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource deleted successfuly");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2002,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,p_request.requestIdentifier));
if(p_responseStatusCode == int2002) {
setverdict(pass, __SCOPE__&":INFO: Resource deleted successfuly");
} else {
setverdict(pass, __SCOPE__&":INFO: Resource deletion rejected");
}
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment