diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-30 15:56:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-31 11:09:25 -0400 |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /adapters/mso-requests-db-adapter/src | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-requests-db-adapter/src')
38 files changed, 2393 insertions, 778 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java new file mode 100644 index 0000000000..9a7382f200 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.onap.so.db.request.beans.ArchivedInfraRequests; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository; +import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.PageRequest; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import net.javacrumbs.shedlock.core.SchedulerLock; + +@Component +public class ArchiveInfraRequestsScheduler { + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ArchiveInfraRequestsScheduler.class); + + @Autowired + private InfraActiveRequestsRepository infraActiveRepo; + @Autowired + private ArchivedInfraRequestsRepository archivedInfraRepo; + + @Value("${mso.infra-requests.archived.period}") + private int archivedPeriod; + + /** + * Runs the scheduler nightly + * [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year] + */ + @Scheduled(cron="0 0 1 * * ?") + @SchedulerLock(name = "archiveInfraRequestsScheduler") + public void infraRequestsScheduledTask() { + logger.debug("Start of archiveInfraRequestsScheduler"); + + Date currentDate= new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentDate); + calendar.add(Calendar.DATE, -archivedPeriod); + Date archivingDate = calendar.getTime(); + + logger.debug("Date before 6 months: "+ (calendar.get(Calendar.MONTH) + 1) + "-" + + calendar.get(Calendar.DATE) + "-" + calendar.get(Calendar.YEAR)); + + List<InfraActiveRequests> requestsByEndTime = new ArrayList<>(); + PageRequest pageRequest = new PageRequest(0, 100); + do { + requestsByEndTime = infraActiveRepo.findByEndTimeLessThan(archivingDate, pageRequest); + logger.debug(requestsByEndTime.size() + " requests to be archived based on End Time" ); + archiveInfraRequests(requestsByEndTime); + } while(requestsByEndTime.size() > 0); + + List<InfraActiveRequests> requestsByStartTime = new ArrayList<>(); + do { + requestsByStartTime = infraActiveRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, pageRequest); + logger.debug(requestsByEndTime.size() + " requests to be archived based on Start Time" ); + archiveInfraRequests(requestsByStartTime); + } while(requestsByStartTime.size() > 0); + + logger.debug("End of archiveInfraRequestsScheduler"); + } + + protected void archiveInfraRequests(List<InfraActiveRequests> requests) { + List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>(); + List<InfraActiveRequests> oldInfraReqs = new ArrayList<>(); + + for(InfraActiveRequests iar: requests) { + ArchivedInfraRequests archivedInfra = new ArchivedInfraRequests(); + try { + archivedInfra.setAaiServiceId(iar.getAaiServiceId()); + archivedInfra.setAction(iar.getAction()); + archivedInfra.setAicCloudRegion(iar.getAicCloudRegion()); + archivedInfra.setAicNodeClli(iar.getAicNodeClli()); + archivedInfra.setCallBackUrl(iar.getCallBackUrl()); + archivedInfra.setClientRequestId(iar.getClientRequestId()); + archivedInfra.setConfigurationId(iar.getConfigurationId()); + archivedInfra.setConfigurationName(iar.getConfigurationName()); + archivedInfra.setCorrelator(iar.getCorrelator()); + archivedInfra.setEndTime(iar.getEndTime()); + archivedInfra.setLastModifiedBy(iar.getLastModifiedBy()); + archivedInfra.setNetworkId(iar.getNetworkId()); + archivedInfra.setNetworkName(iar.getNetworkName()); + archivedInfra.setNetworkType(iar.getNetworkType()); + archivedInfra.setOperationalEnvId(iar.getOperationalEnvId()); + archivedInfra.setOperationalEnvName(iar.getOperationalEnvName()); + archivedInfra.setProgress(iar.getProgress()); + archivedInfra.setProvStatus(iar.getProvStatus()); + archivedInfra.setRequestAction(iar.getRequestAction()); + archivedInfra.setRequestBody(iar.getRequestBody()); + archivedInfra.setRequestId(iar.getRequestId()); + archivedInfra.setRequestorId(iar.getRequestorId()); + archivedInfra.setRequestScope(iar.getRequestScope()); + archivedInfra.setRequestStatus(iar.getRequestStatus()); + archivedInfra.setRequestType(iar.getRequestType()); + archivedInfra.setResponseBody(iar.getResponseBody()); + archivedInfra.setServiceInstanceId(iar.getServiceInstanceId()); + archivedInfra.setServiceInstanceName(iar.getServiceInstanceName()); + archivedInfra.setServiceType(iar.getServiceType()); + archivedInfra.setSource(iar.getSource()); + archivedInfra.setStartTime(iar.getStartTime()); + archivedInfra.setStatusMessage(iar.getStatusMessage()); + archivedInfra.setTenantId(iar.getTenantId()); + archivedInfra.setVfModuleId(iar.getVfModuleId()); + archivedInfra.setVfModuleModelName(iar.getVfModuleModelName()); + archivedInfra.setVfModuleName(iar.getVfModuleName()); + archivedInfra.setVnfId(iar.getVnfId()); + archivedInfra.setVnfName(iar.getVnfName()); + archivedInfra.setVnfOutputs(iar.getVnfOutputs()); + archivedInfra.setVnfParams(iar.getVnfParams()); + archivedInfra.setVnfType(iar.getVnfType()); + archivedInfra.setVolumeGroupId(iar.getVolumeGroupId()); + archivedInfra.setVolumeGroupName(iar.getVolumeGroupName()); + + newArchivedReqs.add(archivedInfra); + oldInfraReqs.add(iar); + } catch(Exception e) { + logger.error(e); + logger.error(MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.UnknownError, e.getMessage()); + } + } + + logger.info("Creating archivedInfraRequest records: " + newArchivedReqs.size()); + archivedInfraRepo.save(newArchivedReqs); + + logger.info("Deleting InfraActiveRequest records: "+ oldInfraReqs.size()); + infraActiveRepo.delete(oldInfraReqs); + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java new file mode 100644 index 0000000000..e28bdb2f96 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlElement; + +import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.ResourceOperationStatus; + +/** + * MSO Request DB Adapter Web Service + */ +@WebService(name = "RequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb") +public interface MsoRequestsDbAdapter { + + @WebMethod + public void updateInfraRequest(@WebParam(name = "requestId") @XmlElement(required = true) String requestId, + @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy, + @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage, + @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody, + @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs, + @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId, + @WebParam(name = "networkId") @XmlElement(required = false) String networkId, + @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId, + @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId, + @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId, + @WebParam(name = "serviceInstanceName") @XmlElement(required = false) String serviceInstanceName, + @WebParam(name = "configurationId") @XmlElement(required = false) String configurationId, + @WebParam(name = "configurationName") @XmlElement(required = false) String configurationName, + @WebParam(name = "vfModuleName") @XmlElement(required = false) String vfModuleName) + throws MsoRequestsDbException; + + @WebMethod + public InfraActiveRequests getInfraRequest( + @WebParam(name = "requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException; + + @WebMethod + public boolean getSiteStatus(@WebParam(name = "siteName") @XmlElement(required = true) String siteName); + + @WebMethod + public void updateServiceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = false) String operationId, + @WebParam(name = "operationType") @XmlElement(required = false) String operationType, + @WebParam(name = "userId") @XmlElement(required = false) String userId, + @WebParam(name = "result") @XmlElement(required = false) String result, + @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; + + @WebMethod + public void initResourceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = true) String operationId, + @WebParam(name = "operationType") @XmlElement(required = true) String operationType, + @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs) + throws MsoRequestsDbException; + + @WebMethod + public ResourceOperationStatus getResourceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = true) String operationId, + @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID) + throws MsoRequestsDbException; + + @WebMethod + public void updateResourceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = true) String operationId, + @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID, + @WebParam(name = "operType") @XmlElement(required = false) String operType, + @WebParam(name = "resourceInstanceID") @XmlElement(required = false) String resourceInstanceID, + @WebParam(name = "jobId") @XmlElement(required = false) String jobId, + @WebParam(name = "status") @XmlElement(required = false) String status, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "errorCode") @XmlElement(required = false) String errorCode, + @WebParam(name = "statusDescription") @XmlElement(required = false) String statusDescription) + throws MsoRequestsDbException; +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java new file mode 100644 index 0000000000..2f6a5839b7 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -0,0 +1,326 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import java.sql.Timestamp; + +import javax.jws.WebService; +import javax.transaction.Transactional; + +import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatusId; +import org.onap.so.db.request.beans.SiteStatus; +import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.db.request.data.repository.SiteStatusRepository; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.onap.so.utils.UUIDChecker; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb") +@Component +@Primary +public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { + + private static final String SUCCESSFUL = "Successful"; + + private static final String GET_INFRA_REQUEST = "Get Infra request"; + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, MsoRequestsDbAdapterImpl.class); + + @Autowired + private InfraActiveRequestsRepository infraActive; + + @Autowired + private SiteStatusRepository siteRepo; + + @Autowired + private OperationStatusRepository operationStatusRepository; + + @Autowired + private ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Transactional + @Override + public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody, + RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId, + String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName, + String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException { + MsoLogger.setLogContext(requestId, serviceInstanceId); + long startTime = System.currentTimeMillis(); + try { + InfraActiveRequests request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId); + if (request == null) { + String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId; + throw new MsoRequestsDbException(error); + } + if (statusMessage != null) { + request.setStatusMessage(statusMessage); + } + if (responseBody != null) { + request.setResponseBody(responseBody); + } + if (requestStatus != null) { + request.setRequestStatus(requestStatus.toString()); + } + if (progress != null) { + setProgress(progress, request); + } + if (vnfOutputs != null) { + request.setVnfOutputs(vnfOutputs); + } + if (serviceInstanceId != null) { + request.setServiceInstanceId(serviceInstanceId); + } + if (networkId != null) { + request.setNetworkId(networkId); + } + if (vnfId != null) { + request.setVnfId(vnfId); + } + if (vfModuleId != null) { + request.setVfModuleId(vfModuleId); + } + if (volumeGroupId != null) { + request.setVolumeGroupId(volumeGroupId); + } + if (serviceInstanceName != null) { + request.setServiceInstanceName(serviceInstanceName); + } + if (vfModuleName != null) { + request.setVfModuleName(vfModuleName); + } + if (configurationId != null) { + request.setConfigurationId(configurationId); + } + if (configurationName != null) { + request.setConfigurationName(configurationName); + } + if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { + Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis()); + request.setEndTime(nowTimeStamp); + } + request.setLastModifiedBy(lastModifiedBy); + infraActive.save(request); + + } catch (Exception e) { + String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; + logger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + throw new MsoRequestsDbException(error, e); + } + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL); + + } + + private void setProgress(String progress, InfraActiveRequests request) { + try { + request.setProgress(Long.parseLong(progress)); + } catch (NumberFormatException e) { + logger.warnSimple("UpdateInfraRequest", "Invalid value sent for progress"); + } + } + + @Override + @Transactional + public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException { + long startTime = System.currentTimeMillis(); + MsoLogger.setLogContext(requestId, null); + + logger.debug("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); + + InfraActiveRequests request = null; + try { + + request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId); + if (request == null) { + String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId; + throw new MsoRequestsDbException(error); + } + } catch (Exception e) { + String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; + logger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + throw new MsoRequestsDbException(error, e); + } + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL); + return request; + } + + /** + * Get SiteStatus by SiteName. + * + * @param siteName + * The unique name of the site + * @return Status of that site + */ + @Override + @Transactional + public boolean getSiteStatus(String siteName) { + UUIDChecker.generateUUID(logger); + long startTime = System.currentTimeMillis(); + SiteStatus siteStatus; + logger.debug("Request database - get Site Status with Site name:" + siteName); + + siteStatus = siteRepo.findOneBySiteName(siteName); + if (siteStatus == null) { + // if not exist in DB, it means the site is not disabled, thus + // return true + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL); + return true; + } else { + logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL); + return siteStatus.getStatus(); + } + } + + /** + * update operation status <br> + * + * @param serviceId + * @param operationId + * @param operationType + * @param userId + * @param result + * @param operationContent + * @param progress + * @param reason + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + @Transactional + public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, + String result, String operationContent, String progress, String reason) throws MsoRequestsDbException { + OperationStatus operStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId); + if (operStatus == null) { + String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + + operationId; + MsoRequestsDbException e = new MsoRequestsDbException(error); + logger.error("Error "+ MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + throw e; + } + + operStatus.setUserId(userId); + operStatus.setOperation(operationType); + operStatus.setReason(reason); + operStatus.setProgress(progress); + operStatus.setResult(result); + operStatus.setOperationContent(operationContent); + operStatus.setResult(result); + operationStatusRepository.save(operStatus); + } + + /** + * init the operation status of all the resources <br> + * + * @param serviceId + * the service Id + * @param operationId + * the operation Id + * @param operationType + * the operationType + * @param resourceTemplateUUIDs + * the resources, the UUID is split by ":" + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + @Transactional + public void initResourceOperationStatus(String serviceId, String operationId, String operationType, + String resourceTemplateUUIDs) throws MsoRequestsDbException { + String[] resourceLst = resourceTemplateUUIDs.split(":"); + for (String resource : resourceLst) { + if ("".equals(resource)) { + continue; + } + ResourceOperationStatus resourceStatus = new ResourceOperationStatus(); + resourceStatus.setOperationId(operationId); + resourceStatus.setServiceId(serviceId); + resourceStatus.setResourceTemplateUUID(resource); + resourceStatus.setOperType(operationType); + resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING); + resourceStatus.setStatusDescription("Waiting for start"); + resourceOperationStatusRepository.save(resourceStatus); + + } + } + + /** + * get resource operation status <br> + * + * @param serviceId + * @param operationId + * @param resourceTemplateUUID + * @return + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, + String resourceTemplateUUID) throws MsoRequestsDbException { + + return resourceOperationStatusRepository + .findOne(new ResourceOperationStatusId(serviceId, operationId, resourceTemplateUUID)); + } + + /** + * update resource operation status <br> + * + * @param serviceId + * @param operationId + * @param resourceTemplateUUID + * @param operationType + * @param resourceInstanceID + * @param jobId + * @param status + * @param progress + * @param errorCode + * @param statusDescription + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID, + String operationType, String resourceInstanceID, String jobId, String status, String progress, + String errorCode, String statusDescription) throws MsoRequestsDbException { + ResourceOperationStatus resStatus = new ResourceOperationStatus(); + resStatus.setServiceId(serviceId); + resStatus.setOperationId(operationId); + resStatus.setResourceTemplateUUID(resourceTemplateUUID); + resStatus.setOperType(operationType); + resStatus.setResourceInstanceID(resourceInstanceID); + resStatus.setJobId(jobId); + resStatus.setStatus(status); + resStatus.setProgress(progress); + resStatus.setErrorCode(errorCode); + resStatus.setStatusDescription(statusDescription); + resourceOperationStatusRepository.save(resStatus); + } +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java index cebde1aa7a..1d5b892ade 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/RequestStatusType.java @@ -26,7 +26,7 @@ // -package org.openecomp.mso.adapters.requestsdb; +package org.onap.so.adapters.requestsdb; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java index 152eb5cf8a..5ee7119f35 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ResponseStatus.java @@ -18,16 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb; - - +package org.onap.so.adapters.requestsdb; /* * Enum for Status values returned by API Handler to Tail-F */ public enum ResponseStatus { - SENDING_FINAL_NOTIFY, - SUCCESS, - FAILED, - TIMEOUT -} + SENDING_FINAL_NOTIFY, SUCCESS, FAILED, TIMEOUT +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java new file mode 100644 index 0000000000..9f52160c8e --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import org.onap.so.security.MSOSpringFirewall; +import org.onap.so.security.WebSecurityConfig; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.firewall.StrictHttpFirewall; +import org.springframework.util.StringUtils; + +@EnableWebSecurity +public class WebSecurityConfigImpl extends WebSecurityConfig { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable() + .authorizeRequests() + .antMatchers("/manage/health","/manage/info").permitAll() + .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) + .and() + .httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java new file mode 100644 index 0000000000..a7e9cab6ba --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.application; + +import javax.xml.ws.Endpoint; + +import org.apache.cxf.Bus; +import org.apache.cxf.feature.LoggingFeature; +import org.apache.cxf.jaxrs.swagger.Swagger2Feature; +import org.apache.cxf.jaxws.EndpointImpl; +import org.apache.cxf.transport.servlet.CXFServlet; +import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class CXFConfiguration { + + @Autowired + private Bus bus; + + @Autowired + private MsoRequestsDbAdapter requestDbAdapterImpl; + + + + @Bean + public ServletRegistrationBean cxfServlet() { + + return new ServletRegistrationBean(new CXFServlet(), "/services/*"); + } + + @Bean + public Endpoint requestEndpointk() { + EndpointImpl endpoint = new EndpointImpl(bus, requestDbAdapterImpl); + endpoint.publish("/RequestsDbAdapter"); + LoggingFeature logFeature = new LoggingFeature(); + logFeature.setPrettyLogging(true); + logFeature.initialize(bus); + endpoint.getFeatures().add(logFeature); + return endpoint; + } + + @Bean + public Swagger2Feature createSwaggerFeature() { + Swagger2Feature swagger2Feature = new Swagger2Feature(); + swagger2Feature.setPrettyPrint(true); + swagger2Feature.setTitle("SO Request Adapter"); + swagger2Feature.setContact("The ONAP SO team"); + swagger2Feature.setDescription("This project is the SO Orchestration Engine"); + swagger2Feature.setVersion("1.0.0"); + swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb"); + swagger2Feature.setScan(true); + return swagger2Feature; + } + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java new file mode 100644 index 0000000000..21582a1e5f --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.application; + +import java.time.Duration; + +import javax.sql.DataSource; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +import net.javacrumbs.shedlock.core.LockProvider; +import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; +import net.javacrumbs.shedlock.spring.ScheduledLockConfiguration; +import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder; + +/** + * @since Version 1.0 + * + */ + +@SpringBootApplication(scanBasePackages = { "org.onap.so"}) +public class MSORequestDBApplication { + + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/reqdb/"); + } + } + + public static void main(String... args) { + SpringApplication.run(MSORequestDBApplication.class, args); + setLogsDir(); + } + + @Bean + public LockProvider lockProvider(DataSource dataSource) { + return new JdbcTemplateLockProvider(dataSource); + } + + @Bean + public ScheduledLockConfiguration taskScheduler(LockProvider lockProvider) { + return ScheduledLockConfigurationBuilder + .withLockProvider(lockProvider) + .withPoolSize(10) + .withDefaultLockAtMostFor(Duration.ofMinutes(10)) + .build(); + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java new file mode 100644 index 0000000000..bc1e17b067 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/RequestDBConfig.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.application; + + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Profile({"!test"}) +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories( + entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", + basePackages = { "org.onap.so.db.request.data.repository" } + ) +public class RequestDBConfig { + + @Primary + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource dataSource() { + return DataSourceBuilder.create().build(); + } + + @Primary + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean + entityManagerFactory( + EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource + ) { + return builder + .dataSource(dataSource) + .packages("org.onap.so.db.request.beans") + .persistenceUnit("requestDB") + .build(); + } + + @Primary + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory + entityManagerFactory + ) { + return new JpaTransactionManager(entityManagerFactory); + } + +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java index 3d909786be..660761143e 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; @@ -30,7 +30,7 @@ import javax.xml.ws.WebFault; * * */ -@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.openecomp.mso/requestsdb") +@WebFault (name="MsoRequestsDbException", faultBean="org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.onap.so/requestsdb") public class MsoRequestsDbException extends Exception { private static final long serialVersionUID = 1L; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java index dce1cf9365..c836a6b374 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; import java.io.Serializable; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java deleted file mode 100644 index 2a74d797da..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - - -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.HealthCheckUtils; -import org.openecomp.mso.utils.UUIDChecker; - - -@Path("/") - public class HealthCheckHandler { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - - @HEAD - @GET - @Path("/healthcheck") - @Produces("text/html") - public Response healthcheck (@QueryParam("requestId") String requestId) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("Healthcheck"); - UUIDChecker.verifyOldUUID(requestId, msoLogger); - HealthCheckUtils healthCheck = new HealthCheckUtils (); - if (!healthCheck.siteStatusCheck(msoLogger)) { - return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; - } - - if (!healthCheck.requestDBCheck (msoLogger, startTime)) { - return HealthCheckUtils.NOT_STARTED_RESPONSE; - } - msoLogger.debug("healthcheck - Successful"); - return HealthCheckUtils.HEALTH_CHECK_RESPONSE; - } - -} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java deleted file mode 100644 index fa9016c69c..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlElement; - -import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.ResourceOperationStatus; - -/** - * MSO Request DB Adapter Web Service - */ -@WebService(name = "RequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb") -public interface MsoRequestsDbAdapter { - - @WebMethod - public void updateInfraRequest (@WebParam(name = "requestId") @XmlElement(required = true) String requestId, - @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy, - @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage, - @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody, - @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus, - @WebParam(name = "progress") @XmlElement(required = false) String progress, - @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs, - @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId, - @WebParam(name = "networkId") @XmlElement(required = false) String networkId, - @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId, - @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId, - @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId, - @WebParam(name = "serviceInstanceName") @XmlElement(required = false) String serviceInstanceName, - @WebParam(name = "configurationId") @XmlElement(required = false) String configurationId, - @WebParam(name = "configurationName") @XmlElement(required = false) String configurationName, - @WebParam(name = "vfModuleName") @XmlElement(required = false) String vfModuleName) throws MsoRequestsDbException; - - @WebMethod - public InfraActiveRequests getInfraRequest (@WebParam(name="requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException; - - @WebMethod - public boolean getSiteStatus (@WebParam(name="siteName") @XmlElement(required = true) String siteName); - - @WebMethod - public void updateServiceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, - @WebParam(name = "operationId") @XmlElement(required = false) String operationId, - @WebParam(name = "operationType") @XmlElement(required = false) String operationType, - @WebParam(name = "userId") @XmlElement(required = false) String userId, - @WebParam(name = "result") @XmlElement(required = false) String result, - @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent, - @WebParam(name = "progress") @XmlElement(required = false) String progress, - @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; - - @WebMethod - public void initResourceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, - @WebParam(name = "operationId") @XmlElement(required = true) String operationId, - @WebParam(name = "operationType") @XmlElement(required = true) String operationType, - @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs) throws MsoRequestsDbException; - - @WebMethod - public ResourceOperationStatus getResourceOperationStatus (@WebParam(name="serviceId") @XmlElement(required = true) String serviceId, - @WebParam(name = "operationId") @XmlElement(required = true) String operationId, - @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID) throws MsoRequestsDbException; - - @WebMethod - public void updateResourceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, - @WebParam(name = "operationId") @XmlElement(required = true) String operationId, - @WebParam(name = "resourceTemplateUUID") @XmlElement(required = true) String resourceTemplateUUID, - @WebParam(name = "operType") @XmlElement(required = false) String operType, - @WebParam(name = "resourceInstanceID") @XmlElement(required = false) String resourceInstanceID, - @WebParam(name = "jobId") @XmlElement(required = false) String jobId, - @WebParam(name = "status") @XmlElement(required = false) String status, - @WebParam(name = "progress") @XmlElement(required = false) String progress, - @WebParam(name = "errorCode") @XmlElement(required = false) String errorCode, - @WebParam(name = "statusDescription") @XmlElement(required = false) String statusDescription) throws MsoRequestsDbException; -} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java deleted file mode 100644 index 3dcf69c815..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ /dev/null @@ -1,400 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - -import java.sql.Timestamp; - -import javax.jws.WebService; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.OperationStatus; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.RequestsDbConstant; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; -import org.openecomp.mso.requestsdb.ResourceOperationStatus; -import org.openecomp.mso.requestsdb.SiteStatus; -import org.openecomp.mso.utils.UUIDChecker; - -@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb") -public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { - - protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); - - private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - @Override - public void updateInfraRequest (String requestId, - String lastModifiedBy, - String statusMessage, - String responseBody, - RequestStatusType requestStatus, - String progress, - String vnfOutputs, - String serviceInstanceId, - String networkId, - String vnfId, - String vfModuleId, - String volumeGroupId, - String serviceInstanceName, - String configurationId, - String configurationName, - String vfModuleName) throws MsoRequestsDbException { - MsoLogger.setLogContext (requestId, null); - Session session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - int result = 0; - long startTime = System.currentTimeMillis (); - try { - session.beginTransaction (); - StringBuilder queryString = new StringBuilder("update InfraActiveRequests set "); - if (statusMessage != null) { - queryString.append("statusMessage = :statusMessage, "); - } - if (responseBody != null) { - queryString.append("responseBody = :responseBody, "); - } - if (requestStatus != null) { - queryString.append("requestStatus = :requestStatus, "); - } - if (progress != null) { - queryString.append("progress = :progress, "); - } - if (vnfOutputs != null) { - queryString.append("vnfOutputs = :vnfOutputs, "); - } - if (serviceInstanceId != null) { - queryString.append("serviceInstanceId = :serviceInstanceId, "); - } - if (networkId != null) { - queryString.append("networkId = :networkId, "); - } - if (vnfId != null) { - queryString.append("vnfId = :vnfId, "); - } - if (vfModuleId != null) { - queryString.append("vfModuleId = :vfModuleId, "); - } - if (volumeGroupId != null) { - queryString.append("volumeGroupId = :volumeGroupId, "); - } - if (serviceInstanceName != null) { - queryString.append("serviceInstanceName = :serviceInstanceName, "); - } - if (vfModuleName != null) { - queryString.append("vfModuleName = :vfModuleName, "); - } - if (configurationId != null) { - queryString.append("configurationId = :configurationId, "); - } - if (configurationName != null) { - queryString.append("configurationName = :configurationName, "); - } - if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { - queryString.append("endTime = :endTime, "); - } else { - queryString.append("modifyTime = :modifyTime, "); - } - queryString.append("lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId"); - - logger.debug("Executing update: " + queryString.toString()); - - Query query = session.createQuery (queryString.toString()); - query.setParameter ("requestId", requestId); - if (statusMessage != null) { - query.setParameter ("statusMessage", statusMessage); - logger.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage); - } - if (responseBody != null) { - query.setParameter ("responseBody", responseBody); - logger.debug ("ResponseBody in updateInfraRequest is set to: " + responseBody); - } - if (requestStatus != null) { - query.setParameter ("requestStatus", requestStatus.toString ()); - logger.debug ("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString()); - } - - if (progress != null) { - query.setParameter ("progress", Long.parseLong (progress)); - logger.debug ("Progress in updateInfraRequest is set to: " + progress); - } - if (vnfOutputs != null) { - query.setParameter ("vnfOutputs", vnfOutputs); - logger.debug ("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs); - } - if (serviceInstanceId != null) { - query.setParameter ("serviceInstanceId", serviceInstanceId); - logger.debug ("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId); - } - if (networkId != null) { - query.setParameter ("networkId", networkId); - logger.debug ("NetworkId in updateInfraRequest is set to: " + networkId); - } - if (vnfId != null) { - query.setParameter ("vnfId", vnfId); - logger.debug ("VnfId in updateInfraRequest is set to: " + vnfId); - } - if (vfModuleId != null) { - query.setParameter ("vfModuleId", vfModuleId); - logger.debug ("vfModuleId in updateInfraRequest is set to: " + vfModuleId); - } - if (volumeGroupId != null) { - query.setParameter ("volumeGroupId", volumeGroupId); - logger.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); - } - if (serviceInstanceName != null) { - query.setParameter ("serviceInstanceName", serviceInstanceName); - logger.debug ("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName); - } - if (vfModuleName != null) { - query.setParameter ("vfModuleName", vfModuleName); - logger.debug ("vfModuleName in updateInfraRequest is set to: " + vfModuleName); - } - if (configurationId != null) { - query.setParameter ("configurationId", configurationId); - logger.debug ("configurationId in updateInfraRequest is set to: " + configurationId); - } - if (configurationName != null) { - query.setParameter ("configurationName", configurationName); - logger.debug ("configurationName in updateInfraRequest is set to: " + configurationName); - } - if (vfModuleName != null) { - query.setParameter ("vfModuleName", vfModuleName); - logger.debug ("vfModuleName in updateInfraRequest is set to: " + vfModuleName); - } - Timestamp nowTimeStamp = new Timestamp (System.currentTimeMillis ()); - if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) { - query.setParameter ("endTime", nowTimeStamp); - logger.debug ("EndTime in updateInfraRequest is set to: " + nowTimeStamp); - } else { - query.setParameter ("modifyTime", nowTimeStamp); - logger.debug ("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp); - } - query.setParameter ("lastModifiedBy", lastModifiedBy); - logger.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy); - result = query.executeUpdate (); - checkIfExists (result, requestId); - session.getTransaction ().commit (); - } catch (HibernateException e) { - String error = "Unable to update MSO Requests DB: " + e.getMessage (); - logger.error (MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); - throw new MsoRequestsDbException (error, e); - } finally { - if (session != null && session.isOpen ()) { - session.close (); - } - } - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - } - - - private void checkIfExists (int result, String requestId) throws MsoRequestsDbException { - if (result == 0) { - String error = "Request ID does not exist in MSO Requests DB: " + requestId; - logger.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error); - throw new MsoRequestsDbException (error); - } - } - - - @Override - public InfraActiveRequests getInfraRequest (String requestId) throws MsoRequestsDbException { - long startTime = System.currentTimeMillis (); - MsoLogger.setLogContext (requestId, null); - Session session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - - logger.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); - - InfraActiveRequests request = null; - try { - session.beginTransaction (); - Query query = session.createQuery ("FROM InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); - query.setParameter ("requestId", requestId); - request = (InfraActiveRequests) query.uniqueResult(); - } catch (HibernateException e) { - String error = "Unable to retrieve MSO Infra Requests DB for Request ID " - + requestId; - logger.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); - throw new MsoRequestsDbException (error, e); - } finally { - if (session != null && session.isOpen ()) { - session.close (); - } - } - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - return request; - } - - - /** - * Get SiteStatus by SiteName. - * - * @param siteName The unique name of the site - * @return Status of that site - */ - @Override - public boolean getSiteStatus (String siteName) { - UUIDChecker.generateUUID (logger); - Session session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - - long startTime = System.currentTimeMillis (); - SiteStatus siteStatus = null; - logger.debug ("Request database - get Site Status with Site name:" + siteName); - try { - String hql = "FROM SiteStatus WHERE siteName = :site_name"; - Query query = session.createQuery (hql); - query.setParameter ("site_name", siteName); - - siteStatus = (SiteStatus) query.uniqueResult (); - } finally { - if (session != null && session.isOpen ()) { - session.close (); - } - } - if (siteStatus == null) { - // if not exist in DB, it means the site is not disabled, thus return true - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - return true; - } else { - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - return siteStatus.getStatus(); - } - } - - /** - * update operation status - * <br> - * - * @param serviceId - * @param operationId - * @param operationType - * @param userId - * @param result - * @param operationContent - * @param progress - * @param reason - * @throws MsoRequestsDbException - * @since ONAP Amsterdam Release - */ - @Override - public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, - String result, String operationContent, String progress, String reason) throws MsoRequestsDbException { - OperationStatus operStatus = new OperationStatus(); - operStatus.setServiceId(serviceId); - operStatus.setOperationId(operationId); - operStatus.setUserId(userId); - operStatus.setOperation(operationType); - operStatus.setReason(reason); - operStatus.setProgress(progress); - operStatus.setResult(result); - operStatus.setOperationContent(operationContent); - RequestsDatabase.getInstance().updateOperationStatus(operStatus); - } - - /** - * init the operation status of all the resources - * <br> - * - * @param serviceId the service Id - * @param operationId the operation Id - * @param operationType the operationType - * @param resourceTemplateUUIDs the resources, the UUID is split by ":" - * @throws MsoRequestsDbException - * @since ONAP Amsterdam Release - */ - @Override - public void initResourceOperationStatus(String serviceId, String operationId, String operationType, - String resourceTemplateUUIDs) throws MsoRequestsDbException{ - String[] resourceLst = resourceTemplateUUIDs.split(":"); - for(String resource: resourceLst){ - if("".equals(resource)){ - continue; - } - ResourceOperationStatus resourceStatus = new ResourceOperationStatus(); - resourceStatus.setOperationId(operationId); - resourceStatus.setServiceId(serviceId); - resourceStatus.setResourceTemplateUUID(resource); - resourceStatus.setOperType(operationType); - resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING); - resourceStatus.setStatusDescription("Waiting for start"); - RequestsDatabase.getInstance().updateResOperStatus(resourceStatus); - } - } - - /** - * get resource operation status - * <br> - * - * @param serviceId - * @param operationId - * @param resourceTemplateUUID - * @return - * @throws MsoRequestsDbException - * @since ONAP Amsterdam Release - */ - @Override - public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) - throws MsoRequestsDbException { - return RequestsDatabase.getInstance().getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID); - } - - /** - * update resource operation status - * <br> - * - * @param serviceId - * @param operationId - * @param resourceTemplateUUID - * @param operationType - * @param resourceInstanceID - * @param jobId - * @param status - * @param progress - * @param errorCode - * @param statusDescription - * @throws MsoRequestsDbException - * @since ONAP Amsterdam Release - */ - @Override - public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID, - String operationType, String resourceInstanceID, String jobId, String status, String progress, - String errorCode, String statusDescription) throws MsoRequestsDbException { - ResourceOperationStatus resStatus = new ResourceOperationStatus(); - resStatus.setServiceId(serviceId); - resStatus.setOperationId(operationId); - resStatus.setResourceTemplateUUID(resourceTemplateUUID); - resStatus.setOperType(operationType); - resStatus.setResourceInstanceID(resourceInstanceID); - resStatus.setJobId(jobId); - resStatus.setStatus(status); - resStatus.setProgress(progress); - resStatus.setErrorCode(errorCode); - resStatus.setStatusDescription(statusDescription); - RequestsDatabase.getInstance().updateResOperStatus(resStatus); - } -} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java deleted file mode 100644 index 3c6f9224e5..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - - -/* - * Enum for Status values returned by API Handler to Tail-F -*/ -public enum Status { - PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT; - - public boolean isFinished () { - switch (this) { - case COMPLETED: - case FAILED: - case TIMEOUT: - return true; - default: - return false; - } - } -} diff --git a/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties b/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties deleted file mode 100644 index c9345389c9..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties +++ /dev/null @@ -1,28 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ECOMP MSO -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - - -# -- welcome -- -welcomeTitle=JSF Blank Application - -welcomeHeading=Welcome! - -welcomeMessage=This is a JSF blank application. \ - You can find the application.properties file with this message in the src/resources folder. diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml new file mode 100644 index 0000000000..2b4e7808b5 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml @@ -0,0 +1,47 @@ +# will be used as entry in DB to say SITE OFF/ON for healthcheck + +server: + port: 8090 + tomcat: + max-threads: 50 +ssl-enable: false +mso: + logPath: logs + site-name: localSite +spring: + datasource: + url: jdbc:mariadb://localhost:3306/requestdb + username: mso + password: mso123 + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: bpel + password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO' + role: BPEL-Client + - + username: mso_admin + password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' + role: ACTUATOR + +#Actuator +management: + context-path: /manage + +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3306/requestdb + user: mso + password: mso123 +
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml new file mode 100644 index 0000000000..4f423ca870 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml @@ -0,0 +1,47 @@ +# will be used as entry in DB to say SITE OFF/ON for healthcheck + +server: + port: 8080 + tomcat: + max-threads: 50 + +mso: + site-name: unknown + logPath: ./logs/reqdb/ + infra-requests: + archived: + period: 180 +# H2 +spring: + datasource: + url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + dbcp2: + initial-size: 5 + max-total: 20 + validation-query: select 1 + test-on-borrow: true + jpa: + show-sql: false + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb + user: ${DB_ADMIN_USERNAME} + password: ${DB_ADMIN_PASSWORD} + +#Actuator +management: + context-path: /manage + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V1__Base_version.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V1__Base_version.sql new file mode 100644 index 0000000000..94f7d2bb75 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V1__Base_version.sql @@ -0,0 +1,155 @@ +use requestdb; + +CREATE TABLE `activate_operational_env_service_model_distribution_status` ( + `OPERATIONAL_ENV_ID` varchar(45) NOT NULL, + `SERVICE_MODEL_VERSION_ID` varchar(45) NOT NULL, + `REQUEST_ID` varchar(45) NOT NULL, + `SERVICE_MOD_VER_FINAL_DISTR_STATUS` varchar(45) DEFAULT NULL, + `RECOVERY_ACTION` varchar(30) DEFAULT NULL, + `RETRY_COUNT_LEFT` int(11) DEFAULT NULL, + `WORKLOAD_CONTEXT` varchar(80) NOT NULL, + `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`OPERATIONAL_ENV_ID`,`SERVICE_MODEL_VERSION_ID`,`REQUEST_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +CREATE TABLE `activate_operational_env_per_distributionid_status` ( + `DISTRIBUTION_ID` varchar(45) NOT NULL, + `DISTRIBUTION_ID_STATUS` varchar(45) DEFAULT NULL, + `DISTRIBUTION_ID_ERROR_REASON` varchar(250) DEFAULT NULL, + `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `OPERATIONAL_ENV_ID` varchar(45) NOT NULL, + `SERVICE_MODEL_VERSION_ID` varchar(45) NOT NULL, + `REQUEST_ID` varchar(45) NOT NULL, + PRIMARY KEY (`DISTRIBUTION_ID`), + KEY `fk_activate_op_env_per_distributionid_status__aoesmds1_idx` (`OPERATIONAL_ENV_ID`,`SERVICE_MODEL_VERSION_ID`,`REQUEST_ID`), + CONSTRAINT `fk_activate_op_env_per_distributionid_status__aoesmds1` FOREIGN KEY (`OPERATIONAL_ENV_ID`, `SERVICE_MODEL_VERSION_ID`, `REQUEST_ID`) REFERENCES `activate_operational_env_service_model_distribution_status` (`OPERATIONAL_ENV_ID`, `SERVICE_MODEL_VERSION_ID`, `REQUEST_ID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +CREATE TABLE `active_requests` ( + `REQUEST_ID` varchar(45) NOT NULL, + `CLIENT_REQUEST_ID` varchar(45) DEFAULT NULL, + `SERVICE_INSTANCE_ID` varchar(50) NOT NULL, + `SUBSCRIBER_NAME` varchar(200) DEFAULT NULL, + `REQUEST_URI` varchar(255) DEFAULT NULL, + `SERVICE_TYPE` varchar(65) NOT NULL, + `REQUEST_ACTION` varchar(45) NOT NULL, + `NOTIFICATION_URL` varchar(255) DEFAULT NULL, + `REQUEST_ID_IN_PROGRESS` varchar(45) DEFAULT NULL, + `START_TIME` datetime DEFAULT NULL, + `MODIFY_TIME` datetime DEFAULT NULL, + `COMPLETION_TIME` datetime DEFAULT NULL, + `RESPONSE_CODE` varchar(20) DEFAULT NULL, + `RESPONSE_BODY` longtext, + `STATUS` varchar(25) DEFAULT NULL, + `SERVICE_REQUEST_TIMEOUT` datetime DEFAULT NULL, + `FINAL_ERROR_CODE` varchar(20) DEFAULT NULL, + `FINAL_ERROR_MESSAGE` varchar(2000) DEFAULT NULL, + `ORDER_NUMBER` varchar(45) DEFAULT NULL, + `SOURCE` varchar(20) DEFAULT NULL, + `RESPONSE_STATUS` varchar(25) DEFAULT NULL, + `ORDER_VERSION` varchar(20) DEFAULT NULL, + `LAST_MODIFIED_BY` varchar(20) DEFAULT NULL, + `MOCARS_TICKET_NUM` varchar(200) DEFAULT NULL, + `REQUEST_BODY` longtext, + `REQUEST_SUB_ACTION` varchar(45) DEFAULT NULL, + `SDNC_CALLBACK_BPEL_URL` varchar(255) DEFAULT NULL, + `FEATURE_TYPE` varchar(255) DEFAULT NULL, + `FEATURE_INSTANCE_ID` varchar(255) DEFAULT NULL, + `REQUEST_TYPE` varchar(255) DEFAULT NULL, + `INTERIM_COMPLETION_TIME` datetime DEFAULT NULL, + `INTERIM_STAGE_COMPLETION` int(11) DEFAULT NULL, + `SERVICE_NAME_VERSION_ID` varchar(50) DEFAULT NULL, + `GLOBAL_SUBSCRIBER_ID` varchar(255) DEFAULT NULL, + `SERVICE_ID` varchar(50) DEFAULT NULL, + `SERVICE_VERSION` varchar(10) DEFAULT NULL, + `CORRELATOR` varchar(50) DEFAULT NULL, + PRIMARY KEY (`REQUEST_ID`), + UNIQUE KEY `UK_f0hdk7xbw5mb2trnxx0fvlh3x` (`CLIENT_REQUEST_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `infra_active_requests` ( + `REQUEST_ID` varchar(45) NOT NULL, + `CLIENT_REQUEST_ID` varchar(45) DEFAULT NULL, + `ACTION` varchar(45) DEFAULT NULL, + `REQUEST_STATUS` varchar(20) DEFAULT NULL, + `STATUS_MESSAGE` longtext, + `PROGRESS` bigint(20) DEFAULT NULL, + `START_TIME` datetime DEFAULT NULL, + `END_TIME` datetime DEFAULT NULL, + `SOURCE` varchar(45) DEFAULT NULL, + `VNF_ID` varchar(45) DEFAULT NULL, + `VNF_NAME` varchar(80) DEFAULT NULL, + `VNF_TYPE` varchar(200) DEFAULT NULL, + `SERVICE_TYPE` varchar(45) DEFAULT NULL, + `AIC_NODE_CLLI` varchar(11) DEFAULT NULL, + `TENANT_ID` varchar(45) DEFAULT NULL, + `PROV_STATUS` varchar(20) DEFAULT NULL, + `VNF_PARAMS` longtext, + `VNF_OUTPUTS` longtext, + `REQUEST_BODY` longtext, + `RESPONSE_BODY` longtext, + `LAST_MODIFIED_BY` varchar(100) DEFAULT NULL, + `MODIFY_TIME` datetime DEFAULT NULL, + `REQUEST_TYPE` varchar(20) DEFAULT NULL, + `VOLUME_GROUP_ID` varchar(45) DEFAULT NULL, + `VOLUME_GROUP_NAME` varchar(45) DEFAULT NULL, + `VF_MODULE_ID` varchar(45) DEFAULT NULL, + `VF_MODULE_NAME` varchar(200) DEFAULT NULL, + `VF_MODULE_MODEL_NAME` varchar(200) DEFAULT NULL, + `AAI_SERVICE_ID` varchar(50) DEFAULT NULL, + `AIC_CLOUD_REGION` varchar(11) DEFAULT NULL, + `CALLBACK_URL` varchar(200) DEFAULT NULL, + `CORRELATOR` varchar(80) DEFAULT NULL, + `NETWORK_ID` varchar(45) DEFAULT NULL, + `NETWORK_NAME` varchar(80) DEFAULT NULL, + `NETWORK_TYPE` varchar(80) DEFAULT NULL, + `REQUEST_SCOPE` varchar(50) NOT NULL, + `REQUEST_ACTION` varchar(45) NOT NULL DEFAULT 'unknown', + `SERVICE_INSTANCE_ID` varchar(45) DEFAULT NULL, + `SERVICE_INSTANCE_NAME` varchar(80) DEFAULT NULL, + `REQUESTOR_ID` varchar(50) DEFAULT NULL, + `CONFIGURATION_ID` varchar(45) DEFAULT NULL, + `CONFIGURATION_NAME` varchar(200) DEFAULT NULL, + `OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL, + `OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL, + PRIMARY KEY (`REQUEST_ID`), + UNIQUE KEY `UK_bhu6w8p7wvur4pin0gjw2d5ak` (`CLIENT_REQUEST_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +CREATE TABLE `site_status` ( + `SITE_NAME` varchar(255) NOT NULL, + `STATUS` bit(1) DEFAULT NULL, + `CREATION_TIMESTAMP` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`SITE_NAME`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `watchdog_distributionid_status` ( + `DISTRIBUTION_ID` varchar(45) NOT NULL, + `DISTRIBUTION_ID_STATUS` varchar(45) DEFAULT NULL, + `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`DISTRIBUTION_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `watchdog_per_component_distribution_status` ( + `DISTRIBUTION_ID` varchar(45) NOT NULL, + `COMPONENT_NAME` varchar(45) NOT NULL, + `COMPONENT_DISTRIBUTION_STATUS` varchar(45) DEFAULT NULL, + `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`DISTRIBUTION_ID`,`COMPONENT_NAME`), + CONSTRAINT `fk_watchdog_component_distribution_status_watchdog_distributi1` FOREIGN KEY (`DISTRIBUTION_ID`) REFERENCES `watchdog_distributionid_status` (`DISTRIBUTION_ID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `watchdog_service_mod_ver_id_lookup` ( + `DISTRIBUTION_ID` varchar(45) NOT NULL, + `SERVICE_MODEL_VERSION_ID` varchar(45) NOT NULL, + `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODIFY_TIME` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`DISTRIBUTION_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.1__Add_Identifiers_Active_Requests.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.1__Add_Identifiers_Active_Requests.sql new file mode 100644 index 0000000000..8e6a767d2c --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.1__Add_Identifiers_Active_Requests.sql @@ -0,0 +1,9 @@ +use requestdb; + +ALTER TABLE active_requests +ADD VPN_ID varchar(200), +ADD PROGRESS BIGINT(20), +ADD STATUS_MESSAGE LONGTEXT, +ADD REQUESTED_SERVICE_NAME varchar(200), +ADD PRODUCT_FLAVOR varchar(200), +ADD SERVICE_INSTANCE_NAME varchar(80); diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.2__Add_Operation_Status.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.2__Add_Operation_Status.sql new file mode 100644 index 0000000000..1e96f614b5 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.2__Add_Operation_Status.sql @@ -0,0 +1,30 @@ +use requestdb; + +create table if not exists operation_status ( + SERVICE_ID varchar(255) not null, + OPERATION_ID varchar(255) not null, + SERVICE_NAME varchar(255), + OPERATION_TYPE varchar(255), + USER_ID varchar(255), + RESULT varchar(255), + OPERATION_CONTENT varchar(255), + PROGRESS varchar(255), + REASON varchar(255), + OPERATE_AT datetime, + FINISHED_AT datetime, + primary key (SERVICE_ID,OPERATION_ID) +); + +create table resource_operation_status ( + SERVICE_ID varchar(255) not null, + OPERATION_ID varchar(255) not null, + RESOURCE_TEMPLATE_UUID varchar(255) not null, + OPER_TYPE varchar(255), + RESOURCE_INSTANCE_ID varchar(255), + JOB_ID varchar(255), + STATUS varchar(255), + PROGRESS varchar(255), + ERROR_CODE varchar(255) , + STATUS_DESCRIPOTION varchar(255) , + primary key (SERVICE_ID,OPERATION_ID,RESOURCE_TEMPLATE_UUID) +) ENGINE=InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.3__Remove_Invalid_requestdb_data.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.3__Remove_Invalid_requestdb_data.sql new file mode 100644 index 0000000000..d361bcedd9 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.3__Remove_Invalid_requestdb_data.sql @@ -0,0 +1,5 @@ +USE requestdb; + +delete from infra_active_requests where source != 'VID' and source != 'POLO'; + +delete from infra_active_requests where request_body like '<%'; diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.4__Activate_Requests_Nullable_Coulmns.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.4__Activate_Requests_Nullable_Coulmns.sql new file mode 100644 index 0000000000..32a9d61645 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.4__Activate_Requests_Nullable_Coulmns.sql @@ -0,0 +1,6 @@ +USE requestdb; + +ALTER TABLE active_requests + MODIFY IF EXISTS SERVICE_INSTANCE_ID varchar(50) NULL, + MODIFY IF EXISTS REQUEST_ACTION varchar(45) NULL, + MODIFY IF EXISTS SERVICE_TYPE varchar(65) NULL;
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.5__Archived_Infra_Requests.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.5__Archived_Infra_Requests.sql new file mode 100644 index 0000000000..b2568627a3 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.5__Archived_Infra_Requests.sql @@ -0,0 +1,51 @@ +use requestdb; + +CREATE TABLE IF NOT EXISTS `archived_infra_requests` ( +`REQUEST_ID` VARCHAR(45) NOT NULL, +`CLIENT_REQUEST_ID` VARCHAR(45) NULL DEFAULT NULL, +`ACTION` VARCHAR(45) NULL, +`REQUEST_STATUS` VARCHAR(20) NULL DEFAULT NULL, +`STATUS_MESSAGE` LONGTEXT NULL DEFAULT NULL, +`PROGRESS` BIGINT(20) NULL DEFAULT NULL, +`START_TIME` DATETIME NULL DEFAULT NULL, +`END_TIME` DATETIME NULL DEFAULT NULL, +`SOURCE` VARCHAR(45) NULL DEFAULT NULL, +`VNF_ID` VARCHAR(45) NULL DEFAULT NULL, +`VNF_NAME` VARCHAR(80) NULL DEFAULT NULL, +`VNF_TYPE` VARCHAR(200) NULL DEFAULT NULL, +`SERVICE_TYPE` VARCHAR(45) NULL DEFAULT NULL, +`AIC_NODE_CLLI` VARCHAR(11) NULL DEFAULT NULL, +`TENANT_ID` VARCHAR(45) NULL DEFAULT NULL, +`PROV_STATUS` VARCHAR(20) NULL DEFAULT NULL, +`VNF_PARAMS` LONGTEXT NULL DEFAULT NULL, +`VNF_OUTPUTS` LONGTEXT NULL DEFAULT NULL, +`REQUEST_BODY` LONGTEXT NULL DEFAULT NULL, +`RESPONSE_BODY` LONGTEXT NULL DEFAULT NULL, +`LAST_MODIFIED_BY` VARCHAR(100) NULL DEFAULT NULL, +`MODIFY_TIME` DATETIME NULL DEFAULT NULL, +`REQUEST_TYPE` VARCHAR(20) NULL DEFAULT NULL, +`VOLUME_GROUP_ID` VARCHAR(45) NULL DEFAULT NULL, +`VOLUME_GROUP_NAME` VARCHAR(45) NULL DEFAULT NULL, +`VF_MODULE_ID` VARCHAR(45) NULL DEFAULT NULL, +`VF_MODULE_NAME` VARCHAR(200) NULL DEFAULT NULL, +`VF_MODULE_MODEL_NAME` VARCHAR(200) NULL DEFAULT NULL, +`AAI_SERVICE_ID` VARCHAR(50) NULL DEFAULT NULL, +`AIC_CLOUD_REGION` VARCHAR(11) NULL DEFAULT NULL, +`CALLBACK_URL` VARCHAR(200) NULL DEFAULT NULL, +`CORRELATOR` VARCHAR(80) NULL DEFAULT NULL, +`NETWORK_ID` VARCHAR(45) NULL DEFAULT NULL, +`NETWORK_NAME` VARCHAR(80) NULL DEFAULT NULL, +`NETWORK_TYPE` VARCHAR(80) NULL DEFAULT NULL, +`REQUEST_SCOPE` VARCHAR(45) NOT NULL DEFAULT 'unknown', +`REQUEST_ACTION` VARCHAR(45) NOT NULL DEFAULT 'unknown', +`SERVICE_INSTANCE_ID` VARCHAR(45) NULL DEFAULT NULL, +`SERVICE_INSTANCE_NAME` VARCHAR(80) NULL DEFAULT NULL, +`REQUESTOR_ID` VARCHAR(50) NULL DEFAULT NULL, +`CONFIGURATION_ID` VARCHAR(45) NULL, +`CONFIGURATION_NAME` VARCHAR(200) NULL, +`OPERATIONAL_ENV_ID` VARCHAR(45) NULL, +`OPERATIONAL_ENV_NAME` VARCHAR(200) NULL, +PRIMARY KEY (`REQUEST_ID`), +UNIQUE INDEX `UK_client_request_id` (`CLIENT_REQUEST_ID` ASC)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.6__shedlock.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.6__shedlock.sql new file mode 100644 index 0000000000..76faf07f59 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.6__shedlock.sql @@ -0,0 +1,9 @@ +use requestdb; + +CREATE TABLE SHEDLOCK( +NAME VARCHAR(64), +LOCK_UNTIL TIMESTAMP(3) NULL, +LOCKED_AT TIMESTAMP(3) NULL, +LOCKED_BY VARCHAR(255), +PRIMARY KEY (NAME) +); diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.7__Update_Status_Message_ColumnTypes.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.7__Update_Status_Message_ColumnTypes.sql new file mode 100644 index 0000000000..5433e397d9 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V2.7__Update_Status_Message_ColumnTypes.sql @@ -0,0 +1,8 @@ +use requestdb; + +ALTER TABLE active_requests +MODIFY STATUS_MESSAGE LONGTEXT; + + +ALTER TABLE infra_active_requests +MODIFY STATUS_MESSAGE LONGTEXT; diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java new file mode 100644 index 0000000000..54debac36f --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository; +import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageRequest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@Transactional +public class ArchiveInfraRequestsSchedulerTest { + + @Autowired + private ArchiveInfraRequestsScheduler scheduler; + + @Autowired + private InfraActiveRequestsRepository iarRepo; + + @Autowired + private ArchivedInfraRequestsRepository archivedRepo; + + @Value("${mso.infra-requests.archived.period}") + private int archivedPeriod; + + @Test + public void testArchiveInfraRequests() { + String requestId1 = "requestId1"; + String requestId2 = "requestId2"; + + InfraActiveRequests iar1 = new InfraActiveRequests(); + iar1.setRequestId(requestId1); + iar1.setAction("action1"); + + InfraActiveRequests iar2 = new InfraActiveRequests(); + iar2.setRequestId(requestId2); + iar2.setAction("action2"); + + List<InfraActiveRequests> requests = new ArrayList<>(); + requests.add(iar1); + requests.add(iar2); + iarRepo.save(requests); + + scheduler.archiveInfraRequests(requests); + + assertEquals(2, archivedRepo.count()); + assertEquals(requestId1, archivedRepo.findOne(requestId1).getRequestId()); + assertEquals(requestId2, archivedRepo.findOne(requestId2).getRequestId()); + } + + @Test + public void testInfraRequestsScheduledTask() { + Date currentDate= new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentDate); + calendar.add(Calendar.DATE, -archivedPeriod); + Date archivingDate = calendar.getTime(); + + List<InfraActiveRequests> requests = iarRepo.findByEndTimeLessThan(archivingDate, new PageRequest(0, 100)); + List<InfraActiveRequests> requests2 = iarRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, new PageRequest(0, 100)); + + int total = requests.size() + requests2.size(); + + scheduler.infraRequestsScheduledTask(); + + assertTrue(archivedRepo.count() >= total); + assertTrue(iarRepo.count() < total); + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java new file mode 100644 index 0000000000..005eba0ec2 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.adapters; + +import static org.junit.Assert.*; + + + +import javax.ws.rs.core.Response; + +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; + +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class HealthCheckHandlerTest { + + @LocalServerPort + private int port; + + TestRestTemplate restTemplate = new TestRestTemplate(); + + HttpHeaders headers = new HttpHeaders(); + + + @Test + public void testHealthcheck() throws JSONException { + + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + + ResponseEntity<String> response = restTemplate.exchange( + createURLWithPort("/manage/health"), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + } + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java new file mode 100644 index 0000000000..4d00421e6c --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.adapters; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter; +import org.onap.so.adapters.requestsdb.RequestStatusType; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class MSORequestDBImplTest { + + @LocalServerPort + private int port; + + @Autowired + private MsoRequestsDbAdapter dbAdapter; + + @Autowired + private OperationStatusRepository operationStatusRepository; + + @Autowired + private ResourceOperationStatusRepository resourceOperationStatusRepo; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + public InfraActiveRequests setupTestEntities() { + return buildTestRequest(); + } + + private InfraActiveRequests buildTestRequest() { + InfraActiveRequests testRequest= new InfraActiveRequests(); + testRequest.setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017"); + testRequest.setClientRequestId("00032ab7-3fb3-42e5-965d-8ea592502016"); + testRequest.setRequestStatus("COMPLETE"); + testRequest.setStatusMessage("Vf Module has been deleted successfully."); + testRequest.setProgress((long) 100); + testRequest.setSource("VID"); + testRequest.setTenantId("6accefef3cb442ff9e644d589fb04107"); + testRequest.setServiceInstanceId("e3b5744d-2ad1-4cdd-8390-c999a38829bc"); + testRequest.setRequestAction("deleteInstance"); + testRequest.setRequestScope("vfModule"); + testRequest.setAction("deleteInstance"); + testRequest.setAicCloudRegion("mtn6"); + testRequest.setLastModifiedBy("BPMN"); + testRequest.setVfModuleId("c7d527b1-7a91-49fd-b97d-1c8c0f4a7992"); + testRequest.setVfModuleModelName("vSAMP10aDEV::base::module-0"); + testRequest.setVnfId("b92f60c8-8de3-46c1-8dc1-e4390ac2b005"); + + return testRequest; + } + + + + + @Test + public void getByRequestId() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017"; + + // When + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId); + if(infraRequest ==null) + fail("Null infraRequest"); + + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + + @Test + public void getByInvalidRequestId() throws MsoRequestsDbException { + // Given + String requestId = "invalidRequestId"; + + try { + dbAdapter.getInfraRequest(requestId); + fail("Expected MsoRequestsDbException to be thrown"); + } catch (MsoRequestsDbException e) { + assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId"); + } catch (Exception e) { + fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown"); + } + } + + @Test + public void getByClientRequestId() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + // When + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + if(infraRequest ==null) + fail("Null infraRequest"); + + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + + @Test + public void updateInfraRequest() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + + // When + String lastModifiedBy = "UNIT TEST"; + String statusMessage = "TESTING THE UDPATES"; + String progress = "50"; + String vnfOutputs = "VNF OUTPUTS"; + String networkId = "New NetworkID"; + String vnfId = "NEWVNFID"; + String volumeGroupId = "NewVolumeGroupId"; + String serviceInstanceName = "NewServiceInstanceName"; + String configurationId = "NewConfigurationId"; + String configurationName = "NewConfigurationName"; + String vfModuleName = "VFModuleName"; + RequestStatusType requestStatus = RequestStatusType.COMPLETE ; + String responseBody = "NewResponseBody"; + String vfModuleId = "NEW VF MODULEID"; + String serviceInstanceId = " new serv ind"; + + + testRequest.setVolumeGroupId(volumeGroupId); + testRequest.setServiceInstanceName(serviceInstanceName); + testRequest.setConfigurationId(configurationId); + testRequest.setConfigurationName(configurationName); + testRequest.setNetworkId(networkId); + testRequest.setResponseBody(responseBody); + testRequest.setStatusMessage(statusMessage); + testRequest.setProgress((long) 50); + testRequest.setServiceInstanceId(lastModifiedBy); + testRequest.setLastModifiedBy(lastModifiedBy); + testRequest.setVfModuleId(vfModuleId); + testRequest.setVfModuleName(vfModuleName); + testRequest.setVnfId(vnfId); + testRequest.setServiceInstanceId(serviceInstanceId); + testRequest.setVfModuleName(vfModuleName); + testRequest.setVnfOutputs(vnfOutputs); + + + dbAdapter.updateInfraRequest ( testRequest.getRequestId(), + lastModifiedBy, + statusMessage, + responseBody, + requestStatus, + progress, + vnfOutputs, + serviceInstanceId, + networkId, + vnfId, + vfModuleId, + volumeGroupId, + serviceInstanceName, + configurationId, + configurationName, + vfModuleName); + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + @Test + public void UpdateByInvalidRequestId() throws MsoRequestsDbException { + // Given + String requestId = "invalidRequestId"; + + try { + dbAdapter.updateInfraRequest ( requestId, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + fail("Expected MsoRequestsDbException to be thrown"); + } catch (MsoRequestsDbException e) { + assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId"); + } catch (Exception e) { + fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown"); + } + } + + + @Test + public void updateInfraRequestNulls() throws MsoRequestsDbException { + InfraActiveRequests testRequest = setupTestEntities(); + // Given + String clientRequestId = "00032ab7-3fb3-42e5-965d-8ea592502016"; + + // When + dbAdapter.updateInfraRequest ( testRequest.getRequestId(), + testRequest.getLastModifiedBy(), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId); + // Then + assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime")); + } + + @Test + public void getSiteStatusNotDisabled() throws MsoRequestsDbException { + setupTestEntities(); + // Given + String siteName = "siteName"; + + // When + boolean siteDisabled = dbAdapter.getSiteStatus(siteName); + + // Then + assertEquals(siteDisabled, true); + } + + @Test + public void getSiteStatusDisabled() throws MsoRequestsDbException { + setupTestEntities(); + // Given + String siteName = "testSite"; + + // When + boolean siteDisabled = dbAdapter.getSiteStatus(siteName); + + // Then + assertEquals(siteDisabled, false); + } + + @Test + public void updateServiceOperation() throws MsoRequestsDbException{ + String serviceId = "serviceid"; + String operationId = "operationid"; + String serviceName = "servicename"; + String operation = "newOperationType"; + String userId = "NewUserId"; + String result = "NewResult"; + String operationContent = "newOperationContent"; + String progress = "Newprogress"; + String reason = "NewReason"; + + OperationStatus updatedOperationStatus = new OperationStatus(); + + + + updatedOperationStatus.setServiceId(serviceId); + updatedOperationStatus.setServiceName(serviceName); + updatedOperationStatus.setOperationId(operationId); + updatedOperationStatus.setOperation(operation); + updatedOperationStatus.setUserId(userId); + updatedOperationStatus.setResult(result); + updatedOperationStatus.setProgress(progress); + updatedOperationStatus.setReason(reason); + updatedOperationStatus.setOperationContent(operationContent); + + dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, + result, operationContent, progress, reason); + OperationStatus dbOpStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId,operationId); + assertThat(dbOpStatus, sameBeanAs(updatedOperationStatus).ignoring("operateAt").ignoring("finishedAt")); + } + + + @Test + public void updateServiceOperation_Not_Found() throws MsoRequestsDbException{ + String serviceId = "badserviceId"; + String operationId = "operationid"; + String operation = "newOperationType"; + String userId = "NewUserId"; + String result = "NewResult"; + String operationContent = "newOperationContent"; + String progress = "Newprogress"; + String reason = "NewReason"; + + OperationStatus updatedOperationStatus = new OperationStatus(); + + + + updatedOperationStatus.setServiceId(serviceId); + updatedOperationStatus.setOperationId(operationId); + updatedOperationStatus.setOperation(operation); + updatedOperationStatus.setUserId(userId); + updatedOperationStatus.setResult(result); + updatedOperationStatus.setProgress(progress); + updatedOperationStatus.setReason(reason); + updatedOperationStatus.setOperationContent(operationContent); + + thrown.expect(MsoRequestsDbException.class); + thrown.expectMessage("Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId); + + dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, + result, operationContent, progress, reason); + + } + + @Test + public void initResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUIDs = "template1:template2:template3:"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + + ResourceOperationStatus resource1 = new ResourceOperationStatus(); + resource1.setOperationId(operationId); + resource1.setServiceId(serviceId); + resource1.setResourceTemplateUUID("template1"); + resource1.setOperType(operationType); + resource1.setStatus(RequestsDbConstant.Status.PROCESSING); + resource1.setStatusDescription("Waiting for start"); + + ResourceOperationStatus resource2 = new ResourceOperationStatus(); + resource2.setOperationId(operationId); + resource2.setServiceId(serviceId); + resource2.setResourceTemplateUUID("template2"); + resource2.setOperType(operationType); + resource2.setStatus(RequestsDbConstant.Status.PROCESSING); + resource2.setStatusDescription("Waiting for start"); + + ResourceOperationStatus resource3 = new ResourceOperationStatus(); + resource3.setOperationId(operationId); + resource3.setServiceId(serviceId); + resource3.setResourceTemplateUUID("template3"); + resource3.setOperType(operationType); + resource3.setStatus(RequestsDbConstant.Status.PROCESSING); + resource3.setStatusDescription("Waiting for start"); + + List<ResourceOperationStatus> expectedResult = new ArrayList<ResourceOperationStatus>(); + expectedResult.add(resource1); + expectedResult.add(resource2); + expectedResult.add(resource3); + + dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType,resourceTemplateUUIDs); + List<ResourceOperationStatus> testList = resourceOperationStatusRepo.findByServiceIdAndOperationId(serviceId,operationId); + assertThat(testList, sameBeanAs(expectedResult)); + } + + @Test + public void getResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUIDs = "template1"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + + ResourceOperationStatus resource1 = new ResourceOperationStatus(); + resource1.setOperationId(operationId); + resource1.setServiceId(serviceId); + resource1.setResourceTemplateUUID("template1"); + resource1.setOperType(operationType); + resource1.setStatus(RequestsDbConstant.Status.PROCESSING); + resource1.setStatusDescription("Waiting for start"); + + + dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType,resourceTemplateUUIDs); + + ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId,"template1"); + assertThat(actualResource, sameBeanAs(resource1)); + } + + @Test + public void updateResourceOperationStatus() throws MsoRequestsDbException{ + String resourceTemplateUUID = "template1"; + String serviceId = "serviceId"; + String operationId = "operationId"; + String operationType = "operationType"; + String resourceInstanceID = "resourceInstanceID"; + String jobId = "jobId"; + String status = RequestsDbConstant.Status.FINISHED; + String progress = "50"; + String errorCode = "errorCode"; + String statusDescription = "statusDescription"; + + + ResourceOperationStatus expectedResource = new ResourceOperationStatus(); + expectedResource.setOperationId(operationId); + expectedResource.setServiceId(serviceId); + expectedResource.setResourceTemplateUUID(resourceTemplateUUID); + expectedResource.setOperType(operationType); + expectedResource.setJobId(jobId); + expectedResource.setErrorCode(errorCode); + expectedResource.setStatus(RequestsDbConstant.Status.FINISHED); + expectedResource.setStatusDescription(statusDescription); + expectedResource.setProgress(progress); + expectedResource.setResourceInstanceID(resourceInstanceID); + + + dbAdapter.updateResourceOperationStatus(serviceId, operationId, resourceTemplateUUID, + operationType, resourceInstanceID, jobId, status, progress, + errorCode, statusDescription); + + ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId,"template1"); + assertThat(actualResource, sameBeanAs(expectedResource)); + } + + +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..cd07f6757f --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/EmbeddedMariaDbConfig.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.requestsdb.application; +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +@EnableTransactionManagement +@EnableJpaRepositories( + entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", + basePackages = { "org.onap.so.db.request.data.repository"} + ) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Primary + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } + + @Primary + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean + entityManagerFactory( + EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource + ) { + return builder + .dataSource(dataSource) + .packages("org.onap.so.db.request.beans") + .persistenceUnit("requestDB") + .build(); + } + + @Primary + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory + entityManagerFactory + ) { + return new JpaTransactionManager(entityManagerFactory); + } +} diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java index 159dd91541..77821bfefd 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; import org.junit.Assert; import org.junit.Before; diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java index b946349037..04f597f9b2 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java @@ -14,10 +14,10 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.requestsdb.exceptions; +package org.onap.so.adapters.requestsdb.exceptions; import org.junit.Assert; import org.junit.Test; diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java deleted file mode 100644 index 87e2a87138..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandlerTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.requestsdb; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.mso.HealthCheckUtils; -import org.openecomp.mso.logger.MsoLogger; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import javax.ws.rs.core.Response; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(HealthCheckHandler.class) -public class HealthCheckHandlerTest { - - HealthCheckHandler hcH; - - @Before - public void init(){ - - hcH = new HealthCheckHandler(); - } - - @Test - public void testNoServiceResp() { - - HealthCheckUtils test = PowerMockito.mock(HealthCheckUtils.class); - try { - PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(test); - when(test.siteStatusCheck(any(MsoLogger.class))).thenReturn(true); - - } catch (Exception e) { - e.printStackTrace(); - } - Response response = hcH.healthcheck("request"); - assertEquals(503,response.getStatus()); - } - -} - - diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java deleted file mode 100644 index 506b3bd95f..0000000000 --- a/adapters/mso-requests-db-adapter/src/test/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImplTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.adapters.requestsdb; - -import org.junit.Test; - -public class MsoRequestsDbAdapterImplTest { - - // TODO: following test case is done for coverage - // later it should be modified for proper test. - MsoRequestsDbAdapterImpl msoRequestsDbAdapter = new MsoRequestsDbAdapterImpl(); - - @Test(expected = NullPointerException.class) - public void updateInfraRequest() throws Exception { - msoRequestsDbAdapter.updateInfraRequest("test", "test", - "test", "test", RequestStatusType.COMPLETE, "test", - "test", "test", "test", "test", - "test", "test", "test", - "test", "test", "tets"); - } - - @Test(expected = NullPointerException.class) - public void getInfraRequest() throws Exception { - msoRequestsDbAdapter.getInfraRequest("test"); - } - - @Test(expected = NullPointerException.class) - public void getSiteStatus() throws Exception { - msoRequestsDbAdapter.getSiteStatus("test"); - } - - @Test(expected = NullPointerException.class) - public void updateServiceOperationStatus() throws Exception { - msoRequestsDbAdapter.updateServiceOperationStatus("test", "test", - "test", "test", "test", "test", - "test", "test"); - } - - @Test(expected = NullPointerException.class) - public void initResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.initResourceOperationStatus("test", "test", "test", "uuid"); - } - - @Test(expected = NullPointerException.class) - public void getResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.getResourceOperationStatus("test", "test", "uuid"); - } - - @Test(expected = NullPointerException.class) - public void updateResourceOperationStatus() throws Exception { - msoRequestsDbAdapter.updateResourceOperationStatus("test", "test", - "uuid", "type", "instance-id", - "jobid", "test", "progress", "errorcode", - "status-desc"); - } - -}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..c3be9323fb --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml @@ -0,0 +1,52 @@ +# will be used as entry in DB to say SITE OFF/ON for healthcheck + +server: + port: 8080 + tomcat: + max-threads: 50 +ssl-enable: false +mso: + logPath: logs + site-name: localSite + infra-requests: + archived: + period: 1 +spring: + datasource: + url: jdbc:mariadb://localhost:3307/requestdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client +mariaDB4j: + dataDir: + port: 3307 + databaseName: requestdb + +#Actuator +management: + security: + enabled: false + basic: + enabled: false + +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3307/requestdb + user: root + password: password diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql new file mode 100644 index 0000000000..ec02ac0734 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -0,0 +1,32 @@ +use requestdb; + +insert into operation_status(service_id, operation_id, service_name, user_id, result, operation_content, progress, reason, operate_at, finished_at) values +('serviceid', 'operationid', 'servicename', 'userid', 'result', 'operationcontent', 'progress', 'reason', '2016-11-24 13:19:10', '2016-11-24 13:19:10'); + + +insert into infra_active_requests(request_id, client_request_id, action, request_status, status_message, progress, start_time, end_time, source, vnf_id, vnf_name, vnf_type, service_type, aic_node_clli, tenant_id, prov_status, vnf_params, vnf_outputs, request_body, response_body, last_modified_by, modify_time, request_type, volume_group_id, volume_group_name, vf_module_id, vf_module_name, vf_module_model_name, aai_service_id, aic_cloud_region, callback_url, correlator, network_id, network_name, network_type, request_scope, request_action, service_instance_id, service_instance_name, requestor_id, configuration_id, configuration_name, operational_env_id, operational_env_name) values +('00032ab7-3fb3-42e5-965d-8ea592502017', '00032ab7-3fb3-42e5-965d-8ea592502016', 'deleteInstance', 'COMPLETE', 'Vf Module has been deleted successfully.', '100', '2016-12-22 18:59:54', '2016-12-22 19:00:28', 'VID', 'b92f60c8-8de3-46c1-8dc1-e4390ac2b005', null, null, null, null, '6accefef3cb442ff9e644d589fb04107', null, null, null, '{"requestDetails":{"modelInfo":{"modelType":"vfModule","modelName":"vSAMP10aDEV::base::module-0"},"requestInfo":{"source":"VID"},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"mtn6"}}}', null, 'BPMN', '2016-12-22 19:00:28', null, null, null, 'c7d527b1-7a91-49fd-b97d-1c8c0f4a7992', null, 'vSAMP10aDEV::base::module-0', null, 'mtn6', null, null, null, null, null, 'vfModule', 'deleteInstance', 'e3b5744d-2ad1-4cdd-8390-c999a38829bc', null, null, null, null, null, null), +('00093944-bf16-4373-ab9a-3adfe730ff2d', null, 'createInstance', 'FAILED', 'Error: Locked instance - This service (MSODEV_1707_SI_vSAMP10a_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.', '100', '2017-07-11 18:33:26', '2017-07-11 18:33:26', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671","modelType":"service","modelName":"MSOTADevInfra_vSAMP10a_Service","modelVersion":"1.0","modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","instanceName":"MSODEV_1707_SI_vSAMP10a_011-4","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarteSet":true,"alaCarte":true}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', null, 'MSODEV_1707_SI_vSAMP10a_011-4', 'xxxxxx', null, null, null, null), +('001619d2-a297-4a4b-a9f5-e2823c88458f', '001619d2-a297-4a4b-a9f5-e2823c88458f', 'CREATE_VF_MODULE', 'COMPLETE', 'COMPLETED', '100', '2016-07-01 14:11:42', '2017-05-02 16:03:34', 'PORTAL', null, 'test-vscp', 'elena_test21', null, null, '381b9ff6c75e4625b7a4182f90fc68d3', null, null, null, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vnf-request xmlns=\"http://org.onap.so/mso/infra/vnf-request/v1\">\n <request-info>\n <request-id>001619d2-a297-4a4b-a9f5-e2823c88458f</request-id>\n <action>CREATE_VF_MODULE</action>\n <source>PORTAL</source>\n </request-info>\n <vnf-inputs>\n <vnf-name>test-vscp</vnf-name>\n <vf-module-name>moduleName</vf-module-name>\n <vnf-type>elena_test21</vnf-type>\n <vf-module-model-name>moduleModelName</vf-module-model-name>\n <asdc-service-model-version>1.0</asdc-service-model-version>\n <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>\n <aic-cloud-region>mtn9</aic-cloud-region>\n <tenant-id>381b9ff6c75e4625b7a4182f90fc68d3</tenant-id>\n <persona-model-id></persona-model-id>\n <persona-model-version></persona-model-version>\n <is-base-vf-module>false</is-base-vf-module>\n </vnf-inputs>\n <vnf-params xmlns:tns=\"http://org.onap.so/mso/infra/vnf-request/v1\"/>\n</vnf-request>\n', 'NONE', 'RDBTEST', '2016-07-01 14:11:42', 'VNF', null, null, null, 'MODULENAME1', 'moduleModelName', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb', 'mtn9', null, null, null, null, null, 'vfModule', 'createInstance', null, null, null, null, null, null, null), +('00164b9e-784d-48a8-8973-bbad6ef818ed', null, 'createInstance', 'COMPLETE', 'Service Instance was created successfully.', '100', '2017-09-28 12:45:51', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"requestDetails":{"requestDetails":{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelNameVersionId":null,"modelName":"MSO Test Network","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":"DEV-MTN6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":null,"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"aicNodeClli":null,"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":true},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}}}', null, 'CreateGenericALaCarteServiceInstance', '2017-09-28 12:45:52', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', 'b2f59173-b7e5-4e0f-8440-232fd601b865', 'DEV-MTN6-3100-0927-1', 'xxxxxx', null, null, null, null), +('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request. No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null), +('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, null, null, null, null, '{"requestDetails":{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null); + +insert into watchdog_distributionid_status(distribution_id, distribution_id_status, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + +insert into watchdog_per_component_distribution_status(distribution_id, component_name, component_distribution_status, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', 'MSO', 'COMPONENT_DONE_ERROR', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + +insert into watchdog_service_mod_ver_id_lookup(distribution_id, service_model_version_id, create_time, modify_time) values +('1533c4bd-a3e3-493f-a16d-28c20614415e', '7e813ab5-88d3-4fcb-86c0-498c5d7eef9a', '2017-11-30 15:48:08', '2017-11-30 15:48:08'), +('55429711-809b-4a3b-9ee5-5120d46d9de0', 'cc031e75-4442-4d1a-b774-8a2b434e0a50', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), +('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'eade1e9d-c1ec-4ef3-bc31-60570fba1573', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); + + +insert into site_status(site_name, status, creation_timestamp) values +('testsite', 0, '2017-11-30 15:48:09');
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..54fa1cdd65 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,33 @@ +<configuration> + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <logger name="org.flywaydb" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl b/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl new file mode 100644 index 0000000000..b22acdae75 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/resources/wsdl/MsoRequestsDbAdapterImpl.wsdl @@ -0,0 +1,295 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions name="RequestsDbAdapter" targetNamespace="http://org.onap.so/requestsdb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://org.onap.so/requestsdb" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> + <wsdl:types> +<xs:schema xmlns:tns="http://org.onap.so/requestsdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://org.onap.so/requestsdb"> + <xs:element name="getInfraRequest" type="tns:getInfraRequest"/> + <xs:element name="getInfraRequestResponse" type="tns:getInfraRequestResponse"/> + <xs:element name="getSiteStatus" type="tns:getSiteStatus"/> + <xs:element name="getSiteStatusResponse" type="tns:getSiteStatusResponse"/> + <xs:element name="initResourceOperationStatus" type="tns:initResourceOperationStatus"/> + <xs:element name="initResourceOperationStatusResponse" type="tns:initResourceOperationStatusResponse"/> + <xs:element name="updateInfraRequest" type="tns:updateInfraRequest"/> + <xs:element name="updateInfraRequestResponse" type="tns:updateInfraRequestResponse"/> + <xs:element name="updateServiceOperationStatus" type="tns:updateServiceOperationStatus"/> + <xs:element name="updateServiceOperationStatusResponse" type="tns:updateServiceOperationStatusResponse"/> + <xs:complexType name="getInfraRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getInfraRequestResponse"> + <xs:sequence> + <xs:element minOccurs="0" name="return" type="tns:infraActiveRequests"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="infraActiveRequests"> + <xs:sequence> + <xs:element minOccurs="0" name="aaiServiceId" type="xs:string"/> + <xs:element minOccurs="0" name="action" type="xs:string"/> + <xs:element minOccurs="0" name="aicCloudRegion" type="xs:string"/> + <xs:element minOccurs="0" name="aicNodeClli" type="xs:string"/> + <xs:element minOccurs="0" name="callBackUrl" type="xs:string"/> + <xs:element minOccurs="0" name="clientRequestId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationName" type="xs:string"/> + <xs:element minOccurs="0" name="correlator" type="xs:string"/> + <xs:element minOccurs="0" name="endTime" type="xs:long"/> + <xs:element minOccurs="0" name="lastModifiedBy" type="xs:string"/> + <xs:element minOccurs="0" name="networkId" type="xs:string"/> + <xs:element minOccurs="0" name="networkName" type="xs:string"/> + <xs:element minOccurs="0" name="networkType" type="xs:string"/> + <xs:element minOccurs="0" name="operationalEnvId" type="xs:string"/> + <xs:element minOccurs="0" name="operationalEnvName" type="xs:string"/> + <xs:element minOccurs="0" name="progress" type="xs:long"/> + <xs:element minOccurs="0" name="provStatus" type="xs:string"/> + <xs:element minOccurs="0" name="requestAction" type="xs:string"/> + <xs:element minOccurs="0" name="requestBody" type="xs:string"/> + <xs:element minOccurs="0" name="requestId" type="xs:string"/> + <xs:element minOccurs="0" name="requestScope" type="xs:string"/> + <xs:element minOccurs="0" name="requestStatus" type="xs:string"/> + <xs:element minOccurs="0" name="requestType" type="xs:string"/> + <xs:element minOccurs="0" name="requestorId" type="xs:string"/> + <xs:element minOccurs="0" name="responseBody" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceId" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceName" type="xs:string"/> + <xs:element minOccurs="0" name="serviceType" type="xs:string"/> + <xs:element minOccurs="0" name="source" type="xs:string"/> + <xs:element minOccurs="0" name="startTime" type="xs:long"/> + <xs:element minOccurs="0" name="statusMessage" type="xs:string"/> + <xs:element minOccurs="0" name="tenantId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleModelName" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleName" type="xs:string"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="vnfName" type="xs:string"/> + <xs:element minOccurs="0" name="vnfOutputs" type="xs:string"/> + <xs:element minOccurs="0" name="vnfParams" type="xs:string"/> + <xs:element minOccurs="0" name="vnfType" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupId" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="msoRequestsDbExceptionBean"> + <xs:sequence> + <xs:element minOccurs="0" name="message" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getSiteStatus"> + <xs:sequence> + <xs:element name="siteName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="getSiteStatusResponse"> + <xs:sequence> + <xs:element name="return" type="xs:boolean"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateInfraRequest"> + <xs:sequence> + <xs:element name="requestId" type="xs:string"/> + <xs:element name="lastModifiedBy" type="xs:string"/> + <xs:element minOccurs="0" name="statusMessage" type="xs:string"/> + <xs:element minOccurs="0" name="responseBody" type="xs:string"/> + <xs:element minOccurs="0" name="requestStatus" type="tns:request-status-type"/> + <xs:element minOccurs="0" name="progress" type="xs:string"/> + <xs:element minOccurs="0" name="vnfOutputs" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceId" type="xs:string"/> + <xs:element minOccurs="0" name="networkId" type="xs:string"/> + <xs:element minOccurs="0" name="vnfId" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleId" type="xs:string"/> + <xs:element minOccurs="0" name="volumeGroupId" type="xs:string"/> + <xs:element minOccurs="0" name="serviceInstanceName" type="xs:string"/> + <xs:element minOccurs="0" name="configurationId" type="xs:string"/> + <xs:element minOccurs="0" name="configurationName" type="xs:string"/> + <xs:element minOccurs="0" name="vfModuleName" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateInfraRequestResponse"> + <xs:sequence/> + </xs:complexType> + <xs:complexType name="initResourceOperationStatus"> + <xs:sequence> + <xs:element name="serviceId" type="xs:string"/> + <xs:element name="operationId" type="xs:string"/> + <xs:element name="operationType" type="xs:string"/> + <xs:element name="resourceTemplateUUIDs" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="initResourceOperationStatusResponse"> + <xs:sequence/> + </xs:complexType> + <xs:complexType name="updateServiceOperationStatus"> + <xs:sequence> + <xs:element name="serviceId" type="xs:string"/> + <xs:element minOccurs="0" name="operationId" type="xs:string"/> + <xs:element minOccurs="0" name="operationType" type="xs:string"/> + <xs:element minOccurs="0" name="userId" type="xs:string"/> + <xs:element minOccurs="0" name="result" type="xs:string"/> + <xs:element minOccurs="0" name="operationContent" type="xs:string"/> + <xs:element minOccurs="0" name="progress" type="xs:string"/> + <xs:element minOccurs="0" name="reason" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="updateServiceOperationStatusResponse"> + <xs:sequence/> + </xs:complexType> + <xs:simpleType name="request-status-type"> + <xs:restriction base="xs:string"> + <xs:enumeration value="COMPLETE"/> + <xs:enumeration value="FAILED"/> + <xs:enumeration value="IN_PROGRESS"/> + </xs:restriction> + </xs:simpleType> + <xs:element name="MsoRequestsDbException" nillable="true" type="tns:msoRequestsDbExceptionBean"/> +</xs:schema> + </wsdl:types> + <wsdl:message name="getInfraRequest"> + <wsdl:part name="parameters" element="tns:getInfraRequest"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getSiteStatus"> + <wsdl:part name="parameters" element="tns:getSiteStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateServiceOperationStatus"> + <wsdl:part name="parameters" element="tns:updateServiceOperationStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateServiceOperationStatusResponse"> + <wsdl:part name="parameters" element="tns:updateServiceOperationStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="MsoRequestsDbException"> + <wsdl:part name="MsoRequestsDbException" element="tns:MsoRequestsDbException"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateInfraRequest"> + <wsdl:part name="parameters" element="tns:updateInfraRequest"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="updateInfraRequestResponse"> + <wsdl:part name="parameters" element="tns:updateInfraRequestResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="initResourceOperationStatus"> + <wsdl:part name="parameters" element="tns:initResourceOperationStatus"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="initResourceOperationStatusResponse"> + <wsdl:part name="parameters" element="tns:initResourceOperationStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getSiteStatusResponse"> + <wsdl:part name="parameters" element="tns:getSiteStatusResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:message name="getInfraRequestResponse"> + <wsdl:part name="parameters" element="tns:getInfraRequestResponse"> + </wsdl:part> + </wsdl:message> + <wsdl:portType name="RequestsDbAdapter"> + <wsdl:operation name="getInfraRequest"> + <wsdl:input name="getInfraRequest" message="tns:getInfraRequest"> + </wsdl:input> + <wsdl:output name="getInfraRequestResponse" message="tns:getInfraRequestResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="getSiteStatus"> + <wsdl:input name="getSiteStatus" message="tns:getSiteStatus"> + </wsdl:input> + <wsdl:output name="getSiteStatusResponse" message="tns:getSiteStatusResponse"> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="updateInfraRequest"> + <wsdl:input name="updateInfraRequest" message="tns:updateInfraRequest"> + </wsdl:input> + <wsdl:output name="updateInfraRequestResponse" message="tns:updateInfraRequestResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="initResourceOperationStatus"> + <wsdl:input name="initResourceOperationStatus" message="tns:initResourceOperationStatus"> + </wsdl:input> + <wsdl:output name="initResourceOperationStatusResponse" message="tns:initResourceOperationStatusResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="updateServiceOperationStatus"> + <wsdl:input name="updateServiceOperationStatus" message="tns:updateServiceOperationStatus"> + </wsdl:input> + <wsdl:output name="updateServiceOperationStatusResponse" message="tns:updateServiceOperationStatusResponse"> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException" message="tns:MsoRequestsDbException"> + </wsdl:fault> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="RequestsDbAdapterSoapBinding" type="tns:RequestsDbAdapter"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getInfraRequest"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="getInfraRequest"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getInfraRequestResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="getSiteStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="getSiteStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getSiteStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="updateInfraRequest"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="updateInfraRequest"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="updateInfraRequestResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="initResourceOperationStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="initResourceOperationStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="initResourceOperationStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="updateServiceOperationStatus"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="updateServiceOperationStatus"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="updateServiceOperationStatusResponse"> + <soap:body use="literal"/> + </wsdl:output> + <wsdl:fault name="MsoRequestsDbException"> + <soap:fault name="MsoRequestsDbException" use="literal"/> + </wsdl:fault> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="RequestsDbAdapter"> + <wsdl:port name="MsoRequestsDbAdapterImplPort" binding="tns:RequestsDbAdapterSoapBinding"> + <soap:address location="http://localhost:9090/MsoRequestsDbAdapterImplPort"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> |