diff options
author | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
---|---|---|
committer | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
commit | b8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch) | |
tree | f78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/api | |
parent | 75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff) |
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/api')
118 files changed, 5180 insertions, 322 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..47b9bdde7b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>action-library-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + + <properties> + <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>action-library-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Spring --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.21</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + + + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..4749ce7f8c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>action-library-rest-types</artifactId> + <name>action-library-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <!--<dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency>--> + </dependencies> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..de6c4c6760 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <name>action-library-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modules> + <module>/action-library-rest-services</module> + <module>/action-library-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java index dcbad726ab..6bfd50b401 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java @@ -28,7 +28,7 @@ public enum ActivityType implements Serializable { CHECKOUT("Check Out"), CHECKIN("Check In"), UPLOAD_HEAT("Upload Heat"), - UPLOAD_ARTIFACT("Upload Artifact"), + UPLOAD_MONITORING_FILE("Upload Monitoring File"), SUBMIT("Submit"); // after collaboration will be added - this will be added: diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..9c3472a970 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>application-config-rest-services</artifactId> + <version>1.0-SNAPSHOT</version> + <!--packaging>pom</packaging--> + + <dependencies> + + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-application-config-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-types</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + </dependencies> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..a9c8bbaee5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-types</artifactId> + <version>1.0-SNAPSHOT</version> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..fd2e251fea --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + + <modules> + <module>application-config-rest-services</module> + <module>application-config-rest-types</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml new file mode 100644 index 0000000000..d41c8ef5b3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>healthcheck-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>healthcheck-rest-services</artifactId> + <version>1.1.0-SNAPSHOT</version> + <!--packaging>pom</packaging--> + + <dependencies> + + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-healthcheck-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>healthcheck-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + + </dependencies> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java new file mode 100644 index 0000000000..2ed1d57f8f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.Collection; +import org.openecomp.sdcrests.health.types.HealthInfoDtos; + +@Path("/v1.0/healthcheck") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Health Check") +@Validated +public interface HealthCheck { + + @GET + @ApiOperation(value = "Perform health check", + response = HealthInfoDtos.class, + responseContainer = "List") + Response checkHealth( ); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java new file mode 100644 index 0000000000..8d560027e5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.rest.mapping; + +import org.openecomp.sdc.health.data.HealthInfo; +import org.openecomp.sdcrests.health.types.HealthCheckStatus; +import org.openecomp.sdcrests.health.types.HealthInfoDto; +import org.openecomp.sdcrests.health.types.HealthInfoDtos; +import org.openecomp.sdcrests.health.types.MonitoredModules; +import org.openecomp.sdcrests.mapping.MappingBase; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Created by Talio on 8/10/2016. + */ +public class MapHealthCheckInfoToDto + extends MappingBase<Collection<HealthInfo>, HealthInfoDtos> { + @Override + public void doMapping(Collection<HealthInfo> source, HealthInfoDtos target) { + + List<HealthInfoDto> healthInfos = source.stream() + .map(healthInfo -> new HealthInfoDto( + MonitoredModules.toValue(healthInfo.getHealthCheckComponent().toString()), + HealthCheckStatus.valueOf(healthInfo.getHealthCheckStatus().toString()), + healthInfo.getVersion(), healthInfo.getDescription())).collect(Collectors.toList()); + target.setHealthInfos(healthInfos); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java new file mode 100644 index 0000000000..047adaa25e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.rest.services; + +import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl; +import org.openecomp.sdc.health.HealthCheckManager; +import org.openecomp.sdc.health.HealthCheckManagerFactory; +import org.openecomp.sdc.health.data.HealthCheckResult; +import org.openecomp.sdc.health.data.HealthCheckStatus; +import org.openecomp.sdc.health.data.HealthInfo; +import org.openecomp.sdc.health.data.SiteMode; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdcrests.health.types.HealthInfoDtos; +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.util.Arrays; +import java.util.Collection; + +@Named +@Service("healthCheck") +@Scope(value = "prototype") +public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.HealthCheck { + + private HealthCheckManager healthCheckManager; + private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class); + + public HealthCheckImpl() { + try { + healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface(); + } catch (Exception e){ + logger.error(e.getMessage(),e); + } + } + + @Override + public Response checkHealth() { + HealthCheckResult healthCheckResult = new HealthCheckResult(); + + try { + MdcUtil.initMdc(LoggerServiceName.Health_check.toString()); + Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth(); + healthCheckResult.setComponentsInfo(healthInfos); + boolean someIsDown = healthInfos.stream() + .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)); + healthInfos.stream(). + filter(healthInfo -> healthInfo.getHealthCheckComponent() + .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)). + findFirst().ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion())); + if (someIsDown) { + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + return responseBuilder.entity(healthCheckResult).status(500).build(); + } + return Response.ok(healthCheckResult).build(); + } catch (Exception ex) { + logger.error("Health check failed", ex); + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + GenericCollectionWrapper<HealthInfoDtos> results = new GenericCollectionWrapper<>(); + HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE , + HealthCheckStatus.DOWN, + "", "Failed to perform Health Check"); + Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo); + healthCheckResult.setComponentsInfo(healthInfos); + return responseBuilder.entity(healthCheckResult).status(500).build(); + } + } + + +} + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml new file mode 100644 index 0000000000..2922980d9e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>healthcheck-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>healthcheck-rest-types</artifactId> + <version>1.1.0-SNAPSHOT</version> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java new file mode 100644 index 0000000000..b634a98532 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java @@ -0,0 +1,28 @@ +package org.openecomp.sdcrests.health.types; + + +public enum HealthCheckStatus { + UP("UP"), + DOWN("DOWN"); + + private String name; + + HealthCheckStatus(String name) { + this.name = name; + } + + + @Override + public String toString() { + return name; + } + + public static final HealthCheckStatus toValue(String inVal){ + for (HealthCheckStatus val : values()){ + if (val.toString().equals(inVal)){ + return val; + } + } + return null; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java new file mode 100644 index 0000000000..9ed93cfec7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java @@ -0,0 +1,61 @@ +package org.openecomp.sdcrests.health.types; + + +public class HealthInfoDto { + private MonitoredModules healthCheckComponent; + private HealthCheckStatus healthStatus; + private String version; + private String description; + + public HealthInfoDto() { + } + + public HealthInfoDto(MonitoredModules healthCheckComponent, HealthCheckStatus healthStatus, String version, String description) { + this.healthCheckComponent = healthCheckComponent; + this.healthStatus = healthStatus; + this.version = version; + this.description = description; + } + + public MonitoredModules getHealthCheckComponent() { + return healthCheckComponent; + } + + public void setHealthCheckComponent(MonitoredModules healthCheckComponent) { + this.healthCheckComponent = healthCheckComponent; + } + + public HealthCheckStatus getHealthStatus() { + return healthStatus; + } + + public void setHealthStatus(HealthCheckStatus healthStatus) { + this.healthStatus = healthStatus; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "HealthInfo{" + + "healthCheckComponent='" + healthCheckComponent + '\'' + + ", healthStatus=" + healthStatus + + ", version='" + version + '\'' + + ", description='" + description + '\'' + + '}'; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java new file mode 100644 index 0000000000..e1385d6b80 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java @@ -0,0 +1,31 @@ +package org.openecomp.sdcrests.health.types; + + +import java.util.List; +import java.util.stream.Collectors; + +public class HealthInfoDtos { + private List<HealthInfoDto> healthInfos; + + public HealthInfoDtos() { + } + + public HealthInfoDtos(List<HealthInfoDto> healthInfos) { + this.healthInfos = healthInfos; + } + + public List<HealthInfoDto> getHealthInfos() { + return healthInfos; + } + + public void setHealthInfos(List<HealthInfoDto> healthInfos) { + this.healthInfos = healthInfos; + } + + @Override + public String toString() { + return healthInfos.stream().map(healthInfoDto -> healthInfoDto.toString()) + .collect(Collectors.joining(", ")); + + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java new file mode 100644 index 0000000000..5ecb37a99b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java @@ -0,0 +1,29 @@ +package org.openecomp.sdcrests.health.types; + + +public enum MonitoredModules { + BE("BE"), + CAS("Cassandra"), + ZU("Zusammen"); + + private String name; + + MonitoredModules(String name) { + this.name = name; + } + + + @Override + public String toString() { + return name; + } + + public static final MonitoredModules toValue(String inVal){ + for (MonitoredModules val : values()){ + if (val.toString().equals(inVal)){ + return val; + } + } + return null; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/pom.xml new file mode 100644 index 0000000000..1bb3e98bd0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/pom.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>healthcheck-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + + <modules> + <module>healthcheck-rest-types</module> + <module>healthcheck-rest-services</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml index db4b48600e..b45ee838a3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml @@ -35,6 +35,11 @@ <artifactId>validation-rest-services</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>healthcheck-rest-services</artifactId> + <version>${project.version}</version> + </dependency> <!--dependency> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>application-config-rest-services</artifactId> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup new file mode 100644 index 0000000000..983518fd29 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup @@ -0,0 +1,226 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>onboarding-be</artifactId> + <name>onboarding-rest-war</name> + <version>1.0-SNAPSHOT</version> + <packaging>war</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <!--dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>${project.version}</version> + </dependency--> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>${javax.servlet.version}</version> + </dependency> + <!-- JSON --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>9.0.6.v20130930</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-application-config-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + <version>${groovy.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.janino</groupId> + <artifactId>janino</artifactId> + <scope>compile</scope> + </dependency> + <!--dependency> + <groupId>org.codehaus.janino</groupId> + <artifactId>commons-compiler</artifactId> + <version>3.0.6</version> + <scope>compile</scope> + </dependency--> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>1.8.9</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>1.8.9</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjtools</artifactId> + <version>1.8.9</version> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + <systemProperties> + <property> + <name>buildNumber</name> + <value>${buildNumber}</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.1.1</version> + <configuration> + <attachClasses>true</attachClasses> + <webResources> + <resource> + <!-- this is relative to the pom.xml directory --> + <directory>${basedir}/target/generated/swagger-ui</directory> + </resource> + </webResources> + </configuration> + </plugin> + <plugin> + <groupId>com.github.kongchen</groupId> + <artifactId>swagger-maven-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>false</springmvc> + <locations>org.openecomp.sdcrests</locations> + <schemes>http</schemes> + <basePath>/onboarding-api</basePath> + <info> + <title>Rest API</title> + <version>v1.0, build #${buildNumber}</version> + <description>Rest API Documentation</description> + <termsOfService> + http://www.github.com/kongchen/swagger-maven-plugin + </termsOfService> + </info> + <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath> + <outputPath>${basedir}/target/generated/api.html</outputPath> + <swaggerDirectory>${basedir}/target/generated/swagger-ui + </swaggerDirectory> + </apiSource> + </apiSources> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + <!--finalName>onboarding-api</finalName--> + </build> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml index 609d69f9f8..c83ae4471a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml @@ -37,7 +37,7 @@ <!-- aspect beans --> <bean id = "debugAspect" class="org.openecomp.sdc.logging.aspects.DebugAspect"/> - + <bean id = "healthCheck" class="org.openecomp.sdcrests.health.rest.services.HealthCheckImpl"/> <!--aop:config> < aspect pointcuts> <aop:pointcut id="loggingDebugPointcut" expression="execution(* org.openecomp.sdc.*.*.*(..))"/> @@ -60,20 +60,26 @@ <ref bean="licenseAgreements"/> <ref bean="featureGroups"/> <ref bean="entitlementPools"/> + <ref bean="entitlementPoolLimits"/> <ref bean="licenseKeyGroups"/> + <ref bean="licenseKeyGroupLimits"/> <ref bean="vendorSoftwareProducts"/> <ref bean="networks"/> <ref bean="components"/> <ref bean="nics"/> + <ref bean="computes"/> <ref bean="processes"/> <ref bean="componentProcesses"/> <ref bean="validation"/> <ref bean="actions"/> <ref bean="applicationConfiguration"/> - <ref bean="componentUploads"/> + <ref bean="componentMonitoringUploads"/> + <ref bean="deploymentFlavors"/> + <ref bean="images"/> <ref bean="orchestrationTemplateCandidate"/> <ref bean="componentDependencyModel"/> <ref bean="activityLog"/> + <ref bean="healthCheck"/> </jaxrs:serviceBeans> <jaxrs:providers> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..aaf3383c42 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-common-rest</artifactId> + <name>openecomp-sdc-common-rest</name> + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <version>${hibernate.validator.version}</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <!-- Swagger --> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-core</artifactId> + <version>${swagger.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index af77268599..e8a6c7e7db 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -22,8 +22,6 @@ package org.openecomp.sdcrests.errors; import org.codehaus.jackson.map.JsonMappingException; import org.hibernate.validator.internal.engine.path.PathImpl; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; @@ -34,10 +32,10 @@ import org.openecomp.sdc.common.errors.ErrorCodeAndMessage; import org.openecomp.sdc.common.errors.GeneralErrorBuilder; import org.openecomp.sdc.common.errors.JsonMappingErrorBuilder; import org.openecomp.sdc.common.errors.ValidationErrorBuilder; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -50,8 +48,8 @@ import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Path; import javax.ws.rs.core.MediaType; -import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = @@ -78,8 +76,8 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { try { writeStackTraceToFile(exception); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); } List<Object> contentTypes = new ArrayList<>(); contentTypes.add(MediaType.APPLICATION_JSON); @@ -174,15 +172,14 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private void writeStackTraceToFile(Exception exception) throws IOException { File file = new File("stack_trace.txt"); - OutputStream outputStream = new FileOutputStream(file); - - if(!file.exists()){ + if (!file.exists()) { file.createNewFile(); } - + OutputStream outputStream = new FileOutputStream(file); PrintWriter printWriter = new PrintWriter(file); exception.printStackTrace(printWriter); printWriter.close(); + outputStream.close(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml index 907e68f807..9fe4ff88a1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -23,6 +23,7 @@ <module>/action-library-rest</module> <module>/application-config-rest</module> <module>/activity-log-rest</module> + <module>/healthcheck-rest</module> </modules> </project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup new file mode 100644 index 0000000000..cd9b491c08 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup @@ -0,0 +1,28 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <name>openecomp-sdc-rest-webapp</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-api</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <modules> + <module>/openecomp-sdc-common-rest</module> + <module>/vendor-license-rest</module> + <module>/onboarding-rest-war</module> + <module>/vendor-software-products-rest</module> + <module>/sequence-rest</module> + <module>/validation-rest</module> + <module>/action-library-rest</module> + <module>/application-config-rest</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..313a50ca9d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <groupId>org.openecomp.sdc</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>sequence-rest</artifactId> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..8bacd99f69 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <name>validation-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <modules> + <module>/validation-rest-services</module> + <module>/validation-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..ffc417313a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>validation-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + <version>1.19.1</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + <version>4.4.1</version> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..5cc8ee7c51 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>validation-rest-types</artifactId> + <name>validation-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-validation-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..ae9c3063bc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup @@ -0,0 +1,23 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <name>vendor-license-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <modules> + <module>/vendor-license-rest-services</module> + <module>/vendor-license-rest-types</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..187135e1f4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup @@ -0,0 +1,135 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-license-rest-services</artifactId> + <name>vendor-license-rest-services</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + + <properties> + <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vendor-license-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency> + + + <!-- Spring --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + + + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java new file mode 100644 index 0000000000..3e7adc845d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java @@ -0,0 +1,103 @@ +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +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.POST; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools" + + "/{entitlementPoolId}/limits") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - Entitlement Pool Limits") +@Validated +public interface EntitlementPoolLimits { + + @POST + @Path("/") + @ApiOperation(value = "Create vendor entitlement pool limits") + Response createLimit(@Valid LimitRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam + ("versionId") + String versionId, + @ApiParam(value = "Vendor license model Entitlement Pool Id") + @PathParam("entitlementPoolId") + String entitlementPoolId , + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + + @GET + @Path("/") + @ApiOperation(value = "List vendor entitlement pool limits", + response = LimitRequestDto.class, + responseContainer = "List") + Response listLimits( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") + String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{limitId}") + @ApiOperation(value = "Update vendor entitlement pool limit") + Response updateLimit(@Valid LimitRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam + ("versionId") + String versionId, + @ApiParam(value = "Vendor license model Entitlement Pool Id") + @PathParam("entitlementPoolId") + String entitlementPoolId , + @NotNull(message = USER_MISSING_ERROR_MSG) + @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{limitId}") + @ApiOperation(value = "Get vendor entitlement pool limit", + response = LimitEntityDto.class) + Response getLimit( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model Entitlement Pool Id") @PathParam + ("entitlementPoolId") String entitlementPoolId, + @ApiParam(value = "Vendor license model Entitlement Pool Limit Id") @PathParam("limitId") + String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{limitId}") + @ApiOperation(value = "Delete vendor entitlement pool limit") + Response deleteLimit( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java new file mode 100644 index 0000000000..bfb2d51af0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java @@ -0,0 +1,101 @@ +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +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; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups" + + "/{licenseKeyGroupId}/limits") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - License Key Group Limits") +@Validated +public interface LicenseKeyGroupLimits { + + @POST + @Path("/") + @ApiOperation(value = "Create vendor license key group limit") + Response createLimit(@Valid LimitRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam + ("versionId") + String versionId, + @ApiParam(value = "Vendor license model License Key Group Id") + @PathParam("licenseKeyGroupId") + String licenseKeyGroupId , + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @ApiOperation(value = "List vendor license key group limits", + response = LimitEntityDto.class, + responseContainer = "List") + Response listLimits( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") + String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{limitId}") + @ApiOperation(value = "Update vendor license key group limit") + Response updateLimit(@Valid LimitRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam + ("versionId") + String versionId, + @ApiParam(value = "Vendor license model License Key Group Id") + @PathParam("licenseKeyGroupId") + String licenseKeyGroupId , + @NotNull(message = USER_MISSING_ERROR_MSG) + @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{limitId}") + @ApiOperation(value = "Get vendor entitlement pool limit", + response = LimitEntityDto.class) + Response getLimit( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model License Key Group") @PathParam + ("licenseKeyGroupId") String entitlementPoolId, + @ApiParam(value = "Vendor license model License Key Group Limit Id") @PathParam("limitId") + String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{limitId}") + @ApiOperation(value = "Delete vendor license key group limit") + Response deleteLimit( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java new file mode 100644 index 0000000000..da7852da2c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +public class LimitCreationDto { + private String limitId; + + public String getLimitId() { + return limitId; + } + + public void setLimitId(String limitId) { + this.limitId = limitId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java index c9f4ab894b..d35c06c30d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -47,7 +47,9 @@ public class MapEntitlementPoolEntityToEntitlementPoolEntityDto .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOtherDto.class)); target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java index fe626e374c..5442e1af61 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -45,7 +45,8 @@ public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOther.class)); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java index 9875a332bd..dedc2a01f0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -31,5 +31,6 @@ public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } -} +}
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java index 70f5666bcb..ce69384f41 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -31,5 +31,6 @@ public class MapFeatureGroupEntityToFeatureGroupDescriptorDto target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java new file mode 100644 index 0000000000..6883f3e48c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java @@ -0,0 +1,12 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapLimitEntityToLimitCreationDto extends + MappingBase<LimitEntity, LimitCreationDto> { + @Override + public void doMapping(LimitEntity source, LimitCreationDto target) { + target.setLimitId(source.getId()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java new file mode 100644 index 0000000000..9678f927b0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java @@ -0,0 +1,23 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; + +public class MapLimitEntityToLimitDto extends MappingBase<LimitEntity, LimitEntityDto> { + + @Override + public void doMapping(LimitEntity source, LimitEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setMetric(source.getMetric() != null ? source.getMetric().name() : null); + target.setAggregationFunction(source.getAggregationFunction() != null ? source + .getAggregationFunction().name() : null); + target.setTime(source.getTime() != null ? source.getTime().name() : null); + target.setType(source.getType() != null ? source.getType().name() : null); + target.setUnit(source.getUnit()); + target.setValue(source.getValue()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java new file mode 100644 index 0000000000..7f48ece1cf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java @@ -0,0 +1,75 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder; +import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.openecomp.sdc.vendorlicense.dao.types.LimitType; + + +public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto, LimitEntity> { + @Override + public void doMapping(LimitRequestDto source, LimitEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + try { + LimitType type = LimitType.valueOf(source.getType()); + target.setType(type); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); + } + + try { + EntitlementMetric metric = EntitlementMetric.valueOf(source.getMetric()); + target.setMetric(metric); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("metric", VendorLicenseErrorCodes.LIMIT_INVALID_METRIC); + } + + try { + AggregationFunction function = source.getAggregationFunction() != null ? + AggregationFunction.valueOf(source.getAggregationFunction()) : null; + target.setAggregationFunction(function); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("aggregationFunction", + VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); + } + + try { + EntitlementTime time = source.getTime() != null ? + EntitlementTime.valueOf(source.getTime()) : null; + target.setTime(time); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("time", VendorLicenseErrorCodes.LIMIT_INVALID_TIME); + } + + target.setValue(source.getValue()); + target.setUnit(source.getUnit()); + + } + + private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { + ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, + vendorLicenseErrorCode); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message() ); + throw new CoreException(errorCode); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java new file mode 100644 index 0000000000..3a08822048 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java @@ -0,0 +1,178 @@ +package org.openecomp.sdcrests.vendorlicense.rest.services; + + +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.rest.EntitlementPoolLimits; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.LimitCreationDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitCreationDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitRequestDtoToLimitEntity; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("entitlementPoolLimits") +@Scope(value = "prototype") +public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + @Autowired + private VendorLicenseManager vendorLicenseManager; + + @Override + public Response createLimit(LimitRequestDto request, + String vlmId, + String versionId, + String entitlementPoolId, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId); + + MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString()); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf + (versionId), entitlementPoolId), user); + + LimitEntity limitEntity = + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setVendorLicenseModelId(vlmId); + + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto + .class); + + /*StringWrapperResponse result = + createdLimit != null ? new StringWrapperResponse(createdLimit.getId()) + : null;*/ + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId); + + //return Response.ok(result).build(); + return Response.ok(createdLimitDto != null ? createdLimitDto : null) + .build(); + } + + @Override + public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String + user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId); + + MdcUtil.initMdc(LoggerServiceName.List_EP.toString()); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf + (versionId), entitlementPoolId), user); + + Collection<LimitEntity> limits = + vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), entitlementPoolId, user); + + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = + new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId); + + return Response.ok(result).build(); + } + + @Override + public Response getLimit( String vlmId, String versionId, String entitlementPoolId, + String limitId, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, + limitId); + + MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString()); + + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf + (versionId), entitlementPoolId), user); + LimitEntity epInput = new LimitEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setVersion(Version.valueOf(versionId)); + epInput.setEpLkgId(entitlementPoolId); + epInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(epInput, user); + + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : + new MapLimitEntityToLimitDto() + .applyMapping(limit, LimitEntityDto.class); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, + limitId); + + return Response.ok(entitlementPoolEntityDto).build(); + } + + @Override + public Response updateLimit(LimitRequestDto request, + String vlmId, + String versionId, + String entitlementPoolId, + String limitId, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", + limitId); + + MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString()); + + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf + (versionId), entitlementPoolId), user); + + LimitEntity limitEntity = + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setId(limitId); + + vendorLicenseManager.updateLimit(limitEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", + limitId); + + return Response.ok().build(); + } + + /** + * Delete entitlement pool. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, + String limitId, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId); + + MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString()); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf + (versionId), entitlementPoolId), user); + + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setEpLkgId(entitlementPoolId); + limitInput.setId(limitId); + vendorLicenseManager.deleteLimit(limitInput, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId); + + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java new file mode 100644 index 0000000000..aabba71a5c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java @@ -0,0 +1,179 @@ +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.rest.LicenseKeyGroupLimits; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.LimitCreationDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitCreationDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitRequestDtoToLimitEntity; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("licenseKeyGroupLimits") +@Scope(value = "prototype") +public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { + + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + @Autowired + private VendorLicenseManager vendorLicenseManager; + + @Override + public Response createLimit(LimitRequestDto request, + String vlmId, + String versionId, + String licenseKeyGroupId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId); + + MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString()); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf + (versionId), licenseKeyGroupId), user); + + LimitEntity limitEntity = + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setVendorLicenseModelId(vlmId); + + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto + .class); + /*StringWrapperResponse result = + createdLimit != null ? new StringWrapperResponse(createdLimit.getId()) + : null;*/ + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId); + + //return Response.ok(result).build(); + return Response.ok(createdLimitDto != null ? createdLimitDto : null) + .build(); + } + + @Override + public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String + user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId); + + MdcUtil.initMdc(LoggerServiceName.List_EP.toString()); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf + (versionId), licenseKeyGroupId), user); + + Collection<LimitEntity> limits = + vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), licenseKeyGroupId, user); + + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = + new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId); + + return Response.ok(result).build(); + } + + @Override + public Response updateLimit(LimitRequestDto request, + String vlmId, + String versionId, + String licenseKeyGroupId, + String limitId, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id", + limitId); + + MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString()); + + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf + (versionId), licenseKeyGroupId), user); + + LimitEntity limitEntity = + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setId(limitId); + + vendorLicenseManager.updateLimit(limitEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id", + limitId); + + return Response.ok().build(); + } + + /** + * Delete License Key Group. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license Key Group id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, + String limitId, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId, + licenseKeyGroupId, limitId); + + MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString()); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf + (versionId), licenseKeyGroupId), user); + + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setEpLkgId(licenseKeyGroupId); + limitInput.setId(limitId); + vendorLicenseManager.deleteLimit(limitInput, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId, + licenseKeyGroupId, limitId); + + return Response.ok().build(); + } + + @Override + public Response getLimit( String vlmId, String versionId, String licenseKeyGroupId, + String limitId, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId, + limitId); + + MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString()); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf + (versionId), licenseKeyGroupId), user); + LimitEntity epInput = new LimitEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setVersion(Version.valueOf(versionId)); + epInput.setEpLkgId(licenseKeyGroupId); + epInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(epInput, user); + + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : + new MapLimitEntityToLimitDto() + .applyMapping(limit, LimitEntityDto.class); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId, + limitId); + + return Response.ok(entitlementPoolEntityDto).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..d24c315f39 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup @@ -0,0 +1,29 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-license-rest-types</artifactId> + <name>vendor-license-rest-types</name> + <version>1.0-SNAPSHOT</version> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java index b70504e20e..b49a138a09 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java @@ -21,6 +21,7 @@ package org.openecomp.sdcrests.vendorlicense.types; import io.swagger.annotations.ApiModel; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; @@ -32,17 +33,18 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @ApiModel(value = "EntitlementPoolRequest") +//@JsonIgnoreProperties(value = {"manufacturerReferenceNumber"}) public class EntitlementPoolRequestDto { @NotNull @Size(max = 120) private String name; - @NotNull + @Size(max = 1000) private String description; - @NotNull - private int thresholdValue; - @NotNull + + private Integer thresholdValue; + private ThresholdUnit thresholdUnits; @NotNull @Valid @@ -52,7 +54,7 @@ public class EntitlementPoolRequestDto { @NotNull @Valid private ChoiceOrOtherDto<AggregationFunction> aggregationFunction; - @NotNull + @Valid private MultiChoiceOrOtherDto<OperationalScope> operationalScope; @NotNull @@ -62,6 +64,9 @@ public class EntitlementPoolRequestDto { @Size(max = 100) private String manufacturerReferenceNumber; + private String startDate; + private String expiryDate; + public String getName() { return name; } @@ -78,11 +83,11 @@ public class EntitlementPoolRequestDto { this.description = description; } - public int getThresholdValue() { + public Integer getThresholdValue() { return thresholdValue; } - public void setThresholdValue(int thresholdValue) { + public void setThresholdValue(Integer thresholdValue) { this.thresholdValue = thresholdValue; } @@ -141,4 +146,20 @@ public class EntitlementPoolRequestDto { public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { this.manufacturerReferenceNumber = manufacturerReferenceNumber; } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getExpiryDate() { + return expiryDate; + } + + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java index 5c1f8f2cfc..f2d0d651ef 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java @@ -20,6 +20,8 @@ package org.openecomp.sdcrests.vendorlicense.types; +import org.hibernate.validator.constraints.NotBlank; + import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @@ -27,12 +29,16 @@ public class FeatureGroupDescriptorDto { @NotNull @Size(max = 120) private String name; - @NotNull + @Size(max = 1000) private String description; @NotNull private String partNumber; + //@NotBlank(message = "is mandatory and should not be empty") + @Size(max = 100) + private String manufacturerReferenceNumber; + public String getName() { return name; } @@ -56,4 +62,12 @@ public class FeatureGroupDescriptorDto { public void setPartNumber(String partNumber) { this.partNumber = partNumber; } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java index acfc130ed1..4239488124 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java @@ -31,7 +31,7 @@ public class LicenseAgreementDescriptorDto { @NotNull @Size(max = 120) private String name; - @NotNull + @Size(max = 1000) private String description; @NotNull diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java index 0df2e3251f..a9072f5e94 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java @@ -31,12 +31,11 @@ public class LicenseKeyGroupRequestDto { @NotNull @Size(max = 120) private String name; - @NotNull @Size(max = 1000) private String description; @NotNull private LicenseKeyType type; - @NotNull + @Valid private MultiChoiceOrOtherDto<OperationalScope> operationalScope; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java new file mode 100644 index 0000000000..0cc18949d8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java @@ -0,0 +1,86 @@ +package org.openecomp.sdcrests.vendorlicense.types; + +public class LimitEntityDto { + + private String id; + private String name; + private String type; + private String description; + private String metric; + private Integer value; + private Integer unit; + private String aggregationFunction; + private String time; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public Integer getUnit() { + return unit; + } + + public void setUnit(Integer unit) { + this.unit = unit; + } + + public String getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction(String aggregationFunction) { + this.aggregationFunction = aggregationFunction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java new file mode 100644 index 0000000000..61f30916f8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java @@ -0,0 +1,96 @@ +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; +import org.hibernate.validator.constraints.NotBlank; +import org.openecomp.sdc.vendorlicense.dao.types.LimitType; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +@ApiModel(value = "LimitRequest") +public class LimitRequestDto { + + @NotBlank(message = "is mandatory and should not be empty") + @Size(max = 120, message = "length should not exceed 120 characters.") + private String name; + @NotBlank(message = "is mandatory and should not be empty") + private String type; + @Size(max = 1000, message = "length should not exceed 1000 characters.") + private String description; + @NotBlank(message = "is mandatory and should not be empty") + private String metric; + @NotNull(message = "is mandatory and should not be empty") + @Min(value = 1, message = "should be integer and > 0") + private Integer value; + @Min(value = 1, message = "should be integer and > 0") + private Integer unit; + private String aggregationFunction; + private String time; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction( + String aggregationFunction) { + this.aggregationFunction = aggregationFunction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getUnit() { + return unit; + } + + public void setUnit(Integer unit) { + this.unit = unit; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..074c8d9e10 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <name>vendor-software-products-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <modules> + <module>/vendor-software-products-rest-services</module> + <module>/vendor-software-products-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..ba2814613e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-software-products-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + <version>1.19.1</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + <version>4.4.1</version> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + +</project>
\ No newline at end of file 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/ComponentMonitoringForSwaggerFileUpload.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/ComponentMonitoringForSwaggerFileUpload.java new file mode 100644 index 0000000000..e7e8ba1b50 --- /dev/null +++ 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/ComponentMonitoringForSwaggerFileUpload.java @@ -0,0 +1,65 @@ +///*- +// * ============LICENSE_START======================================================= +// * SDC +// * ================================================================================ +// * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +// * ================================================================================ +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// * ============LICENSE_END========================================================= +// */ +// +//package org.openecomp.sdcrests.vsp.rest; +// +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import io.swagger.annotations.ApiParam; +//import org.apache.cxf.jaxrs.ext.multipart.Attachment; +//import org.apache.cxf.jaxrs.ext.multipart.Multipart; +//import org.springframework.validation.annotation.Validated; +// +//import javax.validation.constraints.NotNull; +//import javax.ws.rs.Consumes; +//import javax.ws.rs.HeaderParam; +//import javax.ws.rs.Path; +//import javax.ws.rs.PathParam; +//import javax.ws.rs.Produces; +//import javax.ws.rs.core.MediaType; +//import javax.ws.rs.core.Response; +// +//import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +//import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +// +//@Path("/v1.0/vendor-software-products") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) +//@Api(value = "Vendor Software Products") +//@Validated +//public interface ComponentMonitoringForSwaggerFileUpload { +// +// +// +// @Path("/{vspId}/versions/{versionId}/components/{componentId}/uploads/type{type}") +// @Consumes(MediaType.MULTIPART_FORM_DATA) +// @ApiOperation(value = "Upload file for component by type") +// Response upload(@Multipart("upload") Attachment attachment, +// @ApiParam(value = "Vendor software product Id") @PathParam("vspId") +// String vspId, +// @ApiParam(value = "Vendor software product version Id") +// @PathParam("versionId") String versionId, +// @ApiParam(value = "Component Id") @PathParam("componentId") String +// componentId, +// @ApiParam(value = "Upload Type") @PathParam("type") String type, +// @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/ComponentMonitoringUploads.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/ComponentMonitoringUploads.java new file mode 100644 index 0000000000..c8c29b668f --- /dev/null +++ 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/ComponentMonitoringUploads.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; +import org.springframework.validation.annotation.Validated; + +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; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path( + "/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/uploads/") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component Uploads") +@Validated +public interface ComponentMonitoringUploads extends VspEntities { + @POST + @Path("types/{type}/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Upload file for component by type") + Response upload(@Multipart("upload") Attachment attachment, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product version Id") + @PathParam("versionId") String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String + componentId, + @ApiParam(value = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + + @DELETE + @Path("types/{type}") + @ApiOperation(value = "Delete file uploaded for component") + Response delete( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") + String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String componentId, + @ApiParam(value = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws Exception; + + @GET + @Path("") + @ApiOperation(value = "Get the filenames of uploaded files by type", + response = MonitoringUploadStatusDto.class) + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") + String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); +} 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/ComponentUploads.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/ComponentUploads.java index 313ae24e95..9c327f5718 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/ComponentUploads.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/ComponentUploads.java @@ -1,108 +1,108 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.vsp.rest; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.apache.cxf.jaxrs.ext.multipart.Multipart; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; -import org.springframework.validation.annotation.Validated; - -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; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/monitors") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Api(value = "Vendor Software Product Component MIB Uploads") -@Validated -public interface ComponentUploads extends VspEntities { - @POST - @Path("/snmp-trap/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB SNMP_TRAP Definitions file") - Response uploadTrapMibFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, - @ApiParam(value = "Component Id") @PathParam("componentId") String - componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @DELETE - @Path("/snmp-trap") - @ApiOperation(value = "Delete vendor software product MIB SNMP_TRAP Definitions file") - Response deleteTrapMibFile( - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, - @ApiParam(value = "Component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/snmp/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB SNMP_POLL Definitions file") - Response uploadPollMibFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, - @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, - @ApiParam(value = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @DELETE - @Path("/snmp") - @ApiOperation(value = "Delete vendor software product MIB SNMP_POLL Definitions file") - Response deletePollMibFile( - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - // TODO: 2/27/2017 add version - @GET - @Path("/snmp/") - @ApiOperation(value = "Get the filenames of uploaded MIB definitions", - response = MibUploadStatusDto.class) - Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); -} +///*- +// * ============LICENSE_START======================================================= +// * SDC +// * ================================================================================ +// * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +// * ================================================================================ +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// * ============LICENSE_END========================================================= +// */ +// +//package org.openecomp.sdcrests.vsp.rest; +// +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import io.swagger.annotations.ApiParam; +//import org.apache.cxf.jaxrs.ext.multipart.Attachment; +//import org.apache.cxf.jaxrs.ext.multipart.Multipart; +//import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; +//import org.springframework.validation.annotation.Validated; +// +//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; +//import javax.ws.rs.Path; +//import javax.ws.rs.PathParam; +//import javax.ws.rs.Produces; +//import javax.ws.rs.core.MediaType; +//import javax.ws.rs.core.Response; +// +//import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +//import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +// +//@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/monitors") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) +//@Api(value = "Vendor Software Product Component MIB Uploads") +//@Validated +//public interface ComponentUploads extends VspEntities { +// @POST +// @Path("/snmp-trap/upload") +// @Consumes(MediaType.MULTIPART_FORM_DATA) +// @ApiOperation(value = "Upload vendor software product MIB SNMP_TRAP Definitions file") +// Response uploadTrapMibFile(@Multipart("upload") Attachment attachment, +// @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, +// @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, +// @ApiParam(value = "Component Id") @PathParam("componentId") String +// componentId, +// @NotNull(message = USER_MISSING_ERROR_MSG) +// @HeaderParam(USER_ID_HEADER_PARAM) String user); +// +// @DELETE +// @Path("/snmp-trap") +// @ApiOperation(value = "Delete vendor software product MIB SNMP_TRAP Definitions file") +// Response deleteTrapMibFile( +// @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, +// @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, +// @ApiParam(value = "Component Id") @PathParam("componentId") String componentId, +// @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +// +// @POST +// @Path("/snmp/upload") +// @Consumes(MediaType.MULTIPART_FORM_DATA) +// @ApiOperation(value = "Upload vendor software product MIB SNMP_POLL Definitions file") +// Response uploadPollMibFile(@Multipart("upload") Attachment attachment, +// @ApiParam(value = "Vendor software product Id") @PathParam("vspId") +// String vspId, +// @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, +// @ApiParam(value = "Vendor software product component Id") +// @PathParam("componentId") String componentId, +// @NotNull(message = USER_MISSING_ERROR_MSG) +// @HeaderParam(USER_ID_HEADER_PARAM) String user); +// +// @DELETE +// @Path("/snmp") +// @ApiOperation(value = "Delete vendor software product MIB SNMP_POLL Definitions file") +// Response deletePollMibFile( +// @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, +// @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, +// @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") +// String componentId, +// @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +// +// +// // TODO: 2/27/2017 add version +// @GET +// @Path("/snmp/") +// @ApiOperation(value = "Get the filenames of uploaded MIB definitions", +// response = MonitoringUploadStatusDto.class) +// Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, +// @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, +// @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") +// String componentId, +// @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) +// String user); +//} 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/Compute.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/Compute.java new file mode 100644 index 0000000000..13d9a049c8 --- /dev/null +++ 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/Compute.java @@ -0,0 +1,131 @@ +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +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; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId" + + "}/compute-flavors") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component Compute-flavors") +@Validated +public interface Compute extends VspEntities { + + @GET + @Path("/") + @ApiOperation(value = "Get list of vendor software product component compute-flavors", + response = ComputeDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/{computeFlavorId}") + @ApiOperation(value = "Get vendor software product component compute-flavor", + response = ComputeDetailsDto.class, + responseContainer = "CompositionEntityResponse") + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product compute-flavor Id") @PathParam + ("computeFlavorId") + String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product component compute-flavor") + Response create(@Valid ComputeDetailsDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @PUT + @Path("/{computeFlavorId}") + @ApiOperation(value = "Update vendor software product component compute-flavor") + Response update(@Valid ComputeDetailsDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product compute-flavor Id") @PathParam + ("computeFlavorId") + String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @PUT + @Path("/{computeFlavorId}/questionnaire") + @ApiOperation(value = "Update vendor software product component compute-flavor questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product compute-flavor Id") @PathParam + ("computeFlavorId") + String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @DELETE + @Path("/{computeFlavorId}") + @ApiOperation(value = "Delete vendor software product component compute-flavor") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product compute-flavor Id") @PathParam + ("computeFlavorId") + String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/{computeFlavorId}/questionnaire") + @ApiOperation(value = "Get vendor software product component compute-flavor questionnaire", + response = QuestionnaireResponseDto.class) + Response getQuestionnaire( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product compute-flavor Id") @PathParam + ("computeFlavorId") String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +} 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/DeploymentFlavors.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/DeploymentFlavors.java new file mode 100644 index 0000000000..581b15199c --- /dev/null +++ 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/DeploymentFlavors.java @@ -0,0 +1,88 @@ +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/deployment-flavors") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product deployment-flavors") +@Validated +public interface DeploymentFlavors extends VspEntities { + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product Deployment Flavor") + Response create(@Valid DeploymentFlavorRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/") + @ApiOperation(value = "List vendor software product Deployment Flavor", + response = DeploymentFlavorListResponseDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/{deploymentFlavorId}") + @ApiOperation(value = "Get vendor software product Deployment Flavor", + response = DeploymentFlavorDto.class) + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product Deployment Flavor Id") @PathParam + ("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/schema") + Response getSchema(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String + vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @DELETE + @Path("/{deploymentFlavorId}") + @ApiOperation(value = "Delete vendor software product Deployment Flavor") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product Deployment Flavor Id") + @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @PUT + @Path("/{deploymentFlavorId}") + @ApiOperation(value = "Update vendor software product Deployment Flavor") + Response update(@Valid DeploymentFlavorRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product Deployment Flavor Id") + @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); +} 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/Images.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/Images.java new file mode 100644 index 0000000000..8939faa13f --- /dev/null +++ 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/Images.java @@ -0,0 +1,159 @@ +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +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; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/images") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Images") +@Validated +public interface Images extends VspEntities { + + @GET + @Path("/") + @ApiOperation(value = "List vendor software product component images", + response = ImageDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product component image") + Response create(@Valid ImageRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/schema") + //@ApiOperation(value = "Get schema for vendor software product component Image" , + // response = QuestionnaireResponseDto.class) + Response getImageSchema(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId,@NotNull + (message = USER_MISSING_ERROR_MSG) @HeaderParam + (USER_ID_HEADER_PARAM) String user); + + /*@GET + @Path("/{imageId}") + @ApiOperation(value = "Get vendor software product component Image", + response = ImageDto.class, + responseContainer = "ImageEntityResponse") + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product image Id") @PathParam("imageId") + String imageId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user);*/ + + @GET + @Path("/{imageId}") + @ApiOperation(value = "Get vendor software product component Image", + response = ImageDto.class, + responseContainer = "CompositionEntityResponse") + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product Image Id") @PathParam + ("imageId") + String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @DELETE + @Path("/{imageId}") + @ApiOperation(value = "Delete vendor software product Image") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product Image Id") @PathParam("imageId") + String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @PUT + @Path("/{imageId}") + @ApiOperation(value = "Update vendor software product Image") + Response update(@Valid ImageRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product Image Id") @PathParam("imageId") + String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @PUT + @Path("/{imageId}/questionnaire") + @ApiOperation(value = "Update vendor software product component image questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @ApiParam(value = "Vendor software product Id") + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") + @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product image Id") + @PathParam ("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{imageId}/questionnaire") + @ApiOperation(value = "Get vendor software product component image questionnaire", + response = QuestionnaireResponseDto.class) + Response getQuestionnaire( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product image Id") @PathParam + ("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +} 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java index 53fe2af31d..4366b2c3d1 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java @@ -23,21 +23,41 @@ package org.openecomp.sdcrests.vsp.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.validation.constraints.Pattern; +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; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -183,4 +203,14 @@ public interface VendorSoftwareProducts extends VspEntities { @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{vspId}/versions/{versionId}/compute-flavors") + @ApiOperation(value = "Get list of vendor software product compute-flavors", + response = VspComputeDto.class, + responseContainer = "List") + Response listCompute(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String + vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); } 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/mapping/MapComponentDataToComponentDto.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/mapping/MapComponentDataToComponentDto.java index b669830bc7..346b39a6b7 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/mapping/MapComponentDataToComponentDto.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/mapping/MapComponentDataToComponentDto.java @@ -32,6 +32,9 @@ public class MapComponentDataToComponentDto extends MappingBase<ComponentData, C source.getDisplayName() == null ? source.getName() : source.getDisplayName()); target.setVfcCode( source.getVfcCode() == null ? target.getDisplayName() : source.getVfcCode()); + target.setNfcCode( + source.getNfcCode() == null ? source.getDisplayName() : source.getNfcCode()); + target.setNfcFunction(source.getNfcFunction()); target.setDescription(source.getDescription()); } } 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/mapping/MapComponentEntityToComponentCreationDto.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/mapping/MapComponentEntityToComponentCreationDto.java new file mode 100644 index 0000000000..372a83ac78 --- /dev/null +++ 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/mapping/MapComponentEntityToComponentCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; + +public class MapComponentEntityToComponentCreationDto extends MappingBase<ComponentEntity, + ComponentCreationDto> { + @Override + public void doMapping(ComponentEntity source, ComponentCreationDto target) { + target.setVfcId(source.getId()); + } +} 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/mapping/MapComponentRequestDtoToComponentEntity.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/mapping/MapComponentRequestDtoToComponentEntity.java index f61ee0d4ab..6649c117e3 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/mapping/MapComponentRequestDtoToComponentEntity.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/mapping/MapComponentRequestDtoToComponentEntity.java @@ -33,6 +33,8 @@ public class MapComponentRequestDtoToComponentEntity component.setName(source.getName()); component.setDisplayName(source.getDisplayName()); component.setVfcCode(source.getVfcCode()); + component.setNfcCode(source.getNfcCode()); + component.setNfcFunction(source.getNfcFunction()); component.setDescription(source.getDescription()); target.setComponentCompositionData(component); } 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/mapping/MapComputeDataToComputeDetailsDto.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/mapping/MapComputeDataToComputeDetailsDto.java new file mode 100644 index 0000000000..f0408bb73e --- /dev/null +++ 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/mapping/MapComputeDataToComputeDetailsDto.java @@ -0,0 +1,15 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; + +public class MapComputeDataToComputeDetailsDto extends MappingBase<ComputeData, ComputeDetailsDto> { + + @Override + public void doMapping(ComputeData source, ComputeDetailsDto target) { + + target.setName(source.getName()); + target.setDescription(source.getDescription()); + } +} 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/mapping/MapComputeDetailsDtoToComputeEntity.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/mapping/MapComputeDetailsDtoToComputeEntity.java new file mode 100644 index 0000000000..7db9a0a9b1 --- /dev/null +++ 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/mapping/MapComputeDetailsDtoToComputeEntity.java @@ -0,0 +1,17 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; + +public class MapComputeDetailsDtoToComputeEntity extends MappingBase<ComputeDetailsDto, + ComputeEntity> { + @Override + public void doMapping(ComputeDetailsDto source, ComputeEntity target) { + ComputeDescription computeDesc = new ComputeDescription(source.getName(), source + .getDescription()); + target.setCompositionData(computeDesc == null ? null : JsonUtil.object2Json(computeDesc)); + } +} 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/mapping/MapComputeEntityToComputeCreationDto.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/mapping/MapComputeEntityToComputeCreationDto.java new file mode 100644 index 0000000000..23f7b52079 --- /dev/null +++ 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/mapping/MapComputeEntityToComputeCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; + +public class MapComputeEntityToComputeCreationDto extends + MappingBase<ComputeEntity, ComputeCreationDto> { + @Override + public void doMapping(ComputeEntity source, ComputeCreationDto target) { + target.setId(source.getId()); + } +} 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/mapping/MapComputeEntityToComputeDto.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/mapping/MapComputeEntityToComputeDto.java new file mode 100644 index 0000000000..d7586471b5 --- /dev/null +++ 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/mapping/MapComputeEntityToComputeDto.java @@ -0,0 +1,22 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; + +public class MapComputeEntityToComputeDto extends MappingBase<ListComputeResponse, ComputeDto> { + @Override + public void doMapping(ListComputeResponse source, ComputeDto target) { + target.setId(source.getComputeEntity().getId()); + if (source.getComputeEntity().getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getComputeEntity().getCompositionData + (), ComputeDescription.class); + target.setName(desc.getName()); + target.setDescription(desc.getDescription()); + target.setAssociatedToDeploymentFlavor(source.isAssociatedWithDeploymentFlavor()); + } + } +} 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/mapping/MapComputeEntityToVspComputeDto.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/mapping/MapComputeEntityToVspComputeDto.java new file mode 100644 index 0000000000..f02bf3778e --- /dev/null +++ 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/mapping/MapComputeEntityToVspComputeDto.java @@ -0,0 +1,20 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; + +public class MapComputeEntityToVspComputeDto extends MappingBase<ComputeEntity, VspComputeDto> { + @Override + public void doMapping(ComputeEntity source, VspComputeDto target) { + target.setComputeFlavorId(source.getId()); + if (source.getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getCompositionData(), ComputeDescription + .class); + target.setName(desc.getName()); + target.setComponentId(source.getComponentId()); + } + } +}
\ No newline at end of file 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/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.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/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java new file mode 100644 index 0000000000..edfbccf1da --- /dev/null +++ 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/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java @@ -0,0 +1,22 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; + +public class MapDeploymentFlavorEntityDeploymentFlavorToListResponse extends + MappingBase<DeploymentFlavorEntity, DeploymentFlavorListResponseDto> { + + @Override + public void doMapping(DeploymentFlavorEntity source, + DeploymentFlavorListResponseDto target) { + target.setId(source.getId()); + DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); + + if (deploymentFlavor != null) { + target.setModel(deploymentFlavor.getModel()); + target.setDescription(deploymentFlavor.getDescription()); + } + } +} 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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java new file mode 100644 index 0000000000..0ca990c66c --- /dev/null +++ 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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java @@ -0,0 +1,16 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; + + +public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDto extends MappingBase<DeploymentFlavorEntity, + DeploymentFlavorCreationDto> { + + @Override + public void doMapping(DeploymentFlavorEntity source, + DeploymentFlavorCreationDto target) { + target.setDeploymentFlavorId(source.getId()); + } +} 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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java new file mode 100644 index 0000000000..41795eebe0 --- /dev/null +++ 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/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java @@ -0,0 +1,19 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; + +public class MapDeploymentFlavorEntityToDeploymentFlavorDto extends + MappingBase<DeploymentFlavorEntity, DeploymentFlavorDto> { + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorDto target) { + target.setId(source.getId()); + DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); + if (deploymentFlavor != null) { + //new MapNetworkToNetworkDto().doMapping(deploymentFlavor, target); + } + } +} 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/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.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/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java new file mode 100644 index 0000000000..b956313331 --- /dev/null +++ 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/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java @@ -0,0 +1,20 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; + +public class MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity + extends MappingBase<DeploymentFlavorRequestDto, DeploymentFlavorEntity> { + + @Override + public void doMapping(DeploymentFlavorRequestDto source, DeploymentFlavorEntity target) { + DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); + deploymentFlavor.setModel(source.getModel()); + deploymentFlavor.setDescription(source.getDescription()); + deploymentFlavor.setFeatureGroupId(source.getFeatureGroupId()); + deploymentFlavor.setComponentComputeAssociations(source.getComponentComputeAssociations()); + target.setDeploymentFlavorCompositionData(deploymentFlavor); + } +} 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/mapping/MapDeploymentFlavorToDeploymentDto.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/mapping/MapDeploymentFlavorToDeploymentDto.java new file mode 100644 index 0000000000..fceeb8f2ca --- /dev/null +++ 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/mapping/MapDeploymentFlavorToDeploymentDto.java @@ -0,0 +1,16 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; + + +public class MapDeploymentFlavorToDeploymentDto extends MappingBase<DeploymentFlavor, DeploymentFlavorDto> { + @Override + public void doMapping(DeploymentFlavor source, DeploymentFlavorDto target) { + target.setModel(source.getModel()); + target.setDescription(source.getDescription()); + target.setFeatureGroupId(source.getFeatureGroupId()); + target.setComponentComputeAssociations(source.getComponentComputeAssociations()); + } +} 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/mapping/MapImageDataToImageDto.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/mapping/MapImageDataToImageDto.java new file mode 100644 index 0000000000..684cd4c31d --- /dev/null +++ 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/mapping/MapImageDataToImageDto.java @@ -0,0 +1,22 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; + + +public class MapImageDataToImageDto extends MappingBase<ImageData, ImageDto> { + + @Override + public void doMapping(ImageData source, ImageDto target) { + target.setFileName(source.getFileName()); + target.setDescription(source.getDescription()); + } +} + + + + + + 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/mapping/MapImageEntityToImageCreationDto.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/mapping/MapImageEntityToImageCreationDto.java new file mode 100644 index 0000000000..5710fbe02e --- /dev/null +++ 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/mapping/MapImageEntityToImageCreationDto.java @@ -0,0 +1,16 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; + +public class MapImageEntityToImageCreationDto extends MappingBase<ImageEntity, + ImageCreationDto> { + + @Override + public void doMapping(ImageEntity source, ImageCreationDto target) { + target.setId(source.getId()); + } +} 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/mapping/MapImageEntityToImageDto.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/mapping/MapImageEntityToImageDto.java new file mode 100644 index 0000000000..62d37465e1 --- /dev/null +++ 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/mapping/MapImageEntityToImageDto.java @@ -0,0 +1,21 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; + +public class MapImageEntityToImageDto extends MappingBase<ImageEntity, ImageDto> { + @Override + public void doMapping(ImageEntity source, ImageDto target) { + target.setId(source.getId()); + Image image = source.getImageCompositionData(); + + if (image != null) { + ImageData imageData = new ImageData(image.getFileName(), image.getDescription()); + new MapImageDataToImageDto().doMapping(imageData, target); + } + } +} 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/mapping/MapImageRequestDtoToImageEntity.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/mapping/MapImageRequestDtoToImageEntity.java new file mode 100644 index 0000000000..0b8a501f16 --- /dev/null +++ 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/mapping/MapImageRequestDtoToImageEntity.java @@ -0,0 +1,44 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder; +import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageFormat; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; + +public class MapImageRequestDtoToImageEntity extends MappingBase<ImageRequestDto, ImageEntity> { + + @Override + public void doMapping(ImageRequestDto source, ImageEntity target) { + Image image = new Image(); + image.setFileName(source.getFileName()); + image.setDescription(source.getDescription()); + /*try { + if (source.getFormat() != null) { + final ImageFormat imageFormat = ImageFormat.valueOf(source.getFormat()); + image.setFormat(source.getFormat()); + } + } catch (IllegalArgumentException exception) { + ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder(); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message() ); + throw new CoreException(errorCode); + } + image.setMd5(source.getMd5()); + image.setVersion(source.getVersion()); + //image.setProvidedBy(source.getProvidedBy());*/ + target.setImageCompositionData(image); + } + +} 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/mapping/MapMibUploadStatusToDto.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/mapping/MapMonitoringUploadStatusToDto.java index d69e078ac1..08d322dad0 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/mapping/MapMibUploadStatusToDto.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/mapping/MapMonitoringUploadStatusToDto.java @@ -20,14 +20,16 @@ package org.openecomp.sdcrests.vsp.rest.mapping; -import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus; import org.openecomp.sdcrests.mapping.MappingBase; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; -public class MapMibUploadStatusToDto extends MappingBase<MibUploadStatus, MibUploadStatusDto> { +public class MapMonitoringUploadStatusToDto + extends MappingBase<MonitoringUploadStatus, MonitoringUploadStatusDto> { @Override - public void doMapping(MibUploadStatus source, MibUploadStatusDto target) { + public void doMapping(MonitoringUploadStatus source, MonitoringUploadStatusDto target) { target.setSnmpPoll(source.getSnmpPoll()); target.setSnmpTrap(source.getSnmpTrap()); + target.setVesEvent(source.getVesEvent()); } } 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/mapping/MapNicEntityToNicCreationResponseDto.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/mapping/MapNicEntityToNicCreationResponseDto.java new file mode 100644 index 0000000000..23bf5d5357 --- /dev/null +++ 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/mapping/MapNicEntityToNicCreationResponseDto.java @@ -0,0 +1,16 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; + +public class MapNicEntityToNicCreationResponseDto extends MappingBase<NicEntity, + NicCreationResponseDto> { + + + @Override + public void doMapping(NicEntity source, NicCreationResponseDto target) { + target.setNicId(source.getId()); + } +} 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/mapping/MapNicRequestDtoToNicEntity.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/mapping/MapNicRequestDtoToNicEntity.java index 4744364ea6..7fd0253556 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/mapping/MapNicRequestDtoToNicEntity.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/mapping/MapNicRequestDtoToNicEntity.java @@ -21,6 +21,7 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; @@ -32,6 +33,8 @@ public class MapNicRequestDtoToNicEntity extends MappingBase<NicRequestDto, NicE nic.setName(source.getName()); nic.setDescription(source.getDescription()); nic.setNetworkId(source.getNetworkId()); + nic.setNetworkType(NetworkType.valueOf(source.getNetworkType())); + nic.setNetworkDescription(source.getNetworkDescription()); target.setNicCompositionData(nic); } } 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/mapping/MapNicToNicDto.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/mapping/MapNicToNicDto.java index 2fcfd36b3f..8c48f18b3d 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/mapping/MapNicToNicDto.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/mapping/MapNicToNicDto.java @@ -31,5 +31,9 @@ public class MapNicToNicDto extends MappingBase<Nic, NicDto> { target.setDescription(source.getDescription()); target.setNetworkId(source.getNetworkId()); target.setNetworkName(source.getNetworkName()); + if (source.getNetworkType() != null) { + target.setNetworkType(source.getNetworkType().name()); + } + target.setNetworkDescription(source.getNetworkDescription()); } } 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/mapping/MapValidationResponseToDto.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/mapping/MapValidationResponseToDto.java index e6346c452d..89d210f372 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/mapping/MapValidationResponseToDto.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/mapping/MapValidationResponseToDto.java @@ -24,6 +24,8 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.vendorsoftwareproduct.types.ComponentValidationResult; +import org.openecomp.sdc.vendorsoftwareproduct.types.DeploymentFlavorValidationResult; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; @@ -32,15 +34,17 @@ import org.openecomp.sdcrests.common.mapping.MapErrorMessageToDto; import org.openecomp.sdcrests.common.types.ErrorCodeDto; import org.openecomp.sdcrests.common.types.ErrorMessageDto; import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -57,7 +61,8 @@ public class MapValidationResponseToDto private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult( QuestionnaireValidationResult questionnaireValidationResult) { - if (questionnaireValidationResult == null) { + if (Objects.isNull(questionnaireValidationResult) + || Objects.isNull(questionnaireValidationResult.getValidationData())) { return null; } QuestionnaireValidationResultDto questionnaireValidationResultDto = @@ -74,6 +79,44 @@ public class MapValidationResponseToDto return questionnaireValidationResultDto; } + private static ComponentValidationResultDto mapcomponentValidationResult( + ComponentValidationResult componentValidationResult) { + if (componentValidationResult == null) { + return null; + } + ComponentValidationResultDto componentValidationResultDto = + new ComponentValidationResultDto(); + componentValidationResultDto.setValid(componentValidationResult.isValid()); + + Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); + for(CompositionEntityValidationData validationData : componentValidationResult.getValidationData()){ + validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping + (validationData, CompositionEntityValidationDataDto.class)); + } + + componentValidationResultDto.setValidationData(validationDataDto); + return componentValidationResultDto; + } + + private static DeploymentFlavorValidationResultDto mapdeploymentFlavorValidationResult( + DeploymentFlavorValidationResult deploymentFlavorValidationResult) { + if (deploymentFlavorValidationResult == null) { + return null; + } + DeploymentFlavorValidationResultDto deploymentFlavorValidationResultDto = + new DeploymentFlavorValidationResultDto(); + deploymentFlavorValidationResultDto.setValid(deploymentFlavorValidationResult.isValid()); + + Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); + for(CompositionEntityValidationData validationData : deploymentFlavorValidationResult.getValidationData()){ + validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping + (validationData, CompositionEntityValidationDataDto.class)); + } + + deploymentFlavorValidationResultDto.setValidationData(validationDataDto); + return deploymentFlavorValidationResultDto; + } + private static List<ErrorMessageDto> mapErrorMessages(List<ErrorMessage> errorMessages) { return errorMessages == null ? null : errorMessages.stream().map( errorMessage -> new MapErrorMessageToDto() @@ -94,5 +137,7 @@ public class MapValidationResponseToDto target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); target.setQuestionnaireValidationResult( mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult())); + target.setComponentValidationResult(mapcomponentValidationResult(source.getComponentValidationResult())); + target.setDeploymentFlavorValidationResult(mapdeploymentFlavorValidationResult(source.getDeploymentFlavorValidationResult())); } } 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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java index 6eca00e8aa..9093da599f 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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java @@ -7,9 +7,9 @@ * 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. @@ -73,5 +73,9 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto .map(version -> new VersionDto(version.toString(), version.toString())) .collect(Collectors.toList())); } + + //Onboarding Method valid value will always be present in VSP saved in DB + target.setOnboardingMethod(vsp.getOnboardingMethod()); + } } 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/mapping/MapVspDescriptionDtoToVspDetails.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/mapping/MapVspDescriptionDtoToVspDetails.java index ec0843263a..9808bbb2b6 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/mapping/MapVspDescriptionDtoToVspDetails.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/mapping/MapVspDescriptionDtoToVspDetails.java @@ -38,6 +38,7 @@ public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescription target.setIcon(source.getIcon()); target.setVendorName(source.getVendorName()); target.setVendorId(source.getVendorId()); + target.setOnboardingMethod(source.getOnboardingMethod()); VersionDto vlmVersion = source.getLicensingVersion(); if (vlmVersion != null) { 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/mapping/MspVspDetailsToVspCreationDto.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/mapping/MapVspDetailsToVspCreationDto.java index 5480dc13d5..f009d8bbc6 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/mapping/MspVspDetailsToVspCreationDto.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/mapping/MapVspDetailsToVspCreationDto.java @@ -24,10 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; -/** - * Created by TALIO on 5/15/2016. - */ -public class MspVspDetailsToVspCreationDto extends MappingBase<VspDetails, VspCreationDto> { +public class MapVspDetailsToVspCreationDto extends MappingBase<VspDetails, VspCreationDto> { @Override public void doMapping(VspDetails source, VspCreationDto target) { target.setVspId(source.getId()); 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/ComponentMonitoringUploadsImpl.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/ComponentMonitoringUploadsImpl.java new file mode 100644 index 0000000000..a971782a15 --- /dev/null +++ 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/ComponentMonitoringUploadsImpl.java @@ -0,0 +1,117 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.core.enrichment.types.MonitoringUploadType; +import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager; +import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; +import org.openecomp.sdcrests.vsp.rest.ComponentMonitoringUploads; +import org.openecomp.sdcrests.vsp.rest.mapping.MapMonitoringUploadStatusToDto; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.io.InputStream; + +/** + * @author katyr + * @since June 26, 2017 + */ + +@Named +@Service("componentMonitoringUploads") +@Scope(value = "prototype") +//@Validated +public class ComponentMonitoringUploadsImpl implements ComponentMonitoringUploads { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private MonitoringUploadsManager + monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(ComponentMonitoringUploadsImpl.class); + + @Override + public Response upload(Attachment attachment, + String vspId, String versionId, String componentId, String type, + String user) throws Exception { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Upload_Monitoring_Artifact.toString()); + logger.audit(AuditMessages.AUDIT_MSG + String.format(AuditMessages + .UPLOAD_MONITORING_FILE, type, vspId, componentId)); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + monitoringUploadsManager.upload(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + monitoringUploadType, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); + return Response.ok().build(); + } + + private MonitoringUploadType getMonitoringUploadType(String vspId, String componentId, + String type) throws Exception { + MonitoringUploadType monitoringUploadType; + try { + monitoringUploadType = MonitoringUploadType.valueOf(type); + } catch (IllegalArgumentException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.ILLEGAL_MONITORING_ARTIFACT_TYPE.getErrorMessage(), + componentId, vspId); + throw new Exception(errorWithParameters, exception); + } + return monitoringUploadType; + } + + @Override + public Response delete(String vspId, String versionId, String componentId, + String type, String user) throws Exception { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Delete_Monitoring_Artifact.toString()); + + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + monitoringUploadsManager + .delete(vspId, version, componentId, monitoringUploadType, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); + return Response.ok().build(); + } + + @Override + public Response list(String vspId, String versionId, String componentId, + String user) { + MdcUtil.initMdc(LoggerServiceName.List_Monitoring_Artifacts.toString()); + + Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, version, componentId, user); + + MonitoringUploadStatus response = monitoringUploadsManager + .listFilenames(vspId, version, componentId, user); + + MonitoringUploadStatusDto returnEntity = + new MapMonitoringUploadStatusToDto() + .applyMapping(response, MonitoringUploadStatusDto.class); + return Response.status(Response.Status.OK).entity(returnEntity).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/ComponentUploadsImpl.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/ComponentUploadsImpl.java index 7a2a1578b6..f88508250a 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/ComponentUploadsImpl.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/ComponentUploadsImpl.java @@ -1,137 +1,142 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.vsp.rest.services; - -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.core.enrichment.types.ArtifactType; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.context.MdcUtil; -import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; -import org.openecomp.sdc.logging.messages.AuditMessages; -import org.openecomp.sdc.logging.types.LoggerServiceName; -import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; -import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; -import org.openecomp.sdc.vendorsoftwareproduct.MibManager; -import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory; -import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.types.VersionableEntityAction; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; -import org.openecomp.sdcrests.vsp.rest.ComponentUploads; -import org.openecomp.sdcrests.vsp.rest.mapping.MapMibUploadStatusToDto; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.InputStream; - -@Named -@Service("componentUploads") -@Scope(value = "prototype") -@Validated -public class ComponentUploadsImpl implements ComponentUploads { - private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - private MibManager mibManager = MibManagerFactory.getInstance().createInterface(); - private ComponentManager componentManager = - ComponentManagerFactory.getInstance().createInterface(); - private static final Logger logger = - LoggerFactory.getLogger(ComponentUploadsImpl.class); - - @Override - public Response uploadTrapMibFile(Attachment attachment, String vspId, String versionId, String componentId, - String user) { - mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); - MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); - logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_TRAP + vspId); - - Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); - componentManager.validateComponentExistence(vspId, version, componentId, user); - mibManager.upload(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - ArtifactType.SNMP_TRAP, user); - - mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); - return Response.ok().build(); - } - - @Override - public Response deleteTrapMibFile(String vspId, String versionId, String componentId, String user) { - mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); - MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); - - Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); - componentManager.validateComponentExistence(vspId, version, componentId, user); - mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_TRAP, user); - - mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); - return Response.ok().build(); - } - - @Override - public Response uploadPollMibFile(Attachment attachment, String vspId, String versionId, String componentId, - String user) { - - mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); - logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_POLL + vspId); - MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); - - Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); - componentManager.validateComponentExistence(vspId, version, componentId, user); - mibManager.upload(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - ArtifactType.SNMP_POLL, user); - - mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); - return Response.ok().build(); - } - - @Override - public Response deletePollMibFile(String vspId, String versionId, String componentId, String - user) { - mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); - MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); - - Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); - componentManager.validateComponentExistence(vspId, version, componentId, user); - mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_POLL, user); - - mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); - return Response.ok().build(); - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - MdcUtil.initMdc(LoggerServiceName.List_MIB_Files.toString()); - - Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); - componentManager.validateComponentExistence(vspId, version, componentId, user); - - MibUploadStatus response = mibManager.listFilenames(vspId, version, componentId, user); - - MibUploadStatusDto returnEntity = - new MapMibUploadStatusToDto().applyMapping(response, MibUploadStatusDto.class); - return Response.status(Response.Status.OK).entity(returnEntity).build(); - - } -} +///*- +// * ============LICENSE_START======================================================= +// * SDC +// * ================================================================================ +// * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +// * ================================================================================ +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// * ============LICENSE_END========================================================= +// */ +// +//package org.openecomp.sdcrests.vsp.rest.services; +// +//import org.apache.cxf.jaxrs.ext.multipart.Attachment; +//import org.openecomp.core.enrichment.types.MonitoringUploadType; +//import org.openecomp.sdc.logging.api.Logger; +//import org.openecomp.sdc.logging.api.LoggerFactory; +//import org.openecomp.sdc.logging.context.MdcUtil; +//import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +//import org.openecomp.sdc.logging.messages.AuditMessages; +//import org.openecomp.sdc.logging.types.LoggerServiceName; +//import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +//import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +//import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager; +//import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory; +//import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus; +//import org.openecomp.sdc.versioning.dao.types.Version; +//import org.openecomp.sdc.versioning.types.VersionableEntityAction; +//import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; +//import org.openecomp.sdcrests.vsp.rest.ComponentUploads; +//import org.openecomp.sdcrests.vsp.rest.mapping.MapMonitoringUploadStatusToDto; +//import org.springframework.context.annotation.Scope; +//import org.springframework.stereotype.Service; +//import org.springframework.validation.annotation.Validated; +// +//import javax.inject.Named; +//import javax.ws.rs.core.Response; +//import java.io.InputStream; +// +//@Named +//@Service("componentUploads") +//@Scope(value = "prototype") +//@Validated +//public class ComponentUploadsImpl implements ComponentUploads { +// private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); +// private MonitoringUploadsManager +// monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); +// private ComponentManager componentManager = +// ComponentManagerFactory.getInstance().createInterface(); +// private static final Logger logger = +// LoggerFactory.getLogger(ComponentUploadsImpl.class); +// +// @Override +// public Response uploadTrapMibFile(Attachment attachment, String vspId, String versionId, String componentId, +// String user) { +// mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); +// MdcUtil.initMdc(LoggerServiceName.Upload_Monitoring_Artifact.toString()); +// logger.audit(AuditMessages.AUDIT_MSG + String.format(AuditMessages.UPLOAD_MONITORING_FILE , +// vspId,componentId)); +// +// Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); +// componentManager.validateComponentExistence(vspId, version, componentId, user); +// monitoringUploadsManager.upload(attachment.getObject(InputStream.class), +// attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, +// MonitoringUploadType.SNMP_TRAP, user); +// +// mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); +// return Response.ok().build(); +// } +// +// @Override +// public Response deleteTrapMibFile(String vspId, String versionId, String componentId, String user) { +// mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); +// MdcUtil.initMdc(LoggerServiceName.Delete_Monitoring_Artifact.toString()); +// +// Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); +// componentManager.validateComponentExistence(vspId, version, componentId, user); +// monitoringUploadsManager +// .delete(vspId, version, componentId, MonitoringUploadType.SNMP_TRAP, user); +// +// mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); +// return Response.ok().build(); +// } +// +// @Override +// public Response uploadPollMibFile(Attachment attachment, String vspId, String versionId, String componentId, +// String user) { +// +// mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); +// logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_MONITORING_FILE + vspId); +// MdcUtil.initMdc(LoggerServiceName.Upload_Monitoring_Artifact.toString()); +// +// Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); +// componentManager.validateComponentExistence(vspId, version, componentId, user); +// monitoringUploadsManager.upload(attachment.getObject(InputStream.class), +// attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, +// MonitoringUploadType.SNMP_POLL, user); +// +// mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); +// return Response.ok().build(); +// } +// +// @Override +// public Response deletePollMibFile(String vspId, String versionId, String componentId, String +// user) { +// mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); +// MdcUtil.initMdc(LoggerServiceName.Delete_Monitoring_Artifact.toString()); +// +// Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); +// componentManager.validateComponentExistence(vspId, version, componentId, user); +// monitoringUploadsManager +// .delete(vspId, version, componentId, MonitoringUploadType.SNMP_POLL, user); +// +// mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); +// return Response.ok().build(); +// } +// +// @Override +// public Response list(String vspId, String versionId, String componentId, String user) { +// MdcUtil.initMdc(LoggerServiceName.List_Monitoring_Artifacts.toString()); +// +// Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); +// componentManager.validateComponentExistence(vspId, version, componentId, user); +// +// MonitoringUploadStatus response = monitoringUploadsManager +// .listFilenames(vspId, version, componentId, user); +// +// MonitoringUploadStatusDto returnEntity = +// new MapMonitoringUploadStatusToDto().applyMapping(response, MonitoringUploadStatusDto.class); +// return Response.status(Response.Status.OK).entity(returnEntity).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/ComponentsImpl.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/ComponentsImpl.java index a36534ae4f..51955b7b69 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/ComponentsImpl.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/ComponentsImpl.java @@ -7,9 +7,9 @@ * 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. @@ -32,6 +32,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; @@ -39,6 +40,7 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Components; import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDataToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentCreationDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentRequestDtoToComponentEntity; import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; @@ -93,8 +95,12 @@ public class ComponentsImpl implements Components { component.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); ComponentEntity createdComponent = componentManager.createComponent(component, user); + MapComponentEntityToComponentCreationDto mapping = + new MapComponentEntityToComponentCreationDto(); + ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent, + ComponentCreationDto.class); return Response - .ok(createdComponent != null ? new StringWrapperResponse(createdComponent.getId()) : null) + .ok(createdComponent != null ? createdComponentDto : null) .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/ComputeImpl.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/ComputeImpl.java new file mode 100644 index 0000000000..ec445af0e8 --- /dev/null +++ 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/ComputeImpl.java @@ -0,0 +1,162 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.Compute; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDataToComputeDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDetailsDtoToComputeEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("computes") +@Scope(value = "prototype") +public class ComputeImpl implements Compute { + private ComputeManager computetManager = + ComputeManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + + @Override + public Response list(String vspId, String version, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Computes.toString()); + Version vspVersion = resolveVspVersion(vspId, version, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<ListComputeResponse> computes = + computetManager + .listCompute(vspId, vspVersion, componentId, user); + + MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto(); + GenericCollectionWrapper<ComputeDto> results = new GenericCollectionWrapper<>(); + for (ListComputeResponse compute : computes) { + results.add(mapper.applyMapping(compute, ComputeDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response get(String vspId, String version, String componentId, String computeId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Compute.toString()); + Version vspVersion = resolveVspVersion(vspId, version, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + CompositionEntityResponse<ComputeData> response = computetManager + .getCompute(vspId, vspVersion, componentId, computeId, user); + + CompositionEntityResponseDto<ComputeDetailsDto> responseDto = new + CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComputeDataToComputeDetailsDto(), + ComputeDetailsDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } + + @Override + public Response create(ComputeDetailsDto request, String vspId, String versionId, + String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Compute.toString()); + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, + ComputeEntity.class); + compute.setVspId(vspId); + compute.setComponentId(componentId); + compute.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId, user); + + ComputeEntity createdCompute = computetManager.createCompute(compute, user); + + MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); + ComputeCreationDto createdComputeDto = mapper.applyMapping(createdCompute, ComputeCreationDto + .class); + return Response.ok(createdComputeDto != null ? createdComputeDto : null) + .build(); + } + + @Override + public Response update(ComputeDetailsDto request, String vspId, String versionId, String + componentId, String computeFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Compute.toString()); + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, + ComputeEntity.class); + compute.setVspId(vspId); + compute.setComponentId(componentId); + compute.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + compute.setId(computeFlavorId); + + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId, user); + CompositionEntityValidationData validationData = + computetManager.updateCompute(compute, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto().applyMapping(validationData, + CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); + } + + @Override + public Response delete(String vspId, String versionId, String componentId, String + computeFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Compute.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + computetManager.deleteCompute(vspId, version, componentId, computeFlavorId, user); + return Response.ok().build(); + } + + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String + computeFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Compute.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + QuestionnaireResponse questionnaireResponse = computetManager + .getComputeQuestionnaire(vspId, vspVersion, componentId, computeFlavorId, user); + + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, + String componentId, + String computeFlavorId, String user) { + MdcUtil + .initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString() + ); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + computetManager + .updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId, + questionnaireData, user); + return Response.ok().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/DeploymentFlavorsImpl.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/DeploymentFlavorsImpl.java new file mode 100644 index 0000000000..adcdacaa88 --- /dev/null +++ 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/DeploymentFlavorsImpl.java @@ -0,0 +1,129 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager; +import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; +import org.openecomp.sdcrests.vsp.rest.DeploymentFlavors; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityDeploymentFlavorToListResponse; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorToDeploymentDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("deploymentFlavors") +@Scope(value = "prototype") +public class DeploymentFlavorsImpl implements DeploymentFlavors +{ + private DeploymentFlavorManager deploymentFlavorManager = + DeploymentFlavorManagerFactory.getInstance().createInterface(); + + @Override + public Response create(DeploymentFlavorRequestDto request, String vspId, String versionId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Deployment_Flavor.toString()); + DeploymentFlavorEntity deploymentFlavorEntity = + new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() + .applyMapping(request, DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(resolveVspVersion(vspId, null, user, + VersionableEntityAction.Write)); + DeploymentFlavorEntity createdDeploymentFlavor = + deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user); + MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping = + new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); + DeploymentFlavorCreationDto deploymentFlavorCreatedDto= mapping.applyMapping + (createdDeploymentFlavor,DeploymentFlavorCreationDto.class); + return Response + .ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null) + .build(); + } + + @Override + public Response list(String vspId,String version,String user) { + MdcUtil.initMdc(LoggerServiceName.Get_List_Deployment_flavor.toString()); + Collection<DeploymentFlavorEntity> deploymentFlavors = + deploymentFlavorManager.listDeploymentFlavors(vspId, resolveVspVersion(vspId, version, user, + VersionableEntityAction.Read), user); + + MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new + MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); + GenericCollectionWrapper<DeploymentFlavorListResponseDto> results = new GenericCollectionWrapper<>(); + for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) { + results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class)); + } + return Response.ok(results).build(); + } + + @Override + public Response get(String vspId, String version, String deploymentFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Deployment_flavor.toString()); + CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager + .getDeploymentFlavor(vspId, resolveVspVersion(vspId, version, user, + VersionableEntityAction.Read), deploymentFlavorId, user); + + CompositionEntityResponseDto<DeploymentFlavorDto> responseDto = new + CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), DeploymentFlavorDto.class) + .doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } + + @Override + public Response getSchema(String vspId, String version, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Deployment_flavor.toString()); + CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager + .getDeploymentFlavorSchema(vspId, Version.valueOf(version), user); + return Response.ok(response).build(); + } + + @Override + public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Deployment_flavor.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user); + return Response.ok().build(); + } + + @Override + public Response update(DeploymentFlavorRequestDto request, String vspId, String versionId, + String deploymentFlavorId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Deployment_flavor.toString()); + DeploymentFlavorEntity deploymentFlavorEntity = + new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity().applyMapping(request, + DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + deploymentFlavorEntity.setId(deploymentFlavorId); + + CompositionEntityValidationData validationData = + deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto().applyMapping(validationData, + CompositionEntityValidationDataDto.class)).build() : Response.ok().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/ImagesImpl.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/ImagesImpl.java new file mode 100644 index 0000000000..c939eb57ae --- /dev/null +++ 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/ImagesImpl.java @@ -0,0 +1,175 @@ +package org.openecomp.sdcrests.vsp.rest.services; + + +import io.swagger.annotations.ApiParam; +import org.apache.commons.collections.CollectionUtils; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.ImageManager; +import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.Images; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageDataToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageRequestDtoToImageEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.core.Response; + + +@Named +@Service("images") +@Scope(value = "prototype") +public class ImagesImpl implements Images + { + + private ImageManager imageManager = ImageManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + + @Override + public Response create(ImageRequestDto request, String vspId, String versionId,String + componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Image.toString()); + ImageEntity image = + new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); + image.setVspId(vspId); + image.setComponentId(componentId); + image.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + componentManager.validateComponentExistence(vspId, image.getVersion(), componentId, user); + ImageEntity createdImage = imageManager.createImage(image, user); + MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto(); + ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class); + return Response + .ok(createdImage != null ? createdImageDto : null) + .build(); + } + + @Override + public Response getImageSchema(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.GET_Image_Schema.toString()); + CompositionEntityResponse<Image> response = + imageManager.getImageSchema(vspId, user); + return Response.ok(response).build(); + } + + @Override + public Response get(String vspId, String versionId, String componentId, String imageId, String + user) { + MdcUtil.initMdc(LoggerServiceName.GET_Image.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + CompositionEntityResponse<Image> response = imageManager.getImage(vspId, + vspVersion, componentId, imageId, user); + + return Response.ok(response).build(); + } + + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Images.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<ImageEntity> images = + imageManager.listImages(vspId, vspVersion, componentId, user); + + MapImageEntityToImageDto mapper = new MapImageEntityToImageDto(); + GenericCollectionWrapper<ImageDto> results = new GenericCollectionWrapper<>(); + for (ImageEntity image : images) { + results.add(mapper.applyMapping(image, ImageDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response delete(String vspId, String versionId, String componentId, String imageId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Image.toString()); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + imageManager.deleteImage(vspId, vspVersion, componentId, imageId, user); + return Response.ok().build(); + } + + @Override + public Response update(ImageRequestDto request, String vspId, String versionId, String + componentId, + String imageId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Image.toString()); + ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request, + ImageEntity.class); + imageEntity.setVspId(vspId); + imageEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + imageEntity.setComponentId(componentId); + imageEntity.setId(imageId); + componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId, user); + + CompositionEntityValidationData validationData = + imageManager.updateImage(imageEntity, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + Response.ok().build(); + } + + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String + imageId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Compute.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + QuestionnaireResponse questionnaireResponse = imageManager + .getImageQuestionnaire(vspId, vspVersion, componentId, imageId, + user); + + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + + } + + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String + versionId,String componentId,String imageId, String user) { + MdcUtil + .initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString() + ); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + imageManager.updateImageQuestionnaire(vspId, vspVersion, componentId, imageId, + questionnaireData, user); + return Response.ok().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/NicsImpl.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/NicsImpl.java index 922700671c..1612c964a1 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/NicsImpl.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/NicsImpl.java @@ -36,12 +36,14 @@ import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Nics; import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicCreationResponseDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapNicRequestDtoToNicEntity; import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; @@ -89,7 +91,11 @@ public class NicsImpl implements Nics { componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId, user); NicEntity createdNic = nicManager.createNic(nic, user); - return Response.ok(createdNic != null ? new StringWrapperResponse(createdNic.getId()) : null) + MapNicEntityToNicCreationResponseDto mapping = + new MapNicEntityToNicCreationResponseDto(); + NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic, + NicCreationResponseDto.class); + return Response.ok(createdNic != null ? createdNicDto : null) .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 c730066770..6dcb63dfdd 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 @@ -22,16 +22,24 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.openecomp.sdc.activityLog.ActivityLogManager; import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; import org.openecomp.sdc.logging.messages.AuditMessages; import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; @@ -42,16 +50,18 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapVersionedVendorSoftwareProductInfoToVspDetailsDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; -import org.openecomp.sdcrests.vsp.rest.mapping.MspVspDetailsToVspCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToVspCreationDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; import org.slf4j.MDC; @@ -62,6 +72,7 @@ import javax.inject.Named; import javax.ws.rs.core.Response; import java.io.File; import java.io.IOException; +import java.util.Collection; import java.util.List; @@ -79,21 +90,35 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - @Override - public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { - MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); - logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + vspDescriptionDto.getName()); - - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); - - vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); - - MspVspDetailsToVspCreationDto mapping = new MspVspDetailsToVspCreationDto(); - VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + @Override + public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + + vspDescriptionDto.getName()); + + VspCreationDto vspCreationDto = null; + switch (vspDescriptionDto.getOnboardingMethod()) { + case "HEAT": + case "Manual": + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails(). + applyMapping(vspDescriptionDto, VspDetails.class); + + vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); + + MapVspDetailsToVspCreationDto mapping = new MapVspDetailsToVspCreationDto(); + vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + break; + default: + ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder + .getInvalidOnboardingMethodErrorBuilder(); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.ADD_VSP, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message()); + throw new CoreException(onboardingMethodUpdateErrorCode); + } - return Response.ok(vspCreationDto).build(); - } + return Response.ok(vspCreationDto).build(); + } @Override public Response listVsps(String versionFilter, String user) { @@ -324,12 +349,26 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { vendorSoftwareProductManager.getInformationArtifact(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); - Response.ResponseBuilder response = Response.ok(textInformationArtifact); - if (textInformationArtifact == null) { - return Response.status(Response.Status.NOT_FOUND).build(); + Response.ResponseBuilder response = Response.ok(textInformationArtifact); + if (textInformationArtifact == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response + .header("Content-Disposition", "attachment; filename=" + textInformationArtifact.getName()); + return response.build(); } - response - .header("Content-Disposition", "attachment; filename=" + textInformationArtifact.getName()); - return response.build(); + + public Response listCompute(String vspId, String version, String user) { + + Collection<ComputeEntity> computes = vendorSoftwareProductManager.getComputeByVsp(vspId, + resolveVspVersion(vspId, version, user, VersionableEntityAction.Read), user); + + MapComputeEntityToVspComputeDto mapper = new MapComputeEntityToVspComputeDto(); + GenericCollectionWrapper<VspComputeDto> results = new GenericCollectionWrapper<>(); + for (ComputeEntity compute : computes) { + results.add(mapper.applyMapping(compute, VspComputeDto.class)); + } + + return Response.ok(results).build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..7fb5fd711e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-software-products-rest-types</artifactId> + <name>vendor-software-products-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java new file mode 100644 index 0000000000..a4ec05c074 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComponentCreationDto { + private String vfcId; + + public String getVfcId() { + return vfcId; + } + + public void setVfcId(String vfcId) { + this.vfcId = vfcId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java index 8d2fd4b48d..364e11936c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java @@ -7,9 +7,9 @@ * 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. @@ -20,11 +20,19 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + public class ComponentRequestDto { private String name; + @NotNull(message = "VFC displayName is mandatory.") + @Size(min = 1, max = 30,message = "VFC displayName length should be between 1 and 30.") private String displayName; + @Size(min = 0, max = 1000,message = "description length should not exceed 1000.") private String vfcCode; + private String nfcCode; + private String nfcFunction; private String description; public String getName() { @@ -58,4 +66,20 @@ public class ComponentRequestDto { public void setVfcCode(String vfcCode) { this.vfcCode = vfcCode; } + + public String getNfcCode() { + return nfcCode; + } + + public void setNfcCode(String nfcCode) { + this.nfcCode = nfcCode; + } + + public String getNfcFunction() { + return nfcFunction; + } + + public void setNfcFunction(String nfcFunction) { + this.nfcFunction = nfcFunction; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java new file mode 100644 index 0000000000..b5456b7e88 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java @@ -0,0 +1,25 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +import java.util.Set; + +public class ComponentValidationResultDto { + private boolean valid; + private Set<CompositionEntityValidationDataDto> validationData; + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public Set<CompositionEntityValidationDataDto> getValidationData() { + return validationData; + } + + public void setValidationData(Set<CompositionEntityValidationDataDto> validationData) { + this.validationData = validationData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java new file mode 100644 index 0000000000..f2b0689cd4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComputeCreationDto { + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java new file mode 100644 index 0000000000..1c4283acfc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java @@ -0,0 +1,31 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComputeDescription { + private String name; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ComputeDescription() { + + } + + public ComputeDescription(String name, String description) { + this.name = name; + this.description = description; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java new file mode 100644 index 0000000000..4b7889b16d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java @@ -0,0 +1,34 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.hibernate.validator.constraints.NotBlank; + +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +public class ComputeDetailsDto implements CompositionDataEntityDto { + @NotBlank(message = "is mandatory and should not be empty") + @Size(min = 0, max = 30, message = "length should not exceed 30 characters.") + @Pattern(regexp = "^[a-zA-Z 0-9._-]*$", message = "must match \"^[a-zA-Z 0-9._-]*$\"") + private String name; + @Size(min = 0, max = 300, message = "length should not exceed 300 characters.") + private String description; + + public ComputeDetailsDto() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java new file mode 100644 index 0000000000..829e2c58b5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java @@ -0,0 +1,40 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComputeDto { + private String name; + private String id; + private String description; + private boolean associatedToDeploymentFlavor; + + public boolean isAssociatedToDeploymentFlavor() { + return associatedToDeploymentFlavor; + } + + public void setAssociatedToDeploymentFlavor(boolean associatedToDeploymentFlavor) { + this.associatedToDeploymentFlavor = associatedToDeploymentFlavor; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java new file mode 100644 index 0000000000..d4c3443deb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +public class DeploymentFlavorCreationDto { + private String deploymentFlavorId; + + public String getDeploymentFlavorId() { + return deploymentFlavorId; + } + + public void setDeploymentFlavorId(String deploymentFlavorId) { + this.deploymentFlavorId = deploymentFlavorId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java new file mode 100644 index 0000000000..1748603d92 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class DeploymentFlavorDto extends DeploymentFlavorRequestDto implements CompositionDataEntityDto { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java new file mode 100644 index 0000000000..fe51c9ebac --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java @@ -0,0 +1,34 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +public class DeploymentFlavorListResponseDto { + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + private String model; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + private String id; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java new file mode 100644 index 0000000000..54ce63b252 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java @@ -0,0 +1,53 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +import org.hibernate.validator.constraints.NotBlank; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation; + +import java.util.List; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +public class DeploymentFlavorRequestDto { + @NotBlank(message = "is mandatory and should not be empty") + @Pattern(regexp = "^[a-zA-Z 0-9._-]*$", message = "must match \"^[a-zA-Z 0-9._-]*$\"") + @Size(min = 0, max = 30,message = "length should not exceed 30 characters.") + private String model; + @Size(min = 0, max = 300,message = "length should not exceed 300 characters.") + private String description; + private String featureGroupId; + private List<ComponentComputeAssociation> componentComputeAssociations; + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getFeatureGroupId() { + return featureGroupId; + } + + public void setFeatureGroupId(String featureGroupId) { + this.featureGroupId = featureGroupId; + } + + public List<ComponentComputeAssociation> getComponentComputeAssociations() { + return componentComputeAssociations; + } + + public void setComponentComputeAssociations(List<ComponentComputeAssociation> componentComputeAssociations) { + this.componentComputeAssociations = componentComputeAssociations; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java new file mode 100644 index 0000000000..d6f557c461 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java @@ -0,0 +1,25 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +import java.util.Set; + +public class DeploymentFlavorValidationResultDto { + private boolean valid; + private Set<CompositionEntityValidationDataDto> validationData; + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public Set<CompositionEntityValidationDataDto> getValidationData() { + return validationData; + } + + public void setValidationData(Set<CompositionEntityValidationDataDto> validationData) { + this.validationData = validationData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java new file mode 100644 index 0000000000..7e1987e4c2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ImageCreationDto { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java new file mode 100644 index 0000000000..7b300222aa --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +public class ImageDto extends ImageRequestDto implements CompositionDataEntityDto { + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java new file mode 100644 index 0000000000..6164522dda --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java @@ -0,0 +1,75 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.hibernate.validator.constraints.NotBlank; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +public class ImageRequestDto implements CompositionDataEntityDto { + + @NotBlank(message = "is mandatory and should not be empty") + @Pattern(regexp = "^[a-zA-Z 0-9._-]*$", message = "must match \"^[a-zA-Z 0-9._-]*$\"") + private String fileName; + private String description; + /*private String version; + private String format; + private String md5; + //private String providedBy;*/ + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + /*public String getMd5() { + return md5; + } + + public void setMd5(String md5) { + this.md5 = md5; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + /*public String getProvidedBy() { + return providedBy; + } + + public void setProvidedBy(String providedBy) { + this.providedBy = providedBy; + }*/ + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java index 7331115c3f..38cd631c02 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java @@ -20,12 +20,13 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -public class MibUploadStatusDto { +public class MonitoringUploadStatusDto { private String snmpTrap; private String snmpPoll; + private String vesEvent; - public MibUploadStatusDto() { + public MonitoringUploadStatusDto() { } public String getSnmpTrap() { @@ -40,7 +41,16 @@ public class MibUploadStatusDto { return snmpPoll; } + public String getVesEvent() { + return vesEvent; + } + + public void setVesEvent(String vesEvent) { + this.vesEvent = vesEvent; + } + public void setSnmpPoll(String snmpPoll) { this.snmpPoll = snmpPoll; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java new file mode 100644 index 0000000000..469e444a76 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +public class NicCreationResponseDto { + private String nicId; + + public String getNicId() { + return nicId; + } + + public void setNicId(String nicId) { + this.nicId = nicId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java index bd14012eee..fba85b64ed 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java @@ -20,11 +20,25 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import org.hibernate.validator.constraints.NotBlank; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.ValidateString; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + public class NicRequestDto { + @NotBlank(message = "is mandatory and should not be empty") + @Pattern(regexp = "^[a-zA-Z 0-9._-]*$", message = "must match \"^[a-zA-Z 0-9._-]*$\"") private String name; private String description; private String networkId; + @NotNull + @ValidateString(acceptedValues = {"External", "Internal"}, message = "doesn't " + + "meet the expected attribute value.", isCaseSensitive = true) + private String networkType; + + private String networkDescription; public String getName() { return name; @@ -49,4 +63,20 @@ public class NicRequestDto { public void setNetworkId(String networkId) { this.networkId = networkId; } + + public String getNetworkType(){ + return networkType; + } + + public void setNetworkType(String networkType){ + this.networkType = networkType; + } + + public String getNetworkDescription(){ + return networkDescription; + } + + public void setNetworkDescription(String networkDescription){ + this.networkDescription = networkDescription; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java new file mode 100644 index 0000000000..3059efb171 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java @@ -0,0 +1,6 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public enum OnboardingMethod { + HEAT, + Manual; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java index d76ae665ae..bc03ec9f49 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java @@ -33,6 +33,8 @@ public class ValidationResponseDto { private Collection<ErrorCodeDto> licensingDataErrors; private Map<String, List<ErrorMessageDto>> uploadDataErrors; private QuestionnaireValidationResultDto questionnaireValidationResult; + private ComponentValidationResultDto componentValidationResult; + private DeploymentFlavorValidationResultDto deploymentFlavorValidationResult; public boolean isValid() { return valid; @@ -74,4 +76,23 @@ public class ValidationResponseDto { QuestionnaireValidationResultDto questionnaireValidationResult) { this.questionnaireValidationResult = questionnaireValidationResult; } + + public ComponentValidationResultDto getComponentValidationResult() { + return componentValidationResult; + } + + public void setComponentValidationResult( + ComponentValidationResultDto componentValidationResult) { + this.componentValidationResult = componentValidationResult; + } + + public DeploymentFlavorValidationResultDto getDeploymentFlavorValidationResult() { + return deploymentFlavorValidationResult; + } + + public void setDeploymentFlavorValidationResult( + DeploymentFlavorValidationResultDto deploymentFlavorValidationResult) { + this.deploymentFlavorValidationResult = deploymentFlavorValidationResult; + } + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java new file mode 100644 index 0000000000..c7f9d12788 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java @@ -0,0 +1,72 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.ValidateString; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +public class VmSizing { + @Min(value = 1, message = "should be integer and > 0") + @Max(value = 16, message = "should be integer and <= 16") + private int numOfCPUs; + @Min(value = 1, message = "should be integer and > 0") + private int fileSystemSizeGB; + @Min(value = 1, message = "should be integer and > 0") + private int persistentStorageVolumeSize; + @Min(value = 1, message = "should be integer and > 0") + private int ioOperationsPerSec; + @ValidateString(acceptedValues = {"1:1", "4:1", "16:1"}, message = "doesn't meet the expected " + + "attribute value.") + private String cpuOverSubscriptionRatio; + @ValidateString(acceptedValues = {"1", "2", "4", "8"}, message = "doesn't meet the expected " + + "attribute value.") + private String memoryRAM; + + public int getNumOfCPUs() { + return numOfCPUs; + } + + public void setNumOfCPUs(int numOfCPUs) { + this.numOfCPUs = numOfCPUs; + } + + public int getFileSystemSizeGB() { + return fileSystemSizeGB; + } + + public void setFileSystemSizeGB(int fileSystemSizeGB) { + this.fileSystemSizeGB = fileSystemSizeGB; + } + + public int getPersistentStorageVolumeSize() { + return persistentStorageVolumeSize; + } + + public void setPersistentStorageVolumeSize(int persistentStorageVolumeSize) { + this.persistentStorageVolumeSize = persistentStorageVolumeSize; + } + + public int getIoOperationsPerSec() { + return ioOperationsPerSec; + } + + public void setIoOperationsPerSec(int ioOperationsPerSec) { + this.ioOperationsPerSec = ioOperationsPerSec; + } + + public String getCpuOverSubscriptionRatio() { + return cpuOverSubscriptionRatio; + } + + public void setCpuOverSubscriptionRatio(String cpuOverSubscriptionRatio) { + this.cpuOverSubscriptionRatio = cpuOverSubscriptionRatio; + } + + public String getMemoryRAM() { + return memoryRAM; + } + + public void setMemoryRAM(String memoryRAM) { + this.memoryRAM = memoryRAM; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java new file mode 100644 index 0000000000..a41ae5f0af --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java @@ -0,0 +1,31 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class VspComputeDto { + private String name; + private String componentId; + private String computeFlavorId; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getComponentId() { + return componentId; + } + + public void setComponentId(String componentId) { + this.componentId = componentId; + } + + public String getComputeFlavorId() { + return computeFlavorId; + } + + public void setComputeFlavorId(String computeFlavorId) { + this.computeFlavorId = computeFlavorId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java index 92e9d74bad..80b68deeeb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java @@ -25,9 +25,6 @@ import org.openecomp.sdcrests.common.types.VersionDto; import javax.validation.constraints.NotNull; -/** - * Created by TALIO on 4/20/2016. - */ public class VspDescriptionDto { @NotNull private String name; @@ -45,6 +42,9 @@ public class VspDescriptionDto { private VersionDto licensingVersion; // this will be populated with vlm version private LicensingData licensingData; + @NotNull + private String onboardingMethod; + public String getName() { return name; } @@ -116,4 +116,12 @@ public class VspDescriptionDto { public void setLicensingData(LicensingData licensingData) { this.licensingData = licensingData; } + + public String getOnboardingMethod() { + return onboardingMethod; + } + + public void setOnboardingMethod(String onboardingMethod) { + this.onboardingMethod = onboardingMethod; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java new file mode 100644 index 0000000000..0fc2fd7e82 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java @@ -0,0 +1,36 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; + +import java.util.ArrayList; +import java.util.List; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +public class StringValidator implements ConstraintValidator<ValidateString, String> { + + private List<String> valueList; + boolean isCaseSensitive; + + @Override + public void initialize(ValidateString constraintAnnotation) { + valueList = new ArrayList<String>(); + isCaseSensitive = constraintAnnotation.isCaseSensitive(); + for (String val : constraintAnnotation.acceptedValues()) { + if (!isCaseSensitive) { + val = val.toUpperCase(); + } + valueList.add(val); + } + } + + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + if (!isCaseSensitive) { + value = value.toUpperCase(); + } + if (value != null && !valueList.contains(value)) { + return false; + } + return true; + } + +}
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java new file mode 100644 index 0000000000..1218bb1c22 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java @@ -0,0 +1,44 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import javax.validation.Constraint; +import javax.validation.Payload; + +/** + * The interface Validate string. + */ +@Documented +@Constraint(validatedBy = StringValidator.class) +@Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER, CONSTRUCTOR}) +@Retention(RUNTIME) +public @interface ValidateString { + /** + * The constant message. + */ + String message = ""; + + /** + * Accepted values string [ ]. + * + * @return the string [ ] + */ + String[] acceptedValues(); + + String message() default "{org.openecomp.sdcrests.vendorsoftwareproducts.types.validation" + + ".message}"; + + boolean isCaseSensitive() default false; + + Class<?>[] groups() default {}; + + Class<? extends Payload>[] payload() default {}; +} diff --git a/openecomp-be/api/pom.xml.versionsBackup b/openecomp-be/api/pom.xml.versionsBackup new file mode 100644 index 0000000000..4c41573002 --- /dev/null +++ b/openecomp-be/api/pom.xml.versionsBackup @@ -0,0 +1,21 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>openecomp-sdc-api</artifactId> + <name>openecomp-sdc-api</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + <url>http://maven.apache.org</url> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <modules> + <module>/openecomp-sdc-rest-webapp</module> + </modules> + +</project>
\ No newline at end of file |