Search in sources :

Example 1 with ActivateOrDeactivate3gppService

use of org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.ActivateOrDeactivate3gppService 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;
}
Also used : ActivateOrDeactivate3gppService(org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.ActivateOrDeactivate3gppService) Modify3gppService(org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Timestamp(java.sql.Timestamp) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) BPMNFailureException(org.onap.so.apihandlerinfra.exceptions.BPMNFailureException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) RequestDbFailureException(org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 BPMNFailureException (org.onap.so.apihandlerinfra.exceptions.BPMNFailureException)1 RequestDbFailureException (org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ActivateOrDeactivate3gppService (org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.ActivateOrDeactivate3gppService)1 Modify3gppService (org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1