use of org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService in project so by onap.
the class Onap3gppServiceInstances method createRequestObject.
public InfraActiveRequests createRequestObject(Object request, Action action, String requestId, Status status, String requestScope, String requestJson) {
InfraActiveRequests aq = new InfraActiveRequests();
try {
String networkType = null;
String serviceInstanceName = null;
String serviceInstanceId = null;
if (action.name().equals("createInstance")) {
networkType = ((Allocate3gppService) request).getNetworkType();
serviceInstanceName = ((Allocate3gppService) request).getName();
aq.setServiceInstanceName(serviceInstanceName);
} else if (action.name().equals("updateInstance")) {
networkType = ((Modify3gppService) request).getNetworkType();
serviceInstanceName = ((Modify3gppService) request).getName();
serviceInstanceId = ((Modify3gppService) request).getServiceInstanceID();
aq.setServiceInstanceName(serviceInstanceName);
aq.setServiceInstanceId(serviceInstanceId);
} else if (action.name().equals("deleteInstance")) {
networkType = ((DeAllocate3gppService) request).getNetworkType();
serviceInstanceId = ((DeAllocate3gppService) request).getServiceInstanceID();
aq.setServiceInstanceId(serviceInstanceId);
} else if (action.name().equals("activateInstance")) {
networkType = ((ActivateOrDeactivate3gppService) request).getNetworkType();
serviceInstanceId = ((ActivateOrDeactivate3gppService) request).getServiceInstanceID();
// setting serviceInstanceId as serviceInstanceName
aq.setServiceInstanceName(serviceInstanceId);
// -->serviceInstanceName shouldn't be null for action -
// activateInstance duplicateRequests check
aq.setServiceInstanceId(serviceInstanceId);
} else if (action.name().equals("deactivateInstance")) {
networkType = ((ActivateOrDeactivate3gppService) request).getNetworkType();
serviceInstanceId = ((ActivateOrDeactivate3gppService) request).getServiceInstanceID();
aq.setServiceInstanceId(serviceInstanceId);
}
aq.setRequestId(requestId);
aq.setRequestAction(action.toString());
aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
aq.setStartTime(startTimeStamp);
aq.setRequestScope(requestScope);
aq.setRequestBody(requestJson);
aq.setRequestStatus(status.toString());
aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
aq.setNetworkType(networkType);
} catch (Exception e) {
logger.error("Exception when creation record request", e);
if (!status.equals(Status.FAILED)) {
throw e;
}
}
return aq;
}
Aggregations