diff options
Diffstat (limited to 'vid-app-common/src/main')
22 files changed, 578 insertions, 312 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java index 89d3963a..b19ea57e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java +++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java @@ -1,5 +1,27 @@ package org.onap.vid.category; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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========================================================= + */ + import org.onap.vid.model.ListOfErrorsResponse; import java.util.List; @@ -9,6 +31,10 @@ public class AddCategoryOptionResponse extends ListOfErrorsResponse { public AddCategoryOptionResponse() { } + public AddCategoryOptionResponse(String error) { + errors.add(error); + } + public AddCategoryOptionResponse(List<String> errors) { super(errors); } diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java index 5db47462..8e9b1442 100644 --- a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java +++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java @@ -1,7 +1,30 @@ package org.onap.vid.category; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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========================================================= + */ + import java.util.ArrayList; import java.util.List; +import java.util.Objects; public class AddCategoryOptionsRequest { @@ -10,4 +33,17 @@ public class AddCategoryOptionsRequest { public AddCategoryOptionsRequest() { options = new ArrayList<>(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + AddCategoryOptionsRequest that = (AddCategoryOptionsRequest) o; + return Objects.equals(this.options, that.options); + } + + @Override + public int hashCode() { + return Objects.hash(this.options); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java index 355e5483..dc0ecba1 100644 --- a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java +++ b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java @@ -1,5 +1,29 @@ package org.onap.vid.category; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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========================================================= + */ + +import java.util.Objects; + public class CategoryParameterOptionRep { private String id; @@ -28,4 +52,18 @@ public class CategoryParameterOptionRep { public void setName(String name) { this.name = name; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CategoryParameterOptionRep that = (CategoryParameterOptionRep) o; + return Objects.equals(this.id, that.id) && + Objects.equals(this.name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.name); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java index 84e83e8b..a3ff5f92 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java @@ -23,6 +23,7 @@ package org.onap.vid.client; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.JsonNode; import io.joshworks.restclient.http.RestClient; +import io.joshworks.restclient.http.exceptions.RestClientException; import io.joshworks.restclient.http.mapper.ObjectMapper; import org.apache.http.impl.client.CloseableHttpClient; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -39,7 +40,7 @@ import java.security.UnrecoverableKeyException; import java.security.NoSuchAlgorithmException; import java.security.KeyManagementException; import java.security.cert.CertificateException; -import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLException; import java.security.KeyStoreException; import java.text.SimpleDateFormat; import javax.net.ssl.SSLContext; @@ -134,6 +135,11 @@ public class SyncRestClient implements SyncRestClientInterface { } @Override + public <T> HttpResponse<T> delete(String url, Map<String, String> headers, Object body, Class<T> responseClass) { + return callWithRetryOverHttp(url, url2 -> restClient.delete(url2).headers(headers).body(body).asObject(responseClass)); + } + + @Override public <T> HttpResponse<T> delete(String url, Map<String, String> headers, Class<T> responseClass) { return callWithRetryOverHttp(url, url2 -> restClient.delete(url2).headers(headers).asObject(responseClass)); } @@ -150,13 +156,13 @@ public class SyncRestClient implements SyncRestClientInterface { @SneakyThrows private <T> HttpResponse<T> callWithRetryOverHttp(String url, - CheckedFunction1<String, HttpResponse<T>> httpRequest) { + CheckedFunction1<String, HttpResponse<T>> httpRequest) { try { return httpRequest.apply(url); - } catch (Exception e) { - if (e.getCause() instanceof SSLHandshakeException) { + } catch (RestClientException e) { + if (e.getCause() instanceof SSLException) { logger.warn(EELFLoggerDelegate.debugLogger, - DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e); + DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e); return httpRequest.apply(url.replaceFirst(HTTPS_SCHEMA, HTTP_SCHEMA)); } throw e; diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientInterface.java index 142adde1..ae2f8386 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientInterface.java @@ -27,6 +27,8 @@ public interface SyncRestClientInterface { <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body, Class<T> aClass); + <T> HttpResponse<T> delete(String url, Map<String, String> headers, Object body, Class<T> aClass); + <T> HttpResponse<T> delete(String url, Map<String, String> headers, Class<T> aClass); HttpResponse<JsonNode> delete(String url, Map<String, String> headers); diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java index 0976f403..1a3eb42f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java @@ -1,6 +1,30 @@ package org.onap.vid.controllers; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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========================================================= + */ + +import static org.onap.vid.utils.Logging.getMethodCallerName; +import javax.ws.rs.ForbiddenException; import org.onap.portalsdk.core.controller.UnRestrictedBaseController; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.category.AddCategoryOptionResponse; @@ -14,124 +38,114 @@ import org.onap.vid.services.CategoryParameterServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.ForbiddenException; -import java.util.Arrays; -import java.util.Collections; - -import static org.onap.vid.utils.Logging.getMethodCallerName; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** * Controler for APIs that are used only by vid operators */ @RestController -@RequestMapping(MaintenanceController.MAINTENANCE) +@RequestMapping("maintenance") public class MaintenanceController extends UnRestrictedBaseController { - public static final String MAINTENANCE = "maintenance"; + private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class); + private CategoryParameterService categoryParameterService; @Autowired - protected CategoryParameterService categoryParameterService; - private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class); + public MaintenanceController(CategoryParameterService categoryParameterService) { + this.categoryParameterService = categoryParameterService; + } /** * Add list of options to one category parameter - * @param request the request - * @return the new option - * @throws Exception the exception */ @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.POST) - public ResponseEntity addCategoryOptions ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody AddCategoryOptionsRequest option) { + public ResponseEntity addCategoryOptions(@PathVariable String categoryName, + @RequestBody AddCategoryOptionsRequest option) { debugStartLog(); try { - AddCategoryOptionResponse response = categoryParameterService.createCategoryParameterOptions(categoryName, option); - HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK; + AddCategoryOptionResponse response = categoryParameterService + .createCategoryParameterOptions(categoryName, option); + HttpStatus httpStatus = response.getErrors().isEmpty() ? HttpStatus.OK : HttpStatus.MULTI_STATUS; debugEndLog(response); - return new ResponseEntity<>(response, httpStatus); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (Exception exception) { + return createResponseWithBody(httpStatus, response); + } catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { + return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage())); + } catch (RuntimeException exception) { LOGGER.error("failed to add option to parameter category " + categoryName, exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.PUT) - public ResponseEntity updateNameForOption ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOptionRep option) { + public ResponseEntity updateNameForOption(@PathVariable String categoryName, + @RequestBody CategoryParameterOptionRep option) { debugStartLog(); try { - AddCategoryOptionResponse response = categoryParameterService.updateCategoryParameterOption(categoryName, option); - HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK; + AddCategoryOptionResponse response = categoryParameterService + .updateCategoryParameterOption(categoryName, option); + HttpStatus httpStatus = response.getErrors().isEmpty() ? HttpStatus.OK : HttpStatus.MULTI_STATUS; debugEndLog(response); - return new ResponseEntity<>(response, httpStatus); - } - catch (ForbiddenException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.FORBIDDEN); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException|CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.CONFLICT); - } - catch (Exception exception) { + return createResponseWithBody(httpStatus, response); + } catch (ForbiddenException exception) { + return createResponseWithBody(HttpStatus.FORBIDDEN, new AddCategoryOptionResponse(exception.getMessage())); + } catch (CategoryParameterServiceImpl.UnfoundedCategoryException | CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) { + return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage())); + + } catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) { + return createResponseWithBody(HttpStatus.CONFLICT, new AddCategoryOptionResponse(exception.getMessage())); + + } catch (RuntimeException exception) { LOGGER.error("failed to update option to parameter category " + categoryName, exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } /** * Gets the owning entity properties. - * @param request the request - * @return the property - * @throws Exception the exception */ @RequestMapping(value = "/category_parameter", method = RequestMethod.GET) - public ResponseEntity getCategoryParameter(HttpServletRequest request, @RequestParam(value="familyName", required = true) Family familyName) { + public ResponseEntity getCategoryParameter(@RequestParam(value = "familyName", required = true) Family familyName) { debugStartLog(); try { CategoryParametersResponse response = categoryParameterService.getCategoryParameters(familyName); debugEndLog(response); - return new ResponseEntity<>(response, HttpStatus.OK); - } - catch (Exception exception) { + return ResponseEntity.ok().body(response); + } catch (RuntimeException exception) { LOGGER.error("failed to retrieve category parameter list from DB.", exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } - /** * Delete option of the category. - * @param request the request - * @throws Exception the exception */ - @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.POST) - public ResponseEntity deleteCategoryOption ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOption option) { + @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.DELETE) + public ResponseEntity deleteCategoryOption(@PathVariable String categoryName, + @RequestBody CategoryParameterOption option) { debugStartLog(); try { categoryParameterService.deleteCategoryOption(categoryName, option); debugEndLog(HttpStatus.OK); - return new ResponseEntity<>(HttpStatus.OK); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Arrays.asList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (Exception exception) { + return ResponseEntity.status(HttpStatus.OK).build(); + } catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { + return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage())); + } catch (RuntimeException exception) { LOGGER.error("failed to add/update owning entity option", exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } + private ResponseEntity createResponseWithBody(HttpStatus status, AddCategoryOptionResponse response) { + return ResponseEntity.status(status).body(response); + } + private void debugStartLog() { LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodCallerName()); } diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java index cee5af69..6685a63d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java +++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java @@ -23,6 +23,7 @@ package org.onap.vid.job.command; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; import io.joshworks.restclient.http.HttpResponse; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.job.Job.JobStatus; import org.onap.vid.job.JobCommand; import org.onap.vid.job.NextCommand; @@ -30,13 +31,13 @@ import org.onap.vid.mso.MsoInterface; import org.onap.vid.mso.rest.AsyncRequestStatus; import org.onap.vid.services.AsyncInstantiationBusinessLogic; import org.onap.vid.services.AuditService; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import javax.inject.Inject; import java.util.Map; +import java.util.Objects; import java.util.UUID; @@ -68,33 +69,38 @@ public class InProgressStatusCommand implements JobCommand { init(jobUuid, requestId); } + InProgressStatusCommand(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic, MsoInterface msoInterface, AuditService auditService, UUID jobUuid, String requestId) { + this(jobUuid, requestId); + this.asyncInstantiationBL = asyncInstantiationBusinessLogic; + this.restMso = msoInterface; + this.auditService = auditService; + } + @Override public NextCommand call() { try { - String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId; + String path = asyncInstantiationBL.getOrchestrationRequestsPath() + "/" + requestId; HttpResponse<AsyncRequestStatus> msoResponse = restMso.get(path, AsyncRequestStatus.class); JobStatus jobStatus; if (msoResponse.getStatus() >= 400 || msoResponse.getBody() == null) { - auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), msoResponse.getBody().toString()); + auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getBody())); LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to get orchestration status for {}. Status code: {}, Body: {}", - requestId, msoResponse.getStatus(), msoResponse.getRawBody().toString()); + requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getRawBody())); return new NextCommand(JobStatus.IN_PROGRESS, this); - } - else { + } else { jobStatus = asyncInstantiationBL.calcStatus(msoResponse.getBody()); } - asyncInstantiationBL.auditMsoStatus(jobUuid,msoResponse.getBody().request); + asyncInstantiationBL.auditMsoStatus(jobUuid, msoResponse.getBody().request); if (jobStatus == JobStatus.FAILED) { asyncInstantiationBL.handleFailedInstantiation(jobUuid); - } - else { + } else { asyncInstantiationBL.updateServiceInfoAndAuditStatus(jobUuid, jobStatus); } //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress @@ -128,5 +134,4 @@ public class InProgressStatusCommand implements JobCommand { return ImmutableMap.of("requestId", requestId); } - } diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java index 9d22b8bf..958fc115 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java +++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java @@ -42,6 +42,7 @@ import org.springframework.stereotype.Component; import javax.inject.Inject; import java.util.Map; +import java.util.Objects; import java.util.UUID; @@ -73,6 +74,14 @@ public class ServiceInstantiationCommand implements JobCommand { init(uuid, serviceInstantiationRequest, userId); } + ServiceInstantiationCommand(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService, MsoInterface msoInterface, + UUID uuid, ServiceInstantiation serviceInstantiation, String userId) { + this(uuid, serviceInstantiation, userId); + this.asyncInstantiationBL = asyncInstantiationBL; + this.auditService = auditService; + this.restMso = msoInterface; + } + @Override public NextCommand call() { RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper ; @@ -81,7 +90,6 @@ public class ServiceInstantiationCommand implements JobCommand { uuid, serviceInstantiationRequest, userId ); } - //Aai return bad response while checking names uniqueness catch (InvalidAAIResponseException exception) { LOGGER.error("Failed to check name uniqueness in AAI. VID will try again later", exception); @@ -116,7 +124,7 @@ public class ServiceInstantiationCommand implements JobCommand { return new NextCommand(jobStatus, new InProgressStatusCommand(uuid, requestId)); } else { auditService.setFailedAuditStatusFromMso(uuid,null, msoResponse.getStatus(), - msoResponse.getBody().toString()); + Objects.toString(msoResponse.getBody())); return handleCommandFailed(); } diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java index 77e1dd2c..59f12f4c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java @@ -33,14 +33,10 @@ public class JobAdapterImpl implements JobAdapter { } @Override - public Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk){ - JobDaoImpl job = new JobDaoImpl(); - job.setStatus(Job.JobStatus.PENDING); - job.setTypeAndData(jobType, ImmutableMap.of( + public Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk) { + JobDaoImpl job = createJob(jobType, templateId, indexInBulk, ImmutableMap.of( "request", request, "userId", userId)); - job.setTemplateId(templateId); - job.setIndexInBulk(indexInBulk); job.setUserId(userId); return job; } @@ -59,14 +55,17 @@ public class JobAdapterImpl implements JobAdapter { List<Job> jobList = new ArrayList<>(count + 1); UUID templateId = UUID.randomUUID(); for (int i = 0; i < count; i++) { - Job child = new JobDaoImpl(); - child.setTypeAndData(jobType, bulkRequest); - child.setStatus(Job.JobStatus.PENDING); - child.setTemplateId(templateId); - child.setIndexInBulk(i); - jobList.add(child); + jobList.add(createJob(jobType, templateId, i, bulkRequest)); } return jobList; } + private JobDaoImpl createJob(JobType jobType, UUID templateId, Integer indexInBulk, Map<String, Object> data) { + JobDaoImpl job = new JobDaoImpl(); + job.setStatus(Job.JobStatus.PENDING); + job.setTypeAndData(jobType, data); + job.setTemplateId(templateId); + job.setIndexInBulk(indexInBulk); + return job; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java index 99824e72..91617ff4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java @@ -1,12 +1,41 @@ package org.onap.vid.model; -//import org.hibernate.annotations.Table; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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========================================================= + */ -import javax.persistence.*; import java.util.HashSet; +import java.util.Objects; import java.util.Set; - -//import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; @Entity @Table(name = "vid_category_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "name")) @@ -72,4 +101,20 @@ public class CategoryParameter extends VidBaseEntity { public void setIdSupported(boolean idSupported) { this.idSupported = idSupported; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CategoryParameter that = (CategoryParameter) o; + return this.idSupported == that.idSupported && + Objects.equals(this.name, that.name) && + Objects.equals(this.family, that.family) && + Objects.equals(this.options, that.options); + } + + @Override + public int hashCode() { + return Objects.hash(this.name, this.idSupported, this.family, this.options); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java index 96fb15a4..0ecb9257 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java @@ -28,7 +28,7 @@ public interface MsoBusinessLogic { MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); - MsoResponseWrapper scaleOutVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); + MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java index d4ca8651..a6226e00 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java @@ -46,7 +46,11 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; import static org.apache.commons.lang.StringUtils.upperCase; import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest; import static org.onap.vid.controllers.MsoController.*; @@ -56,10 +60,14 @@ import static org.onap.vid.utils.Logging.debugRequestDetails; public class MsoBusinessLogicImpl implements MsoBusinessLogic { - public static final String START = " start"; - public static final String RESOURCE_TYPE = "resourceType"; - FeatureManager featureManager; - + static final List<String> DASHBOARD_ALLOWED_TYPES = Stream.of(RequestType.REPLACE_INSTANCE, + RequestType.UPDATE_INSTANCE, + RequestType.APPLY_UPDATED_CONFIG, + RequestType.IN_PLACE_SOFTWARE_UPDATE, + RequestType.SCALE_OUT) + .map(requestType -> requestType.toString().toUpperCase()) + .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + private static final String RESOURCE_TYPE = "resourceType"; /** * The Constant dateFormat. */ @@ -74,16 +82,16 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { private static final String SOURCE_OPERATIONAL_ENVIRONMENT = "VID"; private static final ObjectMapper objectMapper = new ObjectMapper(); /** + * The logger. + */ + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class); + /** * The Mso REST client * This should be replaced with mso client factory. */ private final MsoInterface msoClientInterface; + FeatureManager featureManager; - /** - * The logger. - */ - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class); - @Autowired public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) { this.msoClientInterface = msoClientInterface; @@ -101,34 +109,26 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { // this function should get params from tosca and send them to instance at mso, then return success response. @Override public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) { - String methodName = "createSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createSvcInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); return msoClientInterface.createSvcInstance(msoRequest, endpoint); } @Override - public MsoResponseWrapper createE2eSvcInstance(Object msoRequest){ - String methodName = "createE2eSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE); - + public MsoResponseWrapper createE2eSvcInstance(Object msoRequest) { + logInvocationInDebug("createE2eSvcInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE); return msoClientInterface.createE2eSvcInstance(msoRequest, endpoint); - } + } @Override public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "createVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); return msoClientInterface.createVnf(requestDetails, vnf_endpoint); @@ -136,11 +136,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "createNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createNwInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); return msoClientInterface.createNwInstance(requestDetails, nw_endpoint); @@ -148,11 +146,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "createVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVolumeGroupInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -162,11 +158,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "createVfModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVfModuleInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -175,22 +169,24 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override - public MsoResponseWrapper scaleOutVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "scaleOutVfModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + public MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { + logInvocationInDebug("scaleOutVfModuleInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT); String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + RequestDetailsWrapper wrapper = new RequestDetailsWrapper(); + requestDetails.setVnfName(null); + requestDetails.setVnfInstanceId(null); + wrapper.requestDetails = requestDetails; - return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint); + return msoClientInterface.scaleOutVFModuleInstance(wrapper, vf_module_endpoint); } + @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) { - String methodName = "createConfigurationInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createConfigurationInstance"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -200,24 +196,21 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String serviceInstanceId) { - String methodName = "deleteE2eSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteE2eSvcInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId; + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId; return msoClientInterface.deleteE2eSvcInstance(requestDetails, endpoint); } @Override public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus) { - String methodName = "deleteSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteSvcInstance"); String endpoint; - if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)){ + if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)) { endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE); - if (shouldUnassignService(serviceStatus)){ + if (shouldUnassignService(serviceStatus)) { logger.debug(EELFLoggerDelegate.debugLogger, "unassign service"); String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign"; return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint); @@ -231,16 +224,14 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } private boolean shouldUnassignService(String serviceStatus) { - return ImmutableList.of("created","pendingdelete","pending-delete", "assigned").contains(serviceStatus.toLowerCase()); + return ImmutableList.of("created", "pendingdelete", "pending-delete", "assigned").contains(serviceStatus.toLowerCase()); } @Override public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "deleteVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId; @@ -249,14 +240,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) { - String methodName = "deleteVfModule"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + logInvocationInDebug("deleteVfModule"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId; return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint); @@ -264,12 +251,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) { - String methodName = "deleteVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + logInvocationInDebug("deleteVolumeGroupInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId; @@ -279,12 +263,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) { - String methodName = "deleteNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + logInvocationInDebug("deleteNwInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId; @@ -294,7 +275,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper getOrchestrationRequest(String requestId) { String methodName = "getOrchestrationRequest"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ); String path = p + "/" + requestId; @@ -302,8 +283,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.getOrchestrationRequest(path); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -311,7 +291,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper getOrchestrationRequests(String filterString) { String methodName = "getOrchestrationRequest"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); String path = p + filterString; @@ -319,8 +299,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.getOrchestrationRequest(path); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -328,48 +307,51 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public List<Request> getOrchestrationRequestsForDashboard() { String methodName = "getOrchestrationRequestsForDashboard"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - List<Request> filteredOrchestrationRequests = new ArrayList<>(); - try { - String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); - path += "filter=modelType:EQUALS:vnf"; - RestObject<String> restObjStr = new RestObject<>(); - String str = new String(); - restObjStr.set(str); + logInvocationInDebug(methodName); - MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr); - List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity()); - - final ImmutableList<String> suppoertedRequestTypes = ImmutableList.of( - RequestType.REPLACE_INSTANCE.toString().toUpperCase(), - RequestType.UPDATE_INSTANCE.toString().toUpperCase(), - RequestType.APPLY_UPDATED_CONFIG.toString().toUpperCase(), - RequestType.IN_PLACE_SOFTWARE_UPDATE.toString().toUpperCase() - ); - - for (RequestWrapper currentRequest : allOrchestrationRequests) { - if (currentRequest.getRequest() != null - && "vnf".equalsIgnoreCase(currentRequest.getRequest().getRequestScope()) - && suppoertedRequestTypes.contains(upperCase(currentRequest.getRequest().getRequestType())) - ) { - filteredOrchestrationRequests.add(currentRequest.getRequest()); - } - } + List<Request> dashboardOrchestrationReqs = new ArrayList<>(); + try { + List<RequestWrapper> vnfOrchestrationReqsWrappers = getOrchestrationRequestsByFilter("modelType", "vnf"); + dashboardOrchestrationReqs = vnfOrchestrationReqsWrappers.stream() + .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest()) + && DASHBOARD_ALLOWED_TYPES.contains(upperCase(reqWrapper.getRequest().getRequestType()))) + .map(RequestWrapper::getRequest) + .collect(Collectors.toList()); + + List<RequestWrapper> scaleOutOrchestrationReqWrappers = getOrchestrationRequestsByFilter("action", "scaleOut"); + List<Request> scaleoutRequests = scaleOutOrchestrationReqWrappers.stream() + .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest())) + .map(RequestWrapper::getRequest) + .collect(Collectors.toList()); + + dashboardOrchestrationReqs.addAll(scaleoutRequests); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); } - return filteredOrchestrationRequests; + return dashboardOrchestrationReqs; + } + + private String constructOrchestrationRequestFilter(String filterName, String filterValue) { + return String.format("%sfilter=%s:EQUALS:%s", + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS), filterName, filterValue); + } + + private List<RequestWrapper> getOrchestrationRequestsByFilter(String filterName, String filterValue) { + String orchestrationReqPath = constructOrchestrationRequestFilter(filterName, filterValue); + RestObject<String> restObjStr = new RestObject<>(); + String str = new String(); + restObjStr.set(str); + MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", orchestrationReqPath, restObjStr); + return deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity()); } private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) { - String methodName = "deserializeOrchestrationRequestsJson"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deserializeOrchestrationRequestsJson"); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true); - RequestList requestList = null; + RequestList requestList; try { requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class); } catch (IOException e) { @@ -382,7 +364,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public List<Task> getManualTasksByRequestId(String originalRequestId) { String methodName = "getManualTasksByRequestId"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); @@ -396,15 +378,13 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return deserializeManualTasksJson(msoResponseWrapper.getEntity()); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } private List<Task> deserializeManualTasksJson(String manualTasksJson) { - String methodName = "deserializeManualTasksJson"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deserializeManualTasksJson"); ObjectMapper mapper = new ObjectMapper(); try { @@ -419,7 +399,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) { String methodName = "completeManualTask"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); String path = p + "/" + taskId + "/complete"; @@ -433,8 +413,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return MsoUtil.wrapResponse(restObjStr); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -442,7 +421,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { String methodName = "activateServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + ACTIVATE; @@ -456,8 +435,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return MsoUtil.wrapResponse(restObjStr); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -465,8 +443,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnf"); String endpoint; endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); @@ -477,11 +454,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "replaceVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("replaceVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, MsoChangeManagementRequest.REPLACE); @@ -502,22 +477,17 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) { validateUpdateVnfConfig(requestDetails); - RequestDetails ConfigUpdateRequest = new RequestDetails(); - ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); - ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); + RequestDetails configUpdateRequest = new RequestDetails(); + configUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); + configUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - requestDetailsWrapper.requestDetails = ConfigUpdateRequest; + requestDetailsWrapper.requestDetails = configUpdateRequest; return requestDetailsWrapper; } - - - - @Override public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnfSoftware"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnfSoftware"); String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails); return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); @@ -525,30 +495,28 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnfConfig"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnfConfig"); RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails); String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE); return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); } private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) { - String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType); return vnf_endpoint; } - private Map getChangeManagementPayload(RequestDetails requestDetails, String message){ - if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){ + private Map getChangeManagementPayload(RequestDetails requestDetails, String message) { + if (requestDetails.getRequestParameters() == null || requestDetails.getRequestParameters().getAdditionalProperties() == null) { throw new BadRequestException(message); } - Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); - try{ - return objectMapper.readValue((String)payloadRaw,Map.class); - } - catch(Exception exception){ + Object payloadRaw = requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); + try { + return objectMapper.readValue((String) payloadRaw, Map.class); + } catch (Exception exception) { throw new BadRequestException(message); } } @@ -577,30 +545,12 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } } - private void validateUpdateVnfConfig(RequestDetails requestDetails) { - final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request"; - - Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); - validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters"); - validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters"); - } - - private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) { - final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid"; - if(!payload.containsKey(propertyName)) { - throw new BadRequestException( noValidPayloadPropertyMsg); - } - } - @Override - public MsoResponseWrapper deleteConfiguration( - org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, - String serviceInstanceId, - String configurationId) { - - String methodName = "deleteConfiguration"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + public MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, + String serviceInstanceId, + String configurationId) { + logInvocationInDebug("deleteConfiguration"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); endpoint = endpoint.replace(CONFIGURATION_ID, configurationId); @@ -615,8 +565,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String configurationId, boolean isActivate) { - String methodName = "setConfigurationActiveStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("setConfigurationActiveStatus"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -629,9 +578,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override - public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate) { + public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails, String serviceInstanceId, boolean isActivate) { + logInvocationInDebug("setServiceInstanceStatus"); String methodName = "setServiceInstanceStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); try { String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); String endpoint = serviceEndpoint + "/" + serviceInstanceId; @@ -644,7 +593,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String str = ""; restObjStr.set(str); - msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr); + msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", endpoint, restObjStr); return MsoUtil.wrapResponse(restObjStr); @@ -661,8 +610,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String serviceInstanceId, String configurationId, boolean isEnable) { - String methodName = "setPortOnConfigurationStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("setPortOnConfigurationStatus"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -676,7 +624,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override - public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) { + public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) { RequestDetails requestDetails = new RequestDetails(); RequestInfo requestInfo = new RequestInfo(); requestInfo.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT); @@ -750,7 +698,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } - @Override public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) { OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo( @@ -779,8 +726,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "removeRelationshipFromServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("removeRelationshipFromServiceInstance"); String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships"; @@ -790,8 +736,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "addRelationshipToServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("addRelationshipToServiceInstance"); String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships"; @@ -799,8 +744,31 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath); } + private void validateUpdateVnfConfig(RequestDetails requestDetails) { + final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request"; - public enum RequestType { + Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters"); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters"); + } + + private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) { + final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid"; + if (!payload.containsKey(propertyName)) { + throw new BadRequestException(noValidPayloadPropertyMsg); + } + } + + private void logInvocationInDebug(String methodName) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + } + + private void logException(String methodName, Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + } + + enum RequestType { CREATE_INSTANCE("createInstance"), DELETE_INSTANCE("deleteInstance"), @@ -810,27 +778,23 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { DEACTIVATE_INSTANCE("deactivateInstance"), APPLY_UPDATED_CONFIG("applyUpdatedConfig"), IN_PLACE_SOFTWARE_UPDATE("inPlaceSoftwareUpdate"), + SCALE_OUT("scaleOut"), UNKNOWN("unknown"), NOT_PROVIDED("not provided"); - private final String value; private static final Map<String, RequestType> CONSTANTS = new HashMap<>(); static { - for (RequestType c: values()) { + for (RequestType c : values()) { CONSTANTS.put(c.value, c); } } + private final String value; + RequestType(String value) { this.value = value; } - @JsonValue - @Override - public String toString() { - return this.value; - } - @JsonCreator public static RequestType fromValue(String value) { RequestType constant = CONSTANTS.get(value); @@ -840,5 +804,11 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return constant; } } + + @JsonValue + @Override + public String toString() { + return this.value; + } } }
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java index 3cba12f6..834f8088 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java @@ -74,6 +74,8 @@ public interface MsoInterface { MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint); + MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint); + MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint); MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java index 9cac3e4e..37600f7b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java @@ -124,6 +124,14 @@ public class MsoRestClientNew implements MsoInterface { } @Override + public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) { + String methodName = "scaleOutVFModuleInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + String path = baseUrl + endpoint; + return createInstance(requestDetailsWrapper, path); + } + + @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) { String methodName = "createConfigurationInstance"; logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); @@ -478,7 +486,7 @@ public class MsoRestClientNew implements MsoInterface { try { logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); - HttpResponse<String> response = client.delete(path, commonHeaders, String.class); + HttpResponse<String> response = client.delete(path, commonHeaders, request, String.class); MsoResponseWrapper w = MsoUtil.wrapResponse(response); logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetailsWrapper.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetailsWrapper.java index 0e320a35..20c84422 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetailsWrapper.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetailsWrapper.java @@ -1,5 +1,34 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * Modifications Copyright (C) 2018 Nokia. 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.vid.mso.rest; -public class RequestDetailsWrapper { - public RequestDetails requestDetails; +public final class RequestDetailsWrapper { + + private final RequestDetails requestDetails; + + public RequestDetailsWrapper(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java index 13db1ae9..b4806f1c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. 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.vid.services; import com.fasterxml.jackson.core.JsonParseException; @@ -16,12 +36,12 @@ public class AuditServiceImpl implements AuditService{ @Inject private AsyncInstantiationBusinessLogic asyncInstantiationBL; + public static final String FAILED_MSO_REQUEST_STATUS = "FAILED"; @Override public void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse){ - final String failedMsoRequestStatus = "FAILED"; String additionalInfo = formatExceptionAdditionalInfo(statusCode, msoResponse); - asyncInstantiationBL.auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo); + asyncInstantiationBL.auditMsoStatus(jobUuid, FAILED_MSO_REQUEST_STATUS, requestId, additionalInfo); } private String formatExceptionAdditionalInfo(int statusCode, String msoResponse) { diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java index fa531ffc..b3d20a62 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. 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.vid.services; import org.onap.vid.category.AddCategoryOptionResponse; @@ -20,6 +40,7 @@ import java.util.stream.Collectors; @Service public class CategoryParameterServiceImpl implements CategoryParameterService { + public static final String OPTION_ALREADY_EXIST_FOR_CATEGORY = "Option %s already exist for category %s"; @Autowired private DataAccessService dataAccessService; @@ -68,7 +89,7 @@ public class CategoryParameterServiceImpl implements CategoryParameterService { Set<String> categoryOptions = categoryParameter.getOptions().stream().map(CategoryParameterOption::getName).collect(Collectors.toSet()); for (String optionName : optionsRequest.options) { if (categoryOptions.contains(optionName)) { - response.getErrors().add(String.format("Option %s already exist for category %s", optionName, categoryName)); + response.getErrors().add(String.format(OPTION_ALREADY_EXIST_FOR_CATEGORY, optionName, categoryName)); continue; } String appId = categoryParameter.isIdSupported() ? UUID.randomUUID().toString() : optionName; diff --git a/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java index 21b1ec1c..231b3522 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. 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.vid.services; import org.onap.vid.aai.PombaClientInterface; diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java index dc2541b3..1890a5b3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. 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.vid.services; import com.google.common.cache.CacheBuilder; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index 89660fb1..aee4c05f 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -190,7 +190,7 @@ DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));
$scope.createType = COMPONENT.A_LA_CARTE;
var broadcastType = COMPONENT.CREATE_COMPONENT;
- if (AsdcService.isMacro(serviceModel)) {
+ if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {
DataService.setALaCarte(false);
if(AsdcService.shouldExcludeMacroFromAsyncInstatiationFlow(serviceModel)){
DataService.setShouldExcludeMacroFromAsyncInstatiationFlow(true);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index f1440fc3..6029ed2d 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -269,11 +269,15 @@ var data; if(workflowType=="VNF Scale Out") { data = { + vnfName: vnf.name, + vnfInstanceId: vnf.id, modelInfo: { modelType: 'vfModule', modelInvariantId: moduleToScale.invariantUuid, modelName: moduleToScale.modelCustomizationName, modelVersion: moduleToScale.version, + modelCustomizationName: moduleToScale.modelCustomizationName, + modelCustomizationId: moduleToScale.customizationUuid, modelVersionId: moduleToScale.uuid }, cloudConfiguration: vnf.cloudConfiguration, @@ -335,6 +339,7 @@ var relatedInstance = { instanceId: vnf.id, modelInfo: { + modelCustomizationId: vnf.availableVersions[0].modelInfo.modelCustomizationId, modelCustomizationName: vnf.availableVersions[0].modelInfo.modelCustomizationName, modelInvariantId: vnf.availableVersions[0].modelInfo.modelInvariantId, modelName: vnf.availableVersions[0].modelInfo.modelName, @@ -377,18 +382,8 @@ //no scheduling support var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement); if(dataToSo) { - - if(vm.changeManagement.workflow==="VNF Scale Out") { - dataToSo = JSON.parse(dataToSo); - dataToSo = {requestDetails: dataToSo.requestDetails[0]}; - changeManagementService.postChangeManagementScaleOutNow(dataToSo, - vm.changeManagement.vnfNames[0]["service-instance-node"][0].properties["service-instance-id"], - vm.changeManagement.vnfNames[0].id); - }else{ - //TODO: foreach - var vnfName = vm.changeManagement.vnfNames[0].name; - changeManagementService.postChangeManagementNow(dataToSo, vnfName); - } + var vnfName = vm.changeManagement.vnfNames[0].name; + changeManagementService.postChangeManagementNow(dataToSo, vnfName); } } }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js index 753f9fd1..6bdc0ae9 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js @@ -20,7 +20,7 @@ "use strict";
-var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, featureFlags) {
+var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, DataService, featureFlags) {
return {
getModel: function (modelId, successCallbackFunction) {
$log.debug("AsdcService:getModel: modelId: " + modelId);
@@ -37,6 +37,8 @@ var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCON shouldExcludeMacroFromAsyncInstatiationFlow: function(serviceModel){
if (!featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ASYNC_INSTANTIATION))
return true;
+ if (DataService.getE2EService())
+ return true;
if (!_.isEmpty(serviceModel.pnfs))
return true;
if (!_.isEmpty(serviceModel.collectionResource))
@@ -72,4 +74,4 @@ var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCON }
appDS2.factory("AsdcService", ["$http", "$log", "PropertyService",
- "UtilityService", "VIDCONFIGURATION","COMPONENT", "featureFlags", AsdcService]);
+ "UtilityService", "VIDCONFIGURATION","COMPONENT", "DataService", "featureFlags", AsdcService]);
|