summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml55
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java88
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java41
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java15
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java15
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java20
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java270
7 files changed, 504 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
new file mode 100644
index 0000000000..6b96a4d328
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-rest-services</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <!-- CXF -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java
new file mode 100644
index 0000000000..7d7b0854d9
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java
@@ -0,0 +1,88 @@
+package org.openecomp.sdcrests.item.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.item.types.VersionActionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.item.types.VersionRequestDto;
+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.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path("/v1.0/items/{itemId}/versions")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Versions")
+@Validated
+public interface Versions {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "Lists item versions",
+ response = VersionDto.class,
+ responseContainer = "List")
+ Response list(@PathParam("itemId") String itemId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @POST
+ @Path("/{versionId}")
+ @ApiOperation(value = "Creates a new item version")
+ Response create(VersionRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}")
+ @ApiOperation(value = "Gets item version", response = VersionDto.class)
+ Response get(@PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}/activity-logs")
+ @ApiOperation(value = "Gets item version activity log",
+ response = ActivityLogDto.class,
+ responseContainer = "List")
+ Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}/revisions")
+ @ApiOperation(value = "Gets item version revisions", response = RevisionDto.class,
+ responseContainer = "List")
+ Response listRevisions(@PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{versionId}/actions")
+ @ApiOperation(value = "Acts on item version")
+ Response actOn(VersionActionRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java
new file mode 100644
index 0000000000..307b555720
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.ActivityStatus;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapActivityLogEntityToDto
+ extends MappingBase<ActivityLogEntity, ActivityLogDto> {
+
+
+ @Override
+ public void doMapping(ActivityLogEntity source, ActivityLogDto target) {
+ target.setId(source.getId());
+ target.setTimestamp(source.getTimestamp());
+ target.setType(source.getType().name());
+ target.setComment(source.getComment());
+ target.setUser(source.getUser());
+ target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage()));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java
new file mode 100644
index 0000000000..26bd58d950
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdcrests.item.types.ItemDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapItemToDto extends MappingBase<Item, ItemDto> {
+ @Override
+ public void doMapping(Item source, ItemDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java
new file mode 100644
index 0000000000..861f571c5f
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapRevisionToDto extends MappingBase<Revision, RevisionDto> {
+ @Override
+ public void doMapping(Revision source, RevisionDto target) {
+ target.setId(source.getId());
+ target.setMessage(source.getMessage());
+ target.setUser(source.getUser());
+ target.setTime(source.getTime());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java
new file mode 100644
index 0000000000..5fbd9a9e8d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapVersionToDto extends MappingBase<Version, VersionDto> {
+ @Override
+ public void doMapping(Version source, VersionDto target) {
+ target.setId(source.getId());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ target.setBaseId(source.getBaseId());
+ target.setStatus(source.getStatus());
+ target.setState(source.getState());
+ target.setCreationTime(source.getCreationTime());
+ target.setModificationTime(source.getModificationTime());
+ target.setAdditionalInfo(source.getAdditionalInfo());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
new file mode 100644
index 0000000000..466734208d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.item.rest.services;
+
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.RevisionIdNotFoundErrorBuilder;
+import org.openecomp.sdc.versioning.types.NotificationEventTypes;
+import org.openecomp.sdcrests.item.rest.Versions;
+import org.openecomp.sdcrests.item.rest.mapping.MapActivityLogEntityToDto;
+import org.openecomp.sdcrests.item.rest.mapping.MapRevisionToDto;
+import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.CommitRequestDto;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.item.types.RevisionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionActionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.item.types.VersionRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
+
+@Named
+@Service("versions")
+@Scope(value = "prototype")
+public class VersionsImpl implements Versions {
+
+ private static final String COMMIT_ITEM_ACTION = "Commit_Item";
+ private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class);
+
+ private ItemPermissionsManager permissionsManager =
+ ItemPermissionsManagerFactory.getInstance().createInterface();
+ private ItemManager itemManager =
+ ItemManagerFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
+ private ConflictsManager conflictsManager =
+ ConflictsManagerFactory.getInstance().createInterface();
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
+ private NotificationPropagationManager notifier =
+ NotificationPropagationManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response list(String itemId, String user) {
+ GenericCollectionWrapper<VersionDto> results = new GenericCollectionWrapper<>();
+ MapVersionToDto mapper = new MapVersionToDto();
+
+ versioningManager.list(itemId)
+ .forEach(version -> results.add(mapper.applyMapping(version, VersionDto.class)));
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response create(VersionRequestDto request, String itemId, String baseVersionId,
+ String user) {
+ Version version = new Version();
+ version.setBaseId(baseVersionId);
+ version.setDescription(request.getDescription());
+
+ version = versioningManager.create(itemId, version, request.getCreationMethod());
+
+ VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class);
+
+ activityLogManager.logActivity(new ActivityLogEntity(itemId, version,
+ ActivityType.Create_Version, user, true, "", ""));
+
+ return Response.ok(versionDto).build();
+ }
+
+ @Override
+ public Response get(String itemId, String versionId, String user) {
+ Version version = getVersion(itemId, new Version(versionId));
+ VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class);
+ return Response.ok(versionDto).build();
+ }
+
+ @Override
+ public Response getActivityLog(String itemId, String versionId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString());
+
+ GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>();
+ MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto();
+
+ activityLogManager.listLoggedActivities(itemId, new Version(versionId))
+ .forEach(loggedActivity -> results
+ .add(mapper.applyMapping(loggedActivity, ActivityLogDto.class)));
+
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response listRevisions(String itemId, String versionId, String user) {
+ GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>();
+ MapRevisionToDto mapper = new MapRevisionToDto();
+
+ versioningManager.listRevisions(itemId, new Version(versionId))
+ .forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class)));
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response actOn(VersionActionRequestDto request, String itemId, String versionId,
+ String user) {
+ Version version = new Version(versionId);
+ switch (request.getAction()) {
+ case Sync:
+ sync(itemId, version);
+ break;
+ case Commit:
+ if (!permissionsManager.isAllowed(itemId, user, COMMIT_ITEM_ACTION)) {
+ return Response.status(Response.Status.FORBIDDEN)
+ .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build();
+ }
+ commit(request.getCommitRequest(), itemId, version, user);
+ break;
+ case Revert:
+ revert(request.getRevisionRequest(), itemId, versionId);
+ break;
+ case Reset:
+ throw new UnsupportedOperationException("Action reset not supported.");
+ default:
+ }
+ return Response.ok().build();
+ }
+
+
+ private void revert(RevisionRequestDto request, String itemId, String versionId) {
+ if (request.getRevisionId() == null) {
+ throw new CoreException(new RevisionIdNotFoundErrorBuilder().build());
+ }
+
+ versioningManager.revert(itemId, new Version(versionId), request.getRevisionId());
+ }
+
+ private void sync(String itemId, Version version) {
+ versioningManager.sync(itemId, version);
+ conflictsManager.finalizeMerge(itemId, version);
+ }
+
+ private void commit(CommitRequestDto request, String itemId, Version version, String user) {
+
+ String message = request == null ? "" : request.getMessage();
+
+ versioningManager.publish(itemId, version, message);
+ notifyUsers(itemId, version, message, user, NotificationEventTypes.COMMIT);
+
+ activityLogManager.logActivity(new ActivityLogEntity(itemId, version,
+ ActivityType.Commit, user, true, "", message));
+ }
+
+ private void notifyUsers(String itemId, Version version, String message,
+ String userName, NotificationEventTypes eventType) {
+ Map<String, Object> eventProperties = new HashMap<>();
+ eventProperties.put(ITEM_NAME, itemManager.get(itemId).getName());
+ eventProperties.put(ITEM_ID, itemId);
+
+ Version ver = versioningManager.get(itemId, version);
+ eventProperties.put(VERSION_NAME, ver.getName());
+ eventProperties.put(VERSION_ID, ver.getId());
+
+ eventProperties.put(SUBMIT_DESCRIPTION, message);
+ eventProperties.put(PERMISSION_USER, userName);
+
+ Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId);
+ try {
+ notifier.notifySubscribers(syncEvent, userName);
+ } catch (Exception e) {
+ LOGGER.error("Failed to send sync notification to users subscribed o item '" + itemId);
+ }
+ }
+
+ private class SyncEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ public SyncEvent(String eventType, String originatorId,
+ Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
+ }
+
+ private Version getVersion(String itemId, Version version) {
+ version = versioningManager.get(itemId, version);
+
+ if (version.getState().getSynchronizationState() != SynchronizationState.Merging &&
+ conflictsManager.isConflicted(itemId, version)) { // looks for sdc applicative conflicts
+ version.getState().setSynchronizationState(SynchronizationState.Merging);
+ }
+ return version;
+ }
+}