summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-20 14:30:43 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-21 11:12:33 +0000
commit8e9c0653dd6c6862123c9609ae34e1206d86456e (patch)
tree5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main
parent785ebcc95de3e064e843bec04ba7a209d854fc7c (diff)
Add collaboration feature
Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java61
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java14
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java134
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java15
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java22
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java62
6 files changed, 308 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java
new file mode 100644
index 0000000000..396c4ee5d2
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdcrests.conflict.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.common.RestConstants;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/v1.0/items/{itemId}/versions/{versionId}/conflicts")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Version Conflicts")
+@Validated
+public interface Conflicts {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "item version conflicts",
+ notes = "Item version private copy conflicts against its public copy",
+ response = ItemVersionConflictDto.class)
+ Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{conflictId}")
+ @ApiOperation(value = "Gets item version conflict",
+ notes = "Gets an item version private copy conflict against its public copy",
+ response = ConflictDto.class)
+ Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @ApiParam("Version Id") @PathParam("conflictId") String conflictId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{conflictId}")
+ @ApiOperation(value = "Resolves item version conflict",
+ notes = "Resolves an item version private copy conflict against its public copy")
+ Response resolveConflict(ConflictResolutionDto conflictResolution,
+ @ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @ApiParam("Version Id") @PathParam("conflictId") String conflictId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java
new file mode 100644
index 0000000000..e80ef5653d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.ConflictInfo;
+import org.openecomp.sdcrests.conflict.types.ConflictInfoDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapConflictInfoToDto extends MappingBase<ConflictInfo, ConflictInfoDto> {
+ @Override
+ public void doMapping(ConflictInfo source, ConflictInfoDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java
new file mode 100644
index 0000000000..83a0f52155
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java
@@ -0,0 +1,134 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.mapping.EchoMapMapping;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementEntityToLicenseAgreementDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelEntityToDto;
+import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapFilesDataStructureToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireToQuestionnaireDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto;
+
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapConflictToDto extends MappingBase<Conflict, ConflictDto> {
+
+ @Override
+ public void doMapping(Conflict source, ConflictDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+
+ Map.Entry<MappingBase, Class> mapperToTargetClass = getMapper(source.getType());
+ target.setTheirs(map(mapperToTargetClass, source.getTheirs()));
+ target.setYours(map(mapperToTargetClass, source.getYours()));
+ }
+
+ private Map map(Map.Entry<MappingBase, Class> mapperToTargetClass, Object object) {
+ return JsonUtil
+ .json2Object(JsonUtil.object2Json(
+ mapperToTargetClass.getKey().applyMapping(object, mapperToTargetClass.getValue())),
+ Map.class);
+ }
+
+ private Map.Entry<MappingBase, Class> getMapper(ElementType type) {
+ switch (type) {
+ case VendorLicenseModel:
+ return new AbstractMap.SimpleEntry<>(new MapVendorLicenseModelEntityToDto(),
+ VendorLicenseModelEntityDto.class);
+ case LicenseAgreement:
+ return new AbstractMap.SimpleEntry<>(
+ new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(),
+ LicenseAgreementDescriptorDto.class);
+ case FeatureGroup:
+ return new AbstractMap.SimpleEntry<>(new MapFeatureGroupEntityToFeatureGroupDescriptorDto(),
+ FeatureGroupDescriptorDto.class);
+ case LicenseKeyGroup:
+ return new AbstractMap.SimpleEntry<>(
+ new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(), LicenseKeyGroupEntityDto
+ .class);
+ case EntitlementPool:
+ return new AbstractMap.SimpleEntry<>(
+ new MapEntitlementPoolEntityToEntitlementPoolEntityDto(), EntitlementPoolEntityDto
+ .class);
+ case Limit:
+ return new AbstractMap.SimpleEntry<>(new MapLimitEntityToLimitDto(), LimitEntityDto.class);
+ case VendorSoftwareProduct:
+ return new AbstractMap.SimpleEntry<>(new MapVspDetailsToDto(), VspDetailsDto.class);
+ case Network:
+ return new AbstractMap.SimpleEntry<>(new MapNetworkEntityToNetworkDto(), NetworkDto.class);
+ case Component:
+ return new AbstractMap.SimpleEntry<>(new MapComponentEntityToComponentDto(),
+ ComponentDto.class);
+ case ComponentDependencies:
+ return new AbstractMap.SimpleEntry<>(new MapComponentDependencyModelEntityToDto(),
+ ComponentDependencyModel.class);
+ case Nic:
+ return new AbstractMap.SimpleEntry<>(new MapNicEntityToNicDto(), NicDto.class);
+ case Process:
+ return new AbstractMap.SimpleEntry<>(new MapProcessEntityToProcessEntityDto(),
+ ProcessEntityDto.class);
+ case DeploymentFlavor:
+ return new AbstractMap.SimpleEntry<>(new MapDeploymentFlavorEntityToDeploymentFlavorDto(),
+ DeploymentFlavorDto.class);
+ case Compute:
+ return new AbstractMap.SimpleEntry<>(new MapComputeEntityToVspComputeDto(),
+ VspComputeDto.class);
+ case Image:
+ return new AbstractMap.SimpleEntry<>(new MapImageEntityToImageDto(), ImageDto.class);
+ case VSPQuestionnaire:
+ case NicQuestionnaire:
+ case ComponentQuestionnaire:
+ case ImageQuestionnaire:
+ case ComputeQuestionnaire:
+ return new AbstractMap.SimpleEntry<>(new MapQuestionnaireToQuestionnaireDto(),
+ QuestionnaireDto.class);
+ case SNMP_POLL:
+ case SNMP_TRAP:
+ case VES_EVENTS:
+ case OrchestrationTemplateCandidate:
+ return new AbstractMap.SimpleEntry<>(new MapFilesDataStructureToDto(),
+ FileDataStructureDto.class);
+ case ServiceModel:
+ case NetworkPackage:
+ return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class);
+ case itemVersion:
+ return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class);
+ }
+ throw new RuntimeException("Get conflict does not support element type: " + type.name());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java
new file mode 100644
index 0000000000..1a03a6b15e
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapDtoToConflictResolution
+ extends MappingBase<ConflictResolutionDto, ConflictResolution> {
+
+ @Override
+ public void doMapping(ConflictResolutionDto source, ConflictResolution target) {
+ target.setResolution(source.getResolution());
+ target.setOtherResolution(source.getOtherResolution());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java
new file mode 100644
index 0000000000..fb5d013aba
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictInfoDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapItemVersionConflictToDto
+ extends MappingBase<ItemVersionConflict, ItemVersionConflictDto> {
+
+ @Override
+ public void doMapping(ItemVersionConflict source, ItemVersionConflictDto target) {
+ target
+ .setConflict(new MapConflictToDto().applyMapping(source.getVersionConflict(), ConflictDto.class));
+
+ MapConflictInfoToDto conflictInfoMapper = new MapConflictInfoToDto();
+ source.getElementConflicts().forEach(conflictInfo -> target
+ .addConflictInfo(conflictInfoMapper.applyMapping(conflictInfo, ConflictInfoDto.class)));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java
new file mode 100644
index 0000000000..fda12ef4c6
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java
@@ -0,0 +1,62 @@
+package org.openecomp.sdcrests.conflict.rest.services;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.conflict.rest.Conflicts;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapConflictToDto;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapDtoToConflictResolution;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapItemVersionConflictToDto;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+@Named
+@Service("conflicts")
+@Scope(value = "prototype")
+public class ConflictsImpl implements Conflicts {
+
+ @Override
+ public Response getConflict(String itemId, String versionId, String user) {
+
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+ ItemVersionConflict itemVersionConflict = conflictsManager.getConflict
+ (itemId, new Version(versionId));
+ ItemVersionConflictDto result = (new MapItemVersionConflictToDto()).applyMapping
+ (itemVersionConflict, ItemVersionConflictDto.class);
+ return Response.ok(result).build();
+ }
+
+ @Override
+ public Response getConflict(String itemId, String versionId, String conflictId, String user) {
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+ Conflict conflict = conflictsManager.getConflict(itemId, new Version(versionId), conflictId);
+
+ ConflictDto result = new MapConflictToDto().applyMapping(conflict, ConflictDto.class);
+
+ return Response.ok(result).build();
+
+ }
+
+ @Override
+ public Response resolveConflict(ConflictResolutionDto conflictResolution, String itemId,
+ String versionId, String conflictId, String user) {
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+
+ Version version = new Version(versionId);
+ conflictsManager.resolveConflict(itemId, version, conflictId,
+ new MapDtoToConflictResolution()
+ .applyMapping(conflictResolution, ConflictResolution.class));
+ conflictsManager.finalizeMerge(itemId, version);
+
+ return Response.ok().build();
+ }
+}