diff options
Diffstat (limited to 'openecomp-be/api')
3 files changed, 58 insertions, 31 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java index 4f5e31aaaf..cb3abeebc2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 @@ -15,7 +12,6 @@ * 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.sdcrests.vsp.rest; @@ -32,6 +28,7 @@ import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; @@ -76,6 +73,14 @@ public interface OrchestrationTemplateCandidate extends VspEntities { @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; + @DELETE + @Path("/") + @ApiOperation(value = "Delete orchestration template candidate file and its files data structure") + Response abort( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId) + throws Exception; + @PUT @Path("/process") @ApiOperation(value = "process Orchestration Template Candidate", @@ -106,5 +111,4 @@ public interface OrchestrationTemplateCandidate extends VspEntities { @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java index e6be1dcbe9..d856cfc6e5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.beanutils.BeanUtils; @@ -11,6 +27,8 @@ import org.openecomp.sdc.activitylog.dao.type.ActivityType; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; @@ -44,6 +62,8 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate private OrchestrationTemplateCandidateManager candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + private VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory + .getInstance().createInterface(); private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); @@ -75,6 +95,12 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate } @Override + public Response abort(String vspId, String versionId) throws Exception { + candidateManager.abort(vspId, new Version(versionId)); + return Response.ok().build(); + } + + @Override public Response process(String vspId, String versionId, String user) throws InvocationTargetException, IllegalAccessException { @@ -121,6 +147,10 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate throws Exception { Optional<FilesDataStructure> filesDataStructure = candidateManager.getFilesDataStructure(vspId, new Version(versionId)); + if (!filesDataStructure.isPresent()) { + filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId, + new Version(versionId)); + } FileDataStructureDto fileDataStructureDto = filesDataStructure.map(dataStructure -> new MapFilesDataStructureToDto() @@ -128,4 +158,5 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate .orElse(new FileDataStructureDto()); return Response.ok(fileDataStructureDto).build(); } + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 7d1c5e1289..09cb0945b1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.util.UniqueValueUtil; -import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.activitylog.ActivityLogManager; import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; @@ -88,8 +87,6 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; import java.io.File; import java.io.IOException; import java.util.Collection; @@ -100,6 +97,8 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; +import javax.inject.Named; +import javax.ws.rs.core.Response; import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; @@ -112,7 +111,6 @@ import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBM import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; - @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") @@ -591,28 +589,22 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) { - OrchestrationTemplateEntity orchestrationTemplateInfo = - vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); - - vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); - vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); - vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix() == null - ? OnboardingTypesEnum.NONE.toString() - : orchestrationTemplateInfo.getFileSuffix()); - OrchestrationTemplateCandidateData candidateInfo = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface() .getInfo(vspId, version); - - //todo - remove after fix missing candidate element - if (candidateInfo == null) { - candidateInfo = new OrchestrationTemplateCandidateData(); - candidateInfo.setFileSuffix("zip"); + if (Objects.nonNull(candidateInfo) && Objects.nonNull(candidateInfo.getFileSuffix())) { + vspDetailsDto.setValidationData(candidateInfo.getValidationDataStructure()); + vspDetailsDto.setNetworkPackageName(candidateInfo.getFileName()); + vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.getFileSuffix()); + } else { + OrchestrationTemplateEntity orchestrationTemplateInfo = + vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); + if (Objects.nonNull(orchestrationTemplateInfo)) { + vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); + vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); + vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix()); + } } - - vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.getFileSuffix() == null - ? OnboardingTypesEnum.NONE.toString() - : candidateInfo.getFileSuffix()); } private boolean userHasPermission(String itemId, String userId) { |