diff options
Diffstat (limited to 'services/activity-spec/activity-spec-web')
45 files changed, 2983 insertions, 0 deletions
diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/pom.xml b/services/activity-spec/activity-spec-web/activity-spec-service/pom.xml new file mode 100644 index 0000000000..13d0268fde --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/pom.xml @@ -0,0 +1,89 @@ +<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>activity-spec-service</artifactId> + <name>activity-spec-service</name> + + <parent> + <groupId>org.openecomp.activityspec</groupId> + <artifactId>activity-spec-web</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + + + <properties> + <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> + </properties> + + <dependencies> + <!--Cannot remove this dependency since it is being used in mappers as of now --> + <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> + <scope>runtime</scope> + </dependency> + + <!-- Java Stuff --> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-versioning-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-zusammen-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-zusammen-core</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>${org.codehaus.jackson.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-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${mvn.surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/ActivitySpecs.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/ActivitySpecs.java new file mode 100644 index 0000000000..f646a3b87a --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/ActivitySpecs.java @@ -0,0 +1,83 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.activityspec.api.rest.types.ActivitySpecActionRequestDto; +import org.openecomp.activityspec.api.rest.types.ActivitySpecRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +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/activity-spec/") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Activity Specs") +@Validated +public interface ActivitySpecs { + @POST + @Path("/") + @ApiOperation(value = "Create Activity Spec") + Response createActivitySpec(@Valid ActivitySpecRequestDto request); + + @GET + @Path("/{id}/versions/{versionId}") + @ApiOperation(value = "Get Activity Spec") + Response getActivitySpec(@ApiParam(value = "Activity Spec Id") @PathParam("id") + String id, + @ApiParam(value = "Version Id") @PathParam("versionId") + String versionId); + + @PUT + @Path("/{id}/versions/{versionId}") + @ApiOperation(value = "Update Activity Spec") + Response updateActivitySpec(@Valid ActivitySpecRequestDto request, + @ApiParam(value = "Activity Spec Id") @PathParam("id") + String id, + @ApiParam(value = "Version Id") @PathParam("versionId") + String versionId); + + @PUT + @Path("/{id}/versions/{versionId}/actions") + @ApiOperation(value = "Actions on a activity spec", + notes = "Performs one of the following actions on a activity spec: |" + + "Submit: Finalize its active version.|" + + "Deprecate: Deprecate activity spec.|") + Response actOnActivitySpec(ActivitySpecActionRequestDto request, + @ApiParam(value = "Activity Spec Id") @PathParam("id") String id, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId); + + @GET + @Path("/") + @ApiOperation(value = "Get list of activity specs ", + responseContainer = "List") + Response list(@ApiParam( + value = "Currently supported values: 'Certified' - only activity specs with Certified status") + @QueryParam("status") String versionStatus); +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivityParameterToDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivityParameterToDto.java new file mode 100644 index 0000000000..bd644ff4d6 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivityParameterToDto.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.activityspec.api.rest.types.ActivitySpecParameterDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapActivityParameterToDto extends MappingBase<ActivitySpecParameter, + ActivitySpecParameterDto> { + @Override + public void doMapping(ActivitySpecParameter source, ActivitySpecParameterDto target) { + target.setName(source.getName()); + target.setType(source.getType()); + target.setValue(source.getValue()); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecRequestDtoToActivitySpecEntity.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecRequestDtoToActivitySpecEntity.java new file mode 100644 index 0000000000..2062fe273b --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecRequestDtoToActivitySpecEntity.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import java.util.ArrayList; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.activityspec.api.rest.types.ActivitySpecRequestDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +import java.util.Objects; +import java.util.stream.Collectors; + +public class MapActivitySpecRequestDtoToActivitySpecEntity + extends MappingBase<ActivitySpecRequestDto, + ActivitySpecEntity> { + + @Override + public void doMapping(ActivitySpecRequestDto source, ActivitySpecEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setCategoryList(source.getCategoryList() == null ? new ArrayList<String>() + : source.getCategoryList()); + if (Objects.nonNull(source.getInputParameters())) { + target.setInputParameters(source.getInputParameters().stream() + .map(activitySpecParameterDto -> new MapDtoToActivityParameter() + .applyMapping(activitySpecParameterDto, ActivitySpecParameter.class)) + .collect(Collectors.toList())); + } + if (Objects.nonNull(source.getOutputParameters())) { + target.setOutputParameters(source.getOutputParameters().stream() + .map(activitySpecParameterDto -> new MapDtoToActivityParameter() + .applyMapping(activitySpecParameterDto, ActivitySpecParameter.class)) + .collect(Collectors.toList())); + } + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecCreateResponse.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecCreateResponse.java new file mode 100644 index 0000000000..13c881404f --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecCreateResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import java.util.Objects; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.api.rest.types.ActivitySpecCreateResponse; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapActivitySpecToActivitySpecCreateResponse extends MappingBase<ActivitySpecEntity, + ActivitySpecCreateResponse> { + + @Override + public void doMapping(ActivitySpecEntity source, ActivitySpecCreateResponse target) { + target.setId(source.getId()); + target.setVersionId(Objects.nonNull(source.getVersion()) ? source.getVersion().getId() : null); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecGetResponse.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecGetResponse.java new file mode 100644 index 0000000000..25e0f6e9c4 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapActivitySpecToActivitySpecGetResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.api.rest.types.ActivitySpecGetResponse; +import org.openecomp.activityspec.api.rest.types.ActivitySpecParameterDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +import java.util.Objects; +import java.util.stream.Collectors; + +public class MapActivitySpecToActivitySpecGetResponse extends MappingBase<ActivitySpecEntity, + ActivitySpecGetResponse> { + + @Override + public void doMapping(ActivitySpecEntity source, ActivitySpecGetResponse target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setCategoryList(source.getCategoryList()); + if (Objects.nonNull(source.getInputParameters())) { + target.setInputParameters(source.getInputParameters().stream().map( + activitySpecParameter -> new MapActivityParameterToDto() + .applyMapping(activitySpecParameter, ActivitySpecParameterDto + .class)).collect(Collectors.toList())); + } + if (Objects.nonNull(source.getOutputParameters())) { + target.setOutputParameters(source.getOutputParameters().stream().map( + activitySpecParameter -> new MapActivityParameterToDto() + .applyMapping(activitySpecParameter, ActivitySpecParameterDto + .class)).collect(Collectors.toList())); + } + target.setStatus(source.getStatus()); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapDtoToActivityParameter.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapDtoToActivityParameter.java new file mode 100644 index 0000000000..ccffaead76 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapDtoToActivityParameter.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.activityspec.api.rest.types.ActivitySpecParameterDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapDtoToActivityParameter extends MappingBase<ActivitySpecParameterDto, + ActivitySpecParameter> { + @Override + public void doMapping(ActivitySpecParameterDto source, ActivitySpecParameter target) { + target.setName(source.getName()); + target.setType(source.getType()); + target.setValue(source.getValue()); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapItemToListResponseDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapItemToListResponseDto.java new file mode 100644 index 0000000000..c85d5af427 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/mapping/MapItemToListResponseDto.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.mapping; + +import org.openecomp.activityspec.api.rest.types.ActivitySpecListResponseDto; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdcrests.mapping.MappingBase; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static org.openecomp.activityspec.utils.ActivitySpecConstant.CATEGORY_ATTRIBUTE_NAME; + +public class MapItemToListResponseDto extends MappingBase<Item, ActivitySpecListResponseDto> { + @Override + public void doMapping(Item source, ActivitySpecListResponseDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setCategoryList((List<String>) source.getProperties().get( + CATEGORY_ATTRIBUTE_NAME)); + final Map<VersionStatus, Integer> versionStatusCounters = source.getVersionStatusCounters(); + if (Objects.nonNull(versionStatusCounters) && !versionStatusCounters.isEmpty()) { + final Set<VersionStatus> versionStatuses = versionStatusCounters.keySet(); + target.setStatus(versionStatuses.stream().findFirst().isPresent() + ? versionStatuses.stream().findFirst().get().name() : null); + } + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/services/ActivitySpecsImpl.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/services/ActivitySpecsImpl.java new file mode 100644 index 0000000000..db2db40f6e --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/services/ActivitySpecsImpl.java @@ -0,0 +1,117 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.services; + +import org.openecomp.activityspec.api.rest.ActivitySpecs; +import org.openecomp.activityspec.api.rest.mapping.MapActivitySpecRequestDtoToActivitySpecEntity; +import org.openecomp.activityspec.api.rest.mapping.MapActivitySpecToActivitySpecCreateResponse; +import org.openecomp.activityspec.api.rest.mapping.MapActivitySpecToActivitySpecGetResponse; +import org.openecomp.activityspec.api.rest.mapping.MapItemToListResponseDto; +import org.openecomp.activityspec.api.rest.types.ActivitySpecActionRequestDto; +import org.openecomp.activityspec.api.rest.types.ActivitySpecCreateResponse; +import org.openecomp.activityspec.api.rest.types.ActivitySpecGetResponse; +import org.openecomp.activityspec.api.rest.types.ActivitySpecListResponseDto; +import org.openecomp.activityspec.api.rest.types.ActivitySpecRequestDto; +import org.openecomp.activityspec.api.rest.types.InternalEmptyObject; +import org.openecomp.activityspec.be.ActivitySpecManager; +import org.openecomp.activityspec.be.dao.impl.ActivitySpecDaoZusammenImpl; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.be.impl.ActivitySpecManagerImpl; +import org.openecomp.core.dao.UniqueValueDaoFactory; +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.sdc.versioning.ItemManagerFactory; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; + +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.ws.rs.core.Response; + +@Service("activitySpecs") +@Scope(value = "singleton") +@Validated +public class ActivitySpecsImpl implements ActivitySpecs { + + + private final ActivitySpecManager activitySpecManager = + new ActivitySpecManagerImpl(ItemManagerFactory.getInstance().createInterface(), + VersioningManagerFactory.getInstance().createInterface(), + new ActivitySpecDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()), + UniqueValueDaoFactory.getInstance().createInterface()); + + @Override + public Response createActivitySpec(ActivitySpecRequestDto request) { + ActivitySpecEntity activitySpec = new MapActivitySpecRequestDtoToActivitySpecEntity() + .applyMapping(request, ActivitySpecEntity.class); + + activitySpec = activitySpecManager.createActivitySpec(activitySpec); + ActivitySpecCreateResponse createActivitySpecResponse = + new MapActivitySpecToActivitySpecCreateResponse().applyMapping(activitySpec, + ActivitySpecCreateResponse.class); + + return Response.ok(createActivitySpecResponse).build(); + } + + @Override + public Response getActivitySpec(String activitySpecId, String versionId) { + ActivitySpecEntity activitySpec = new ActivitySpecEntity(); + activitySpec.setId(activitySpecId); + activitySpec.setVersion(new Version(versionId)); + final ActivitySpecEntity retrieved = activitySpecManager.get(activitySpec); + ActivitySpecGetResponse getResponse = new MapActivitySpecToActivitySpecGetResponse() + .applyMapping(retrieved, ActivitySpecGetResponse.class); + return Response.ok(getResponse).build(); + } + + @Override + public Response updateActivitySpec(ActivitySpecRequestDto request, String activitySpecId, + String versionId) { + ActivitySpecEntity activitySpec = new MapActivitySpecRequestDtoToActivitySpecEntity() + .applyMapping(request, ActivitySpecEntity.class); + + activitySpec.setId(activitySpecId); + activitySpec.setVersion(new Version(versionId)); + + activitySpecManager.update(activitySpec); + + return Response.ok(new InternalEmptyObject()).build(); + } + + @Override + public Response actOnActivitySpec(ActivitySpecActionRequestDto request, String activitySpecId, + String versionId) { + activitySpecManager.actOnAction(activitySpecId, versionId, request.getAction()); + return Response.ok(new InternalEmptyObject()).build(); + } + + @Override + public Response list(String versionStatus) { + + GenericCollectionWrapper<ActivitySpecListResponseDto> results = new GenericCollectionWrapper<>(); + MapItemToListResponseDto mapper = new MapItemToListResponseDto(); + activitySpecManager.list(versionStatus).stream() + .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .forEach(activitySpecItem -> results.add(mapper.applyMapping(activitySpecItem, + ActivitySpecListResponseDto.class))); + + return Response.ok(results).build(); + } + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecAction.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecAction.java new file mode 100644 index 0000000000..bedcfcb2da --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecAction.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +public enum ActivitySpecAction { + CERTIFY, + DEPRECATE, + DELETE +}
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecActionRequestDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecActionRequestDto.java new file mode 100644 index 0000000000..c9012120f1 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecActionRequestDto.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +@lombok.Data +public class ActivitySpecActionRequestDto { + private ActivitySpecAction action; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecCreateResponse.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecCreateResponse.java new file mode 100644 index 0000000000..9a654f780c --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecCreateResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +@lombok.Data +public class ActivitySpecCreateResponse { + private String id; + private String versionId; +} + diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecGetResponse.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecGetResponse.java new file mode 100644 index 0000000000..cf3fa969fa --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecGetResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +import java.util.List; + +@lombok.Data +public class ActivitySpecGetResponse { + private String name; + private String description; + private List<String> categoryList; + private List<ActivitySpecParameterDto> inputParameters; + private List<ActivitySpecParameterDto> outputParameters; + private String status; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecListResponseDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecListResponseDto.java new file mode 100644 index 0000000000..782143f620 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecListResponseDto.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +import java.util.List; + +@lombok.Data +public class ActivitySpecListResponseDto { + private String id; + private String version; + String name; + List<String> categoryList; + private String status; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecParameterDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecParameterDto.java new file mode 100644 index 0000000000..76e8262984 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecParameterDto.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +@lombok.Data +public class ActivitySpecParameterDto { + private String name; + private String type; + private String value; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecRequestDto.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecRequestDto.java new file mode 100644 index 0000000000..77ea393ce3 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/ActivitySpecRequestDto.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +import io.swagger.annotations.ApiModel; +import org.hibernate.validator.constraints.NotBlank; + +import javax.validation.constraints.Pattern; +import java.util.List; + +@ApiModel(value = "ActivitySpecRequest") +@lombok.Data +public class ActivitySpecRequestDto { + + @NotBlank(message = "is mandatory and should not be empty") + @Pattern(regexp = "^[a-zA-Z0-9-]*$", message = "must match \"^[a-zA-Z0-9-]*$\"") + private String name; + private String description; + + private List<String> categoryList; + private List<ActivitySpecParameterDto> inputParameters; + private List<ActivitySpecParameterDto> outputParameters; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/InternalEmptyObject.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/InternalEmptyObject.java new file mode 100644 index 0000000000..2faf7bcafa --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/rest/types/InternalEmptyObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.rest.types; + +import org.codehaus.jackson.annotate.JsonAutoDetect; + +/** + * Object of this class can be used to create empty Response body like "{}" + */ +@JsonAutoDetect +public class InternalEmptyObject { + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/filters/ActivitySpecSessionContextFilter.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/filters/ActivitySpecSessionContextFilter.java new file mode 100644 index 0000000000..715d0961e6 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/filters/ActivitySpecSessionContextFilter.java @@ -0,0 +1,83 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.server.filters; + +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response.Status; +import org.apache.commons.lang.StringUtils; +import org.openecomp.sdc.common.session.SessionContextProvider; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; + +import static org.openecomp.activityspec.utils.ActivitySpecConstant.TENANT; +import static org.openecomp.activityspec.utils.ActivitySpecConstant.USER; +import static org.openecomp.activityspec.utils.ActivitySpecConstant.USER_ID_HEADER_PARAM; + +public class ActivitySpecSessionContextFilter implements Filter { + + private static final String MESSAGE_USER_MAY_NOT_BE_NULL = "{\"message\": \"User ID can not be null\"}"; + + @Override + public void init(FilterConfig filterConfig) { + //No ActivitySpec specific initialization required + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, + FilterChain filterChain) throws IOException, ServletException { + + final String userHeader = ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); + + // Not a real security, just make sure the request + // has passed some authentication gateway + if (StringUtils.isEmpty(userHeader)) { + sendErrorResponse(servletResponse); + return; + } + + SessionContextProvider contextProvider = SessionContextProviderFactory.getInstance().createInterface(); + + try { + // use the system-wide user and tenant + contextProvider.create(USER, TENANT); + filterChain.doFilter(servletRequest, servletResponse); + } finally { + contextProvider.close(); + } + } + + private void sendErrorResponse(ServletResponse servletResponse) throws IOException { + HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; + httpServletResponse.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + httpServletResponse.setStatus(Status.UNAUTHORIZED.getStatusCode()); + servletResponse.getOutputStream().write(MESSAGE_USER_MAY_NOT_BE_NULL.getBytes()); + } + + @Override + public void destroy() { + //No ActivitySpec specific destroy required + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/listeners/ActivitySpecAppStartupListener.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/listeners/ActivitySpecAppStartupListener.java new file mode 100644 index 0000000000..8ddb7f3493 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/api/server/listeners/ActivitySpecAppStartupListener.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.api.server.listeners; + +import org.openecomp.sdc.common.session.SessionContextProviderFactory; +import org.springframework.web.context.ContextLoaderListener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import static org.openecomp.activityspec.utils.ActivitySpecConstant.TENANT; +import static org.openecomp.activityspec.utils.ActivitySpecConstant.USER; + +public class ActivitySpecAppStartupListener implements ServletContextListener { + + ContextLoaderListener springListener; + + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + SessionContextProviderFactory.getInstance().createInterface().create(USER, + TENANT); + springListener = new ContextLoaderListener(); + springListener.initWebApplicationContext(servletContextEvent.getServletContext()); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/ActivitySpecManager.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/ActivitySpecManager.java new file mode 100644 index 0000000000..4fa41d029a --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/ActivitySpecManager.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be; + +import java.util.Collection; + +import org.openecomp.activityspec.api.rest.types.ActivitySpecAction; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.sdc.versioning.types.Item; + +public interface ActivitySpecManager { + + ActivitySpecEntity createActivitySpec(ActivitySpecEntity activitySpecEntity); + + ActivitySpecEntity get(ActivitySpecEntity activitySpec); + + void update(ActivitySpecEntity activitySpec); + + void actOnAction(String activitySpecId, String versionId, ActivitySpecAction action); + + Collection<Item> list(String versionStatus); +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/ActivitySpecDao.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/ActivitySpecDao.java new file mode 100644 index 0000000000..375adac876 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/ActivitySpecDao.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.dao; + +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; + +public interface ActivitySpecDao { + void create(ActivitySpecEntity activitySpecEntity); + + ActivitySpecEntity get(ActivitySpecEntity activitySpec); + + void update(ActivitySpecEntity activitySpec); +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecDaoZusammenImpl.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecDaoZusammenImpl.java new file mode 100644 index 0000000000..d9d495a01a --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecDaoZusammenImpl.java @@ -0,0 +1,151 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.dao.impl; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; + +import org.openecomp.activityspec.be.dao.ActivitySpecDao; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.utils.ActivitySpecConstant; +import org.openecomp.activityspec.be.datatypes.ActivitySpecData; +import org.openecomp.activityspec.be.datatypes.ElementType; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Objects; +import java.util.Optional; + +import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + +public class ActivitySpecDaoZusammenImpl implements ActivitySpecDao { + + private final ZusammenAdaptor zusammenAdaptor; + + public ActivitySpecDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void create(ActivitySpecEntity entity) { + SessionContext context = createSessionContext(); + ZusammenElement generalElement = mapActivityDetailsToZusammenElement(entity, Action.CREATE); + + ElementContext elementContext = + new ElementContext(entity.getId(), entity.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, generalElement, + "Create Activity Spec General Info Element"); + } + + @Override + public ActivitySpecEntity get(ActivitySpecEntity entity) { + SessionContext context = createSessionContext(); + + ElementContext elementContext = new ElementContext(entity.getId(), entity.getVersion().getId()); + Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, + null, ElementType.ACTIVITYSPEC.name()); + if (element.isPresent()) { + return mapZusammenElementToActivityDetails(element.get()); + } else { + return null; + } + } + + @Override + public void update(ActivitySpecEntity entity) { + SessionContext context = createSessionContext(); + ZusammenElement generalElement = mapActivityDetailsToZusammenElement(entity, Action.UPDATE); + + ElementContext elementContext = + new ElementContext(entity.getId(), entity.getVersion().getId()); + zusammenAdaptor.saveElement(context, elementContext, generalElement, + "Update Activity Spec General Info Element"); + } + + + private ActivitySpecEntity mapZusammenElementToActivityDetails(Element element) { + ActivitySpecEntity entity = new ActivitySpecEntity(); + entity.setId(element.getElementId().getValue()); + enrichEntityFromElementData(entity, element.getData()); + enrichEntityFromElementInfo(entity, element.getInfo()); + return entity; + } + + private ZusammenElement mapActivityDetailsToZusammenElement(ActivitySpecEntity entity, + Action action) { + ZusammenElement generalElement = + buildStructuralElement(ElementType.ACTIVITYSPEC.name(), action); + + enrichElementInfoFromEntity(generalElement, entity); + enrichElementDataFromEntity(generalElement, entity); + return generalElement; + } + + + private void enrichEntityFromElementInfo(ActivitySpecEntity entity, Info info) { + entity.setName(info.getProperty(InfoPropertyName.NAME.getValue())); + entity.setDescription(info.getProperty(InfoPropertyName.DESCRIPTION.getValue())); + entity.setCategoryList(info.getProperty(InfoPropertyName.CATEGORY.getValue())); + } + + private void enrichEntityFromElementData(ActivitySpecEntity entity, InputStream data) { + ActivitySpecData activitySpecData = JsonUtil.json2Object(data, ActivitySpecData.class); + if (Objects.nonNull(activitySpecData)) { + entity.setInputParameters(activitySpecData.getInputParameters()); + entity.setOutputParameters(activitySpecData.getOutputParameters()); + } + } + + private void enrichElementInfoFromEntity(ZusammenElement element, ActivitySpecEntity entity) { + element.getInfo().addProperty(InfoPropertyName.DESCRIPTION.getValue(), entity.getDescription()); + element.getInfo().addProperty(InfoPropertyName.NAME.getValue(), entity.getName()); + element.getInfo().addProperty(InfoPropertyName.CATEGORY.getValue(), + entity.getCategoryList()); + } + + + private void enrichElementDataFromEntity(ZusammenElement element, ActivitySpecEntity entity) { + ActivitySpecData activitySpecData = new ActivitySpecData(); + activitySpecData.setInputParameters(entity.getInputParameters()); + activitySpecData.setOutputParameters(entity.getOutputParameters()); + element.setData(new ByteArrayInputStream(JsonUtil.object2Json(activitySpecData).getBytes())); + } + + public enum InfoPropertyName { + DESCRIPTION("description"), + NAME("name"), + CATEGORY(ActivitySpecConstant.CATEGORY_ATTRIBUTE_NAME); + + private final String value; + + InfoPropertyName(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/types/ActivitySpecEntity.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/types/ActivitySpecEntity.java new file mode 100644 index 0000000000..b21e424a2f --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/dao/types/ActivitySpecEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.dao.types; + +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; + +@lombok.Data +public class ActivitySpecEntity { + private String id; + private Version version; + private String name; + private String description; + + private List<String> categoryList; + private List<ActivitySpecParameter> inputParameters; + private List<ActivitySpecParameter> outputParameters; + + //Not to be maintained in activityspec element + private String status; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecData.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecData.java new file mode 100644 index 0000000000..e884bfc784 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecData.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.datatypes; + +import java.util.Collections; +import java.util.List; + +@lombok.Data +public class ActivitySpecData { + private List<ActivitySpecParameter> inputParameters = Collections.emptyList(); + private List<ActivitySpecParameter> outputParameters = Collections.emptyList(); +} + diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecParameter.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecParameter.java new file mode 100644 index 0000000000..b9153fa5d9 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ActivitySpecParameter.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.datatypes; + +@lombok.Data +public class ActivitySpecParameter { + private String name; + private String type; + private String value; + + @SuppressWarnings("unused") + public ActivitySpecParameter() { + // default constructor for automatic tools that use reflection + } + + public ActivitySpecParameter(String name, String type) { + this.name = name; + this.type = type; + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ElementType.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ElementType.java new file mode 100644 index 0000000000..be7e61ca8c --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ElementType.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.datatypes; + +public enum ElementType { + ACTIVITYSPEC; +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ItemType.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ItemType.java new file mode 100644 index 0000000000..5091412d08 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/datatypes/ItemType.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.datatypes; + +public enum ItemType { + ACTIVITYSPEC +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java new file mode 100644 index 0000000000..614728cc11 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java @@ -0,0 +1,291 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.impl; + +import static org.openecomp.activityspec.api.rest.types.ActivitySpecAction.CERTIFY; +import static org.openecomp.activityspec.api.rest.types.ActivitySpecAction.DELETE; +import static org.openecomp.activityspec.api.rest.types.ActivitySpecAction.DEPRECATE; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deleted; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deprecated; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Draft; + +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Predicate; +import org.openecomp.activityspec.api.rest.types.ActivitySpecAction; +import org.openecomp.activityspec.be.ActivitySpecManager; +import org.openecomp.activityspec.be.dao.ActivitySpecDao; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.be.datatypes.ItemType; +import org.openecomp.activityspec.utils.ActivitySpecConstant; +import org.openecomp.core.dao.UniqueValueDao; +import org.openecomp.core.util.UniqueValueUtil; +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.common.errors.SdcRuntimeException; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.versioning.ItemManager; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.VersionCreationMethod; + +public class ActivitySpecManagerImpl implements ActivitySpecManager { + + private static final Map<VersionStatus, Transition> TRANSITIONS; + + static { + TRANSITIONS = new EnumMap<>(VersionStatus.class); + TRANSITIONS.put(Certified, new Transition("Certify", Draft)); + TRANSITIONS.put(Deprecated, new Transition("Deprecate", Certified)); + TRANSITIONS.put(Deleted, new Transition("Delete", Deprecated)); + } + + private final ItemManager itemManager; + private final VersioningManager versioningManager; + private final ActivitySpecDao activitySpecDao; + private final UniqueValueUtil uniqueValueUtil; + private static final String ACTIVITY_SPEC_NAME = "ActivitySpec.Name"; + private static final Logger LOGGER = + LoggerFactory.getLogger(ActivitySpecManagerImpl.class); + + public ActivitySpecManagerImpl(ItemManager itemManager, + VersioningManager versioningManager, + ActivitySpecDao activitySpecDao, + UniqueValueDao uniqueValueDao) { + this.itemManager = itemManager; + this.versioningManager = versioningManager; + this.activitySpecDao = activitySpecDao; + this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao); + } + + @Override + public ActivitySpecEntity createActivitySpec(ActivitySpecEntity activitySpecEntity) { + + uniqueValueUtil.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpecEntity.getName()); + + Item item = getActivitySpecItem(activitySpecEntity); + item = itemManager.create(item); + + Version version = getActivitySpecVersion(activitySpecEntity); + versioningManager.create(item.getId(), version, VersionCreationMethod.major); + + enrichActivitySpec(item, version, activitySpecEntity); + activitySpecDao.create(activitySpecEntity); + + uniqueValueUtil.createUniqueValue(ACTIVITY_SPEC_NAME, activitySpecEntity.getName()); + return activitySpecEntity; + } + + private Version getActivitySpecVersion(ActivitySpecEntity activitySpecEntity) { + return activitySpecEntity.getVersion() == null ? new Version() + : activitySpecEntity.getVersion(); + + } + + @Override + public ActivitySpecEntity get(ActivitySpecEntity activitySpec) { + activitySpec.setVersion(calculateLatestVersion(activitySpec.getId(),activitySpec.getVersion() + )); + ActivitySpecEntity retrieved = null; + try { + retrieved = activitySpecDao.get(activitySpec); + } catch (SdcRuntimeException runtimeException) { + LOGGER.error("Failed to retrieve activity spec for activitySpecId: " + activitySpec.getId() + " and version: " + + activitySpec.getVersion().getId(), runtimeException); + validateActivitySpecExistence(activitySpec.getId(), activitySpec.getVersion()); + } + if (retrieved != null) { + final Version retrievedVersion = versioningManager.get(activitySpec.getId(), + activitySpec.getVersion()); + retrieved.setStatus(Objects.nonNull(retrievedVersion) ? retrievedVersion.getStatus().name() + : null); + } + return retrieved; + } + + @Override + public void update(ActivitySpecEntity activitySpec) { + + ActivitySpecEntity previousActivitySpec = get(activitySpec); + + if (!activitySpec.getName().equals(previousActivitySpec.getName())) { + uniqueValueUtil.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpec.getName()); + } + + activitySpecDao.update(activitySpec); + + if (!activitySpec.getName().equals(previousActivitySpec.getName())) { + uniqueValueUtil.createUniqueValue(ACTIVITY_SPEC_NAME, activitySpec.getName()); + itemManager.updateName(activitySpec.getId(), activitySpec.getName()); + uniqueValueUtil.deleteUniqueValue(ACTIVITY_SPEC_NAME, previousActivitySpec.getName()); + } + } + + @Override + public void actOnAction(String activitySpecId, String versionId, ActivitySpecAction action) { + Version version = new Version(versionId); + version = calculateLatestVersion(activitySpecId, version); + if (action == CERTIFY) { + version.setStatus(Certified); + } + if (action == DEPRECATE) { + version.setStatus(Deprecated); + } + if (action == DELETE) { + version.setStatus(Deleted); + } + + updateVersionStatus(activitySpecId, action, version); + if (action == DELETE) { + ActivitySpecEntity entity = new ActivitySpecEntity(); + entity.setId(activitySpecId); + entity.setVersion(version); + final ActivitySpecEntity activitySpecEntity = get(entity); + uniqueValueUtil.deleteUniqueValue(ACTIVITY_SPEC_NAME, activitySpecEntity.getName()); + } + } + + private void updateVersionStatus(String activitySpecId, ActivitySpecAction action, + Version version) { + VersionStatus prevVersionStatus = null; + Version retrievedVersion = null; + try { + retrievedVersion = versioningManager.get(activitySpecId, version); + } catch (SdcRuntimeException exception) { + LOGGER.error("Failed to get version for activitySpecId: " + activitySpecId + " and version: " + version.getId(), + exception); + validateActivitySpecExistence(activitySpecId, version); + + } + + VersionStatus status = version.getStatus(); + Transition transition = TRANSITIONS.get(status); + if (transition != null) { + String errMsg = String.format("%s ActivitySpec With Id %s failed since it is not in %s status", + transition.action, activitySpecId, transition.prevStatus); + validateStatus(Objects.nonNull(retrievedVersion) ? retrievedVersion.getStatus() : null, + transition.prevStatus, errMsg); + prevVersionStatus = transition.prevStatus; + } + + if (Objects.nonNull(retrievedVersion)) { + retrievedVersion.setStatus(status); + versioningManager.updateVersion(activitySpecId, retrievedVersion); + itemManager.updateVersionStatus(activitySpecId, status, prevVersionStatus); + versioningManager.publish(activitySpecId, retrievedVersion, "actionOnActivitySpec :" + + action.name()); + } + } + + private void validateActivitySpecExistence(String activitySpecId, Version version) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder() + .withCategory(ErrorCategory.APPLICATION) + .withId("ACTIVITYSPEC_NOT_FOUND") + .withMessage(String.format("Activity Spec With Id %s and version %s not found", + activitySpecId, version.getId())) + .build()); + } + + private void validateStatus(VersionStatus retrievedVersionStatus, + VersionStatus expectedVersionStatus, String errorMessage) { + if (retrievedVersionStatus != expectedVersionStatus) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder() + .withCategory(ErrorCategory.APPLICATION) + .withId("STATUS_NOT_" + expectedVersionStatus.name().toUpperCase()) + .withMessage(errorMessage).build()); + } + } + + private Version calculateLatestVersion(String activitySpecId, Version version) { + if (ActivitySpecConstant.VERSION_ID_DEFAULT_VALUE.equalsIgnoreCase(version.getId())) { + List<Version> list = null; + try { + list = versioningManager.list(activitySpecId); + } catch (SdcRuntimeException runtimeException) { + LOGGER.error("Failed to list versions for activitySpecId " + activitySpecId, runtimeException); + validateActivitySpecExistence(activitySpecId, version); + } + if (Objects.nonNull(list) && !list.isEmpty()) { + return list.get(0); + } + } + return version; + } + + @Override + public Collection<Item> list(String versionStatus) { + Predicate<Item> itemPredicate; + if (Objects.nonNull(versionStatus)) { + + VersionStatus statusEnumValue; + + try { + statusEnumValue = VersionStatus.valueOf(versionStatus); + } catch (IllegalArgumentException e) { + LOGGER.debug("Unexpected value of VersionStatus {}", versionStatus); + return Collections.emptyList(); + } + + itemPredicate = item -> ItemType.ACTIVITYSPEC.name().equals(item.getType()) + && item.getVersionStatusCounters().containsKey(statusEnumValue); + + } else { + itemPredicate = item -> ItemType.ACTIVITYSPEC.name().equals(item.getType()); + } + + return itemManager.list(itemPredicate); + } + + private void enrichActivitySpec(Item item, Version version, + ActivitySpecEntity activitySpecEntity) { + activitySpecEntity.setId(item.getId()); + activitySpecEntity.setVersion(version); + } + + private Item getActivitySpecItem(ActivitySpecEntity activitySpecEntity) { + Item item = new Item(); + item.setType(ItemType.ACTIVITYSPEC.name()); + item.setName(activitySpecEntity.getName()); + if (activitySpecEntity.getId() != null) { + item.setId(activitySpecEntity.getId()); + } + item.addProperty(ActivitySpecConstant.CATEGORY_ATTRIBUTE_NAME, + activitySpecEntity.getCategoryList()); + return item; + } + + private static class Transition { + + private final String action; + private final VersionStatus prevStatus; + + private Transition(String action, VersionStatus prevStatus) { + this.action = action; + this.prevStatus = prevStatus; + } + } + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/utils/ActivitySpecConstant.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/utils/ActivitySpecConstant.java new file mode 100644 index 0000000000..49752ecaef --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/utils/ActivitySpecConstant.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.utils; + +public class ActivitySpecConstant { + + public static final String CATEGORY_ATTRIBUTE_NAME = "category"; + public static final String VERSION_ID_DEFAULT_VALUE = "latest"; + public static final String TENANT = "activity_spec"; + public static final String USER = "activity_spec_USER"; + public static final String USER_ID_HEADER_PARAM = "USER_ID"; + + private ActivitySpecConstant(){ + //Utility Class declaring constants does not require instantiation. + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecZusammenDaoImplTest.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecZusammenDaoImplTest.java new file mode 100644 index 0000000000..e6b8123823 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/dao/impl/ActivitySpecZusammenDaoImplTest.java @@ -0,0 +1,400 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.dao.impl; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.commons.health.data.HealthInfo; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.Item; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import com.amdocs.zusammen.datatypes.item.ItemVersionData; +import com.amdocs.zusammen.datatypes.item.ItemVersionStatus; +import com.amdocs.zusammen.datatypes.item.Resolution; +import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions; +import com.amdocs.zusammen.datatypes.itemversion.Tag; +import java.io.InputStream; +import org.openecomp.activityspec.be.dao.impl.ActivitySpecDaoZusammenImpl.InfoPropertyName; +import org.openecomp.activityspec.be.datatypes.ActivitySpecData; +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.be.datatypes.ElementType; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.types.ElementPropertyName; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; + +import static org.mockito.Mockito.verify; +import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; + +public class ActivitySpecZusammenDaoImplTest { + + private static final Version version = new Version(); + private static final String versionId = "1234"; + private static final String itemId = "5678"; + private static final String tenant = "dox"; + + ZusammenAdaptorMock zusammenAdaptor; + ActivitySpecDaoZusammenImpl daoImpl; + ActivitySpecEntity entity; + + + @BeforeMethod + public void setUp(){ + SessionContextProviderFactory.getInstance().createInterface().create("test", + tenant); + zusammenAdaptor = new ZusammenAdaptorMock(); + daoImpl = new ActivitySpecDaoZusammenImpl(zusammenAdaptor); + entity = new ActivitySpecEntity(); + entity = new ActivitySpecEntity(); + + entity.setId(itemId); + version.setId(versionId); + entity.setVersion(version); + entity.setName("activitySpec"); + List<String> categoryList = new ArrayList<String>(); + categoryList.add("category1"); + entity.setCategoryList(categoryList); + ActivitySpecParameter inputParams = new ActivitySpecParameter("dbhost", "String"); + inputParams.setValue("localhost"); + List<ActivitySpecParameter> inputs = new ArrayList<>(); + inputs.add(inputParams); + entity.setInputParameters(inputs); + } + + @AfterMethod + public void tearDown(){ + SessionContextProviderFactory.getInstance().createInterface().close(); + } + + @Test + public void testCreate() { + ItemVersion itemVersionmock = new ItemVersion(); + itemVersionmock.setId(new Id()); + + daoImpl.create(entity); + SessionContext context = createSessionContext(); + ElementContext elementContext = + new ElementContext(entity.getId(), entity.getVersion().getId()); + Optional<ElementInfo> testElementInfo = + zusammenAdaptor.getElementInfoByName(context, elementContext,Id.ZERO, + ElementType.ACTIVITYSPEC.name() ); + Assert.assertTrue(testElementInfo.isPresent()); + Assert.assertEquals(testElementInfo.get().getInfo().getName(), ElementType.ACTIVITYSPEC.name()); + Assert.assertEquals(testElementInfo.get().getInfo().getProperty( + ActivitySpecDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue()), + entity.getDescription()); + Assert.assertEquals(testElementInfo.get().getInfo().getProperty( + InfoPropertyName.CATEGORY.getValue()), + entity.getCategoryList()); + Assert.assertEquals(testElementInfo.get().getInfo().getProperty( + ActivitySpecDaoZusammenImpl.InfoPropertyName.NAME.getValue()), + entity.getName()); + + final Optional<Element> testElement = zusammenAdaptor + .getElement(context, elementContext, zusammenAdaptor.elementId); + final InputStream data = testElement.get().getData(); + final ActivitySpecData activitySpecData = JsonUtil.json2Object(data, ActivitySpecData.class); + Assert.assertEquals(activitySpecData.getInputParameters().get(0).getName(), + entity.getInputParameters().get(0).getName()); + } + + @Test + public void testGet () { + SessionContext context = createSessionContext(); + ElementContext elementContext = + new ElementContext(entity.getId(), entity.getVersion().getId()); + final ActivitySpecEntity retrieved = daoImpl.get(entity); + Assert.assertEquals(retrieved.getName(), entity.getName()); + Assert.assertEquals(retrieved.getDescription(), entity.getDescription()); + Assert.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); + } + + @Test + public void testUpdate () { + SessionContext context = createSessionContext(); + ElementContext elementContext = + new ElementContext(entity.getId(), entity.getVersion().getId()); + entity.setDescription("Update AS version1"); + daoImpl.update(entity); + final ActivitySpecEntity retrieved = daoImpl.get(entity); + Assert.assertEquals(retrieved.getName(), entity.getName()); + Assert.assertEquals(retrieved.getDescription(), entity.getDescription()); + Assert.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); + } + + private class ZusammenAdaptorMock implements ZusammenAdaptor { + + private ItemVersion itemVersion; + private Map<String,Element> elementMap = new HashMap<>(); + String elementId; + + /* private void setItemVersion(ItemVersion itemVersion) { + this.itemVersion = itemVersion; + } + + private void addElementInfo(String key, ElementInfo elementInfo) { + elementInfoMap.put(key, elementInfo); + } + + private void addElement(Element element) { + elements.add(element); + }*/ + + @Override + public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) { + + return Optional.ofNullable(itemVersion); + } + + @Override + public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) { + return null; + } + + @Override + public ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId) { + return null; + } + + @Override + public Optional<Element> getElement(SessionContext context, ElementContext elementContext, + String elementId) { + return Optional.of(elementMap.get(elementId)); + } + + @Override + public Optional<Element> getElementByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + //return Optional.empty(); + ZusammenElement element = new ZusammenElement(); + Info info = new Info(); + element.setElementId(Id.ZERO); + info.addProperty("name", entity.getName()); + info.addProperty("description", entity.getDescription()); + info.addProperty("category", entity.getCategoryList()); + element.setInfo(info); + return Optional.ofNullable(element); + } + + @Override + public Collection<ElementInfo> listElements(SessionContext context, + ElementContext elementContext, + Id parentElementId) { + return null; + } + + @Override + public Collection<Element> listElementData(SessionContext context, + ElementContext elementContext, + Id parentElementId) { + return elementMap.values(); + } + + @Override + public Collection<ElementInfo> listElementsByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + + return elementMap.values().stream(). + filter(element->elementName.equals(element.getInfo().getProperty + (ElementPropertyName.elementType.name()))).map(element->{ + ElementInfo elementInfo = new ElementInfo(); + elementInfo.setId(element.getElementId()); + elementInfo.setInfo(element.getInfo()); + return elementInfo; + }).collect(Collectors.toList()); + + } + + @Override + public Optional<ElementInfo> getElementInfoByName(SessionContext context, + ElementContext elementContext, + Id parentElementId, String elementName) { + + + return elementMap.values().stream(). + filter(element -> elementName.equals(element.getInfo().getProperty + (ElementPropertyName.elementType.name()))).map(element -> { + ElementInfo elementInfo = new ElementInfo(); + elementInfo.setId(element.getElementId()); + elementInfo.setInfo(element.getInfo()); + return elementInfo; + }).findAny(); + + + + } + + @Override + public Element saveElement(SessionContext context, ElementContext elementContext, + ZusammenElement element, String message) { + if(element.getAction().equals(Action.CREATE) || + element.getAction().equals(Action.UPDATE)){ + element.setElementId(new Id(UUID.randomUUID().toString())); + } + elementMap.put(element.getElementId().getValue(),element); + elementId = element.getElementId().getValue(); + return element; + } + + @Override + public void resolveElementConflict(SessionContext context, ElementContext elementContext, + ZusammenElement element, Resolution resolution) { + + } + + @Override + public Collection<HealthInfo> checkHealth(SessionContext context) { + return null; + } + + @Override + public Id createItem(SessionContext context, Info info) { + return null; + } + + @Override + public void updateItem(SessionContext context, Id itemId, Info info) { + + } + + @Override + public Id createVersion(SessionContext context, Id itemId, Id baseVersionId, + ItemVersionData itemVersionData) { + return null; + } + + @Override + public void updateVersion(SessionContext context, Id itemId, Id versionId, + ItemVersionData itemVersionData) { + + } + + @Override + public ItemVersion getVersion(SessionContext context, Id itemId, Id versionId) { + return null; + } + + @Override + public ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId) { + return null; + } + + @Override + public ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId) { + return null; + } + + @Override + public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) { + + } + + @Override + public void resetVersionHistory(SessionContext context, Id itemId, Id versionId, + String changeRef) { + + } + + + @Override + public void publishVersion(SessionContext context, Id itemId, Id versionId, String message) { + + } + + @Override + public void syncVersion(SessionContext sessionContext, Id itemId, Id versionId) { + + } + + @Override + public void forceSyncVersion(SessionContext context, Id itemId, Id versionId) { + + } + + @Override + public Optional<ElementInfo> getElementInfo(SessionContext context, + ElementContext elementContext, + Id elementId) { + return Optional.empty(); + } + + @Override + public String getVersion(SessionContext sessionContext) { + return null; + } + + @Override + public void revert(SessionContext sessionContext, Id itemId, Id versionId, + Id revisionId) { + + } + + @Override + public ItemVersionRevisions listRevisions(SessionContext sessionContext, Id itemId, + Id versionId) { + return null; + } + + @Override + public Optional<ElementConflict> getElementConflict(SessionContext context, + ElementContext elementContext, + Id id) { + return Optional.empty(); + } + + @Override + public Collection<Item> listItems(SessionContext context) { + return null; + } + + @Override + public Item getItem(SessionContext context, Id itemId) { + return null; + } + + @Override + public void deleteItem(SessionContext context, Id itemId) { + + } + + } + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java new file mode 100644 index 0000000000..ce0f2883fa --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java @@ -0,0 +1,245 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.be.impl; + +import java.util.Collection; +import org.mockito.InjectMocks; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.openecomp.activityspec.api.rest.types.ActivitySpecAction; +import org.openecomp.activityspec.be.dao.ActivitySpecDao; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; +import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.core.dao.UniqueValueDao; +import org.openecomp.activityspec.mocks.ActivitySpecDaoMock; +import org.openecomp.activityspec.mocks.ItemManagerMock; +import org.openecomp.activityspec.mocks.UniqueValueDaoMock; +import org.openecomp.activityspec.mocks.VersionManagerMock; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; +import org.openecomp.sdc.versioning.ItemManager; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.Item; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +public class ActivitySpecManagerImplTest { + + private static final String STRING_TYPE = "String"; + ActivitySpecEntity activitySpec; + private ActivitySpecEntity retrieved; + private ActivitySpecEntity input; + private ActivitySpecEntity activitySpecToCreate; + + @Spy + @InjectMocks + private ActivitySpecManagerImpl activitySpecManager; + + + private ActivitySpecDao activitySpecDaoMock = new ActivitySpecDaoMock(); + + + private ItemManager itemManagerMock = new ItemManagerMock(); + + + private VersioningManager versionManagerMock = new VersionManagerMock() { + }; + + private UniqueValueDao uniqueValueDaoMock = new UniqueValueDaoMock(); + private ActivitySpecEntity retrivedAfterNameUpdate; + + @BeforeMethod + public void setUp() { + MockitoAnnotations.initMocks(this); + activitySpecManager = new ActivitySpecManagerImpl(itemManagerMock, versionManagerMock, + activitySpecDaoMock, uniqueValueDaoMock); + } + + @AfterMethod + public void tearDown() { + activitySpecManager = null; + } + + + public static final Version VERSION01 = new Version("12345"); + + @Test + public void testCreate() { + + SessionContextProviderFactory.getInstance().createInterface().create("testUser", "testTenant"); + + activitySpecToCreate = new ActivitySpecEntity(); + activitySpecToCreate.setName("startserver"); + activitySpecToCreate.setDescription("start the server"); + activitySpecToCreate.setVersion(VERSION01); + + List<String> categoryList = new ArrayList<>(); + categoryList.add("category1"); + categoryList.add("category2"); + activitySpecToCreate.setCategoryList(categoryList); + + ActivitySpecParameter inputParams = new ActivitySpecParameter("dbhost", STRING_TYPE); + inputParams.setValue("localhost"); + ActivitySpecParameter inputParams1 = new ActivitySpecParameter("dbname", STRING_TYPE); + inputParams.setValue("prod"); + List<ActivitySpecParameter> inputs = new ArrayList<>(); + inputs.add(inputParams); + inputs.add(inputParams1); + activitySpecToCreate.setInputParameters(inputs); + + ActivitySpecParameter outputParams = new ActivitySpecParameter("status", STRING_TYPE); + outputParams.setValue("started"); + List<ActivitySpecParameter> outputs = new ArrayList<>(); + outputs.add(outputParams); + activitySpecToCreate.setOutputParameters(outputs); + + activitySpec = activitySpecManager.createActivitySpec + (activitySpecToCreate); + + Assert.assertNotNull(activitySpec); + activitySpecToCreate.setId(activitySpec.getId()); + activitySpecToCreate.setVersion(VERSION01); + assertActivitySpecEquals(activitySpec, activitySpecToCreate); + } + + @Test(dependsOnMethods = "testCreate") + public void testList () { + //List + final Collection<Item> activitySpecs = activitySpecManager.list("Certified"); + Assert.assertEquals(activitySpecs.size(), 1); + } + + @Test(dependsOnMethods = "testCreate") + public void testGet () { + //Get + input = new ActivitySpecEntity(); + input.setId(activitySpec.getId()); + input.setVersion(activitySpec.getVersion()); + retrieved = activitySpecManager.get(input); + assertActivitySpecEquals(retrieved, activitySpec); + Assert.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); + + input.setVersion(new Version("LATEST")); + retrieved = activitySpecManager.get(input); + assertActivitySpecEquals(retrieved, activitySpec); + Assert.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); + } + + @Test(dependsOnMethods = "testGet") + public void testInvalidDeprecate () { + try { + activitySpecManager.actOnAction(retrieved.getId(), + VERSION01.getId(), ActivitySpecAction.DEPRECATE); + } + catch (CoreException exception) { + Assert.assertEquals(exception.code().id(), "STATUS_NOT_"+VersionStatus.Certified.name() + .toUpperCase()); + } + } + + @Test(dependsOnMethods = "testGet") + public void testInvalidDelete () { + try { + activitySpecManager.actOnAction(retrieved.getId(), + VERSION01.getId(), ActivitySpecAction.DELETE); + } + catch (CoreException exception) { + Assert.assertEquals(exception.code().id(), "STATUS_NOT_"+VersionStatus.Deprecated.name() + .toUpperCase()); + } + } + + @Test(dependsOnMethods = "testGet") + public void testUpdate () { + //Update + retrieved.setDescription("Updated_install"); + activitySpecManager.update(retrieved); + + final ActivitySpecEntity retrivedAfterUpdate = activitySpecManager.get(input); + assertActivitySpecEquals(retrivedAfterUpdate, activitySpecToCreate); + + //Update Name + ActivitySpecEntity activitySpecToUpdate = new ActivitySpecEntity(); + activitySpecToUpdate.setId(activitySpec.getId()); + activitySpecToUpdate.setName("Updated_start_server"); + activitySpecToUpdate.setVersion(activitySpec.getVersion()); + + activitySpecManager.update(activitySpecToUpdate); + + retrivedAfterNameUpdate = activitySpecManager.get(input); + assertActivitySpecEquals(retrivedAfterNameUpdate, activitySpecToUpdate); + Assert.assertEquals(retrivedAfterNameUpdate.getStatus(), VersionStatus.Draft.name()); + } + + @Test(dependsOnMethods = "testUpdate") + public void testCertify () { + activitySpecManager.actOnAction(retrivedAfterNameUpdate.getId(), + VERSION01.getId(), ActivitySpecAction.CERTIFY); + + final ActivitySpecEntity retrivedAfterCertify = activitySpecManager.get(retrivedAfterNameUpdate); + assertActivitySpecEquals(retrivedAfterCertify, retrivedAfterNameUpdate ); + Assert.assertEquals(retrivedAfterCertify.getStatus(), VersionStatus.Certified.name()); + } + + @Test(dependsOnMethods = "testCertify") + public void testInvalidCertify () { + try { + activitySpecManager.actOnAction(retrieved.getId(), + VERSION01.getId(), ActivitySpecAction.CERTIFY); + } + catch (CoreException exception) { + Assert.assertEquals(exception.code().id(), "STATUS_NOT_"+VersionStatus.Draft.name() + .toUpperCase()); + } + } + + @Test(dependsOnMethods = "testCertify") + public void testDeprecate () { + activitySpecManager.actOnAction(retrivedAfterNameUpdate.getId(), + retrivedAfterNameUpdate.getVersion().getId(), ActivitySpecAction.DEPRECATE); + + final ActivitySpecEntity retrivedAfterDeprecate = activitySpecManager.get(retrivedAfterNameUpdate); + assertActivitySpecEquals(retrivedAfterDeprecate, retrivedAfterNameUpdate ); + Assert.assertEquals(retrivedAfterDeprecate.getStatus(), VersionStatus.Deprecated.name()); + } + + @Test(dependsOnMethods = "testDeprecate") + public void testDelete () { + activitySpecManager.actOnAction(retrivedAfterNameUpdate.getId(), + retrivedAfterNameUpdate.getVersion().getId(), ActivitySpecAction.DELETE); + + final ActivitySpecEntity retrivedAfterDelete = activitySpecManager.get(retrivedAfterNameUpdate); + assertActivitySpecEquals(retrivedAfterDelete, retrivedAfterNameUpdate ); + Assert.assertEquals(retrivedAfterDelete.getStatus(), VersionStatus.Deleted.name()); + } + + private void assertActivitySpecEquals(ActivitySpecEntity actual, ActivitySpecEntity expected) { + Assert.assertEquals(actual.getId(), expected.getId()); + Assert.assertEquals(actual.getName(), expected.getName()); + Assert.assertEquals(actual.getDescription(), expected.getDescription()); + Assert.assertEquals(actual.getCategoryList(), expected.getCategoryList()); + Assert.assertEquals(actual.getInputParameters(), expected.getInputParameters()); + Assert.assertEquals(actual.getOutputParameters(), expected.getOutputParameters()); + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ActivitySpecDaoMock.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ActivitySpecDaoMock.java new file mode 100644 index 0000000000..4e21435900 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ActivitySpecDaoMock.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.mocks; + +import org.openecomp.activityspec.be.dao.ActivitySpecDao; +import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; + +public class ActivitySpecDaoMock implements ActivitySpecDao { + public ActivitySpecEntity activitySpec; + + @Override + public void create(ActivitySpecEntity activitySpecEntity) { + activitySpec = activitySpecEntity; + } + + @Override + public ActivitySpecEntity get(ActivitySpecEntity activitySpecEntity) { + return activitySpec; + } + + @Override + public void update(ActivitySpecEntity activitySpecEntity) { + activitySpec = activitySpecEntity; + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ItemManagerMock.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ItemManagerMock.java new file mode 100644 index 0000000000..667a97b3a4 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/ItemManagerMock.java @@ -0,0 +1,81 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.mocks; + + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.ItemManager; +import java.util.Collection; +import java.util.UUID; +import java.util.function.Predicate; + +public class ItemManagerMock implements ItemManager { + + public String id; + public Item item; + + + @Override + public Collection<Item> list(Predicate<Item> predicate) { + List<Item> items = new ArrayList<>(); + items.add(item); + Collection<Item> collection = items; + return items; + } + + @Override + public Item get(String itemId) { + return null; + } + + @Override + public Item create(Item item) { + this.id = UUID.randomUUID().toString(); + item.setId(this.id); + this.item = item; + return item; + } + + @Override + public void updateVersionStatus(String itemId, VersionStatus addedVersionStatus, + VersionStatus removedVersionStatus) { + + } + + + + @Override + public void updateName(String itemId, String name) { + + } + + @Override + public void update(Item item) { + + } + + @Override + public void delete(Item item) { + + } + +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/UniqueValueDaoMock.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/UniqueValueDaoMock.java new file mode 100644 index 0000000000..675c3b1878 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/UniqueValueDaoMock.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.mocks; + +import org.openecomp.core.dao.UniqueValueDao; +import org.openecomp.core.dao.types.UniqueValueEntity; + +import java.util.Collection; + +public class UniqueValueDaoMock implements UniqueValueDao { + @Override + public Collection<UniqueValueEntity> list(UniqueValueEntity entity) { + return null; + } + + @Override + public void create(UniqueValueEntity entity) { + + } + + @Override + public void update(UniqueValueEntity entity) { + + } + + @Override + public UniqueValueEntity get(UniqueValueEntity entity) { + return null; + } + + @Override + public void delete(UniqueValueEntity entity) { + + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/VersionManagerMock.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/VersionManagerMock.java new file mode 100644 index 0000000000..4b1deb3741 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/mocks/VersionManagerMock.java @@ -0,0 +1,105 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.activityspec.mocks; + +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.dao.types.Revision; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.VersionCreationMethod; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deprecated; +import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deleted; + +public class VersionManagerMock implements VersioningManager { + + private String id; + private Version version; + + + @Override + public List<Version> list(String itemId) { + List<Version> versions = new ArrayList<Version>(); + versions.add(version); + return versions; + } + + + @Override + public Version get(String itemId, Version version) { + return this.version; + } + + @Override + public Version create(String itemId, Version version, VersionCreationMethod creationMethod) { + this.id = UUID.randomUUID().toString(); + version.setId(this.id); + version.setStatus(VersionStatus.Draft); + this.version = version; + + return version; + } + + @Override + public void submit(String itemId, Version version, String submitDescription) { + + } + + + @Override + public void publish(String itemId, Version version, String message) { + + } + + @Override + public void sync(String itemId, Version version) { + + } + + @Override + public void forceSync(String itemId, Version version) { + + } + + @Override + public void revert(String itemId, Version version, String revisionId) { + + } + + @Override + public List<Revision> listRevisions(String itemId, Version version) { + return null; + } + + @Override + public void updateVersion(String itemId, Version version) { + if (version.getStatus() == Certified) { + this.version.setStatus(Certified); + } + if (version.getStatus() == Deprecated) { + this.version.setStatus(Deprecated); + } + if (version.getStatus() == Deleted) { + this.version.setStatus(Deleted); + } + } +} diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/pom.xml b/services/activity-spec/activity-spec-web/activity-spec-war/pom.xml new file mode 100644 index 0000000000..dba32097a8 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/pom.xml @@ -0,0 +1,78 @@ +<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>activityspec-war</artifactId> + <name>activityspec-war</name> + <packaging>war</packaging> + + <parent> + <groupId>org.openecomp.activityspec</groupId> + <artifactId>activity-spec-web</artifactId> + <version>1.2.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.activityspec</groupId> + <artifactId>activity-spec-service</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>${mvn.war.version}</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>${mvn.swagger.version}</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>false</springmvc> + <locations>org.openecomp.activityspec</locations> + <schemes>http</schemes> + <basePath>/activityspec-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> + </build> + +</project>
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/beans-services.xml b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/beans-services.xml new file mode 100644 index 0000000000..3d79d1e305 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/beans-services.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + + + <import resource="classpath:META-INF/cxf/cxf.xml"/> + <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> + + <!-- Needed for JSR-303 validations. May be removed when moving to JAX-RS 2.0 --> + <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/> + + <bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper"> + <property name="serializationInclusion" value="NON_NULL"/> + </bean> + + <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"> + <property name="mapper" ref="jacksonObjectMapper"/> + </bean> + + <!-- ASDC --> + + <!-- aspect beans --> + <bean id = "activitySpecs" + class="org.openecomp.activityspec.api.rest.services.ActivitySpecsImpl"/> + + <!-- RESTful Services --> + <jaxrs:server id="restContainer" address="/"> + + <jaxrs:serviceBeans> + <ref bean="activitySpecs"/> + </jaxrs:serviceBeans> + + <jaxrs:providers> + <ref bean="jsonProvider"/> + <bean class="org.openecomp.sdcrests.errors.DefaultExceptionMapper"/> + </jaxrs:providers> + + </jaxrs:server> + +</beans>
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/jetty-web.xml b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 0000000000..9426b13ccc --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Configure PUBLIC + "-//Mort Bay Consulting//DTD Configure//EN" + "http://www.eclipse.org/jetty/configure_9_0.dtd"> + +<Configure class="org.eclipse.jetty.webapp.WebAppContext"> + <Set name="contextPath">/activityspec-api</Set> +</Configure> diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml new file mode 100644 index 0000000000..5a32dd432a --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml @@ -0,0 +1,13 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + + + <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> + <property name="mappings"> + <props/> + </property> + </bean> + +</beans>
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/web.xml b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..e6be3b0a11 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,77 @@ +<web-app + xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> + + + <!-- Spring --> + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value>WEB-INF/beans-services.xml</param-value> + </context-param> + + <listener> + <listener-class>org.openecomp.activityspec.api.server.listeners.ActivitySpecAppStartupListener</listener-class> + </listener> + + + <filter> + <filter-name>LoggingServletFilter</filter-name> + <filter-class>org.openecomp.sdc.logging.servlet.LoggingFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>LoggingServletFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <filter> + <filter-name>SessionContextFilter</filter-name> + <filter-class>org.openecomp.activityspec.api.server.filters.ActivitySpecSessionContextFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>SessionContextFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <!-- Spring WS Mapping --> + <servlet> + <servlet-name>spring-mapper</servlet-name> + <servlet-class> + org.springframework.web.servlet.DispatcherServlet + </servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <!-- CXF --> + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class> + org.apache.cxf.transport.servlet.CXFServlet + </servlet-class> + <init-param> + <param-name>redirects-list</param-name> + <param-value> + /docs/(\S)+\.json + </param-value> + </init-param> + <init-param> + <param-name>redirect-attributes</param-name> + <param-value> + javax.servlet.include.request_uri + </param-value> + </init-param> + <init-param> + <param-name>redirect-servlet-name</param-name> + <param-value>default</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>spring-mapper</servlet-name> + <url-pattern>/ws/*</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> +</web-app> diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/templates/markdown.hbs b/services/activity-spec/activity-spec-web/activity-spec-war/templates/markdown.hbs new file mode 100644 index 0000000000..cc87c38244 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/templates/markdown.hbs @@ -0,0 +1,105 @@ +#{{#info}}{{title}} + + +## {{join schemes " | "}}://{{host}}{{basePath}} + + +{{description}} + +{{#contact}} +[**Contact the developer**](mailto:{{email}}) +{{/contact}} + +**Version** {{version}} + +{{#license}}[**{{name}}**]({{url}}){{/license}} + +{{/info}} + +{{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}} + +{{#if produces}}**Produces:** {{join produces ", "}}{{/if}} + +{{#if securityDefinitions}} +# Security Definitions +{{/if}} +{{> security}} + +# APIs + +{{#each paths}} +## {{@key}} +{{#this}} +{{#get}} +### GET +{{> operation}} +{{/get}} + +{{#put}} +### PUT +{{> operation}} +{{/put}} + +{{#post}} +### POST + +{{> operation}} + +{{/post}} + +{{#delete}} +### DELETE +{{> operation}} +{{/delete}} + +{{#option}} +### OPTION +{{> operation}} +{{/option}} + +{{#patch}} +### PATCH +{{> operation}} +{{/patch}} + +{{#head}} +### HEAD +{{> operation}} +{{/head}} + +{{/this}} +{{/each}} + +# Definitions +{{#each definitions}} +## <a name="/definitions/{{key}}">{{@key}}</a> + +<table border="1"> + <tr> + <th>name</th> + <th>type</th> + <th>required</th> + <th>description</th> + <th>example</th> + </tr> + {{#each this.properties}} + <tr> + <td>{{@key}}</td> + <td> + {{#ifeq type "array"}} + {{#items.$ref}} + {{type}}[<a href="{{items.$ref}}">{{basename items.$ref}}</a>] + {{/items.$ref}} + {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}} + {{else}} + {{#$ref}}<a href="{{$ref}}">{{basename $ref}}</a>{{/$ref}} + {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}} + {{/ifeq}} + </td> + <td>{{#required}}required{{/required}}{{^required}}optional{{/required}}</td> + <td>{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}</td> + <td>{{example}}</td> + </tr> + {{/each}} +</table> +{{/each}}
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/templates/operation.hbs b/services/activity-spec/activity-spec-web/activity-spec-war/templates/operation.hbs new file mode 100644 index 0000000000..375d4f7701 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/templates/operation.hbs @@ -0,0 +1,73 @@ +{{#deprecated}}-deprecated-{{/deprecated}} +<a id="{{operationId}}">{{summary}}</a> + +{{description}} + +{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}}) +{{/if}} + +{{#if security}} +#### Security +{{/if}} + +{{#security}} +{{#each this}} +* {{@key}} +{{#this}} * {{this}} +{{/this}} +{{/each}} +{{/security}} + +#### Request + +{{#if consumes}} +**Content-Type: ** {{join consumes ", "}}{{/if}} + +##### Parameters +{{#if parameters}} +<table border="1"> + <tr> + <th>Name</th> + <th>Located in</th> + <th>Required</th> + <th>Description</th> + <th>Default</th> + <th>Schema</th> + </tr> +{{/if}} + +{{#parameters}} +<tr> + <th>{{name}}</th> + <td>{{in}}</td> + <td>{{#if required}}yes{{else}}no{{/if}}</td> + <td>{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}</td> + <td>{{#if defaultValue}}{{defaultValue}}{{else}} - {{/if}}</td> +{{#ifeq in "body"}} + <td> + {{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}} + {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a> {{/schema.$ref}} + </td> +{{else}} + {{#ifeq type "array"}} + <td>Array[{{items.type}}] ({{collectionFormat}})</td> + {{else}} + <td>{{type}} {{#format}}({{format}}){{/format}}</td> + {{/ifeq}} +{{/ifeq}} +</tr> +{{/parameters}} +{{#if parameters}} +</table> +{{/if}} + + +#### Response + +{{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}} + + +| Status Code | Reason | Response Model | +|-------------|-------------|----------------| +{{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a>{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}{{^schema}} - {{/schema}}| +{{/each}}
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/templates/security.hbs b/services/activity-spec/activity-spec-web/activity-spec-war/templates/security.hbs new file mode 100644 index 0000000000..04f86e8380 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/templates/security.hbs @@ -0,0 +1,88 @@ +{{#each securityDefinitions}} +### {{@key}} +{{#this}} +{{#ifeq type "oauth2"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +{{#if authorizationUrl}} + <tr> + <th>authorizationUrl</th> + <th colspan="2">{{authorizationUrl}}</th> + </tr> +{{/if}} +{{#if flow}} + <tr> + <th>flow</th> + <th colspan="2">{{flow}}</th> + </tr> +{{/if}} +{{#if tokenUrl}} + <tr> + <th>tokenUrl</th> + <th colspan="2">{{tokenUrl}}</th> + </tr> +{{/if}} +{{#if scopes}} + <tr> + <td rowspan="3">scopes</td> +{{#each scopes}} + <td>{{@key}}</td> + <td>{{this}}</td> + </tr> + <tr> +{{/each}} + </tr> +{{/if}} +</table> +{{/ifeq}} +{{#ifeq type "apiKey"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +{{#if name}} + <tr> + <th>name</th> + <th colspan="2">{{name}}</th> + </tr> +{{/if}} +{{#if in}} + <tr> + <th>in</th> + <th colspan="2">{{in}}</th> + </tr> +{{/if}} +</table> +{{/ifeq}} +{{#ifeq type "basic"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +</table> +{{/ifeq}} +{{/this}} +{{/each}}
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-war/templates/strapdown.html.hbs b/services/activity-spec/activity-spec-web/activity-spec-war/templates/strapdown.html.hbs new file mode 100644 index 0000000000..fe722ab6f1 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-war/templates/strapdown.html.hbs @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> +<title>API Document</title> + +<!--xmp theme="united" style="display:none;"--> +<xmp theme="united" style="display:none;"> +{{>markdown}} +</xmp> + +<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script> +</html>
\ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/pom.xml b/services/activity-spec/activity-spec-web/pom.xml new file mode 100644 index 0000000000..c67a9c54f0 --- /dev/null +++ b/services/activity-spec/activity-spec-web/pom.xml @@ -0,0 +1,21 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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.activityspec</groupId> + <artifactId>activity-spec-web</artifactId> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.activityspec</groupId> + <artifactId>activity-spec</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + + <modules> + <module>activity-spec-service</module> + <module>activity-spec-war</module> + </modules> + +</project>
\ No newline at end of file |