diff options
author | Michael Lando <ml636r@att.com> | 2018-08-20 01:27:45 +0300 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-09-05 08:37:54 +0000 |
commit | 5c9769c3e3a6d6675c5ec1bd450720791ef2793c (patch) | |
tree | 91ca1c456ed703dacfd46ded2ac5918711c8ce1a /openecomp-be/api | |
parent | 828ee221b1d186e637bffffaeea1684e752ceb36 (diff) |
fix merge issue
restore activity log
add clean up to the onboarding back end docker
Issue-ID: SDC-1664
Change-Id: Ib7994ca12439bc842650c3cacddb0e4d87215390
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/api')
6 files changed, 225 insertions, 178 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java index eae8e4220e..b00e4594b3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java @@ -16,6 +16,9 @@ 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.datatypes.model.ItemType; import org.openecomp.sdc.itempermissions.PermissionsManager; @@ -64,6 +67,7 @@ public class ItemsImpl implements Items { private ItemManager itemManager = ItemManagerFactory.getInstance().createInterface(); + private static ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); private VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); @@ -200,6 +204,9 @@ public class ItemsImpl implements Items { private void execute(Item item, String user) { notifyUsers(item.getId(), item.getName(), user, this.notificationType); + activityLogManager.logActivity( + new ActivityLogEntity(item.getId(), getLatestVersion(item.getId()), this.activityType, user, true, + "", "")); } private void notifyUsers(String itemId, String itemName, String userName, NotificationEventTypes eventType) { 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 index fd46e7f274..cd6364f145 100644 --- 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 @@ -16,6 +16,10 @@ 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; @@ -60,199 +64,202 @@ import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; @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 PermissionsManager permissionsManager = - PermissionsManagerFactory.getInstance().createInterface(); - private AsdcItemManager asdcItemManager = - AsdcItemManagerFactory.getInstance().createInterface(); - private VersioningManager versioningManager = - VersioningManagerFactory.getInstance().createInterface(); - private ConflictsManager conflictsManager = - ConflictsManagerFactory.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, VersionCreationMethod.valueOf(request - .getCreationMethod().name())); - - VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class); - - 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) { - GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>(); - MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto(); - return Response.ok(results).build(); - } - - @Override - public Response listRevisions(String itemId, String versionId, String user) { - List<Revision> revisions = versioningManager.listRevisions(itemId, new Version(versionId)); - filterRevisions(revisions); - - GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>(); - MapRevisionToDto mapper = new MapRevisionToDto(); - revisions.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 Clean: - versioningManager.clean(itemId, version); - break; - default: - throw new UnsupportedOperationException(String.format("Action %s not supported.", request.getAction())); + private static final String COMMIT_ITEM_ACTION = "Commit_Item"; + private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class); + + private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); + private AsdcItemManager asdcItemManager = AsdcItemManagerFactory.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(); } - return Response.ok().build(); - } - private Version getVersion(String itemId, Version version) { - Version retrievedVersion = versioningManager.get(itemId, version); + @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, VersionCreationMethod.valueOf(request.getCreationMethod().name())); - if (retrievedVersion.getState().getSynchronizationState() != SynchronizationState.Merging && - // looks for sdc applicative conflicts - conflictsManager.isConflicted(itemId, retrievedVersion)) { - retrievedVersion.getState().setSynchronizationState(SynchronizationState.Merging); + VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class); + + activityLogManager + .logActivity(new ActivityLogEntity(itemId, version, ActivityType.Create_Version, user, true, "", "")); + + return Response.ok(versionDto).build(); } - return retrievedVersion; - } - private void sync(String itemId, Version version) { - versioningManager.sync(itemId, version); - conflictsManager.finalizeMerge(itemId, version); - } + @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(); + } - private void commit(CommitRequestDto request, String itemId, Version version, String user) { + @Override + public Response getActivityLog(String itemId, String versionId, String user) { + GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>(); + MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto(); - String message = request == null ? "" : request.getMessage(); + activityLogManager.listLoggedActivities(itemId, new Version(versionId)) + .forEach(loggedActivity -> results.add(mapper.applyMapping(loggedActivity, ActivityLogDto.class))); - versioningManager.publish(itemId, version, message); - notifyUsers(itemId, version, message, user, NotificationEventTypes.COMMIT); - } + return Response.ok(results).build(); + } - private void revert(RevisionRequestDto request, String itemId, String versionId) { - if (request.getRevisionId() == null) { - throw new CoreException(new RevisionIdNotFoundErrorBuilder().build()); + @Override + public Response listRevisions(String itemId, String versionId, String user) { + List<Revision> revisions = versioningManager.listRevisions(itemId, new Version(versionId)); + filterRevisions(revisions); + + GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>(); + MapRevisionToDto mapper = new MapRevisionToDto(); + revisions.forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class))); + return Response.ok(results).build(); } - versioningManager.revert(itemId, new Version(versionId), request.getRevisionId()); - } + @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 Clean: + versioningManager.clean(itemId, version); + break; + default: + throw new UnsupportedOperationException(String.format("Action %s not supported.", request.getAction())); + } + return Response.ok().build(); + } + + private Version getVersion(String itemId, Version version) { + Version retrievedVersion = versioningManager.get(itemId, version); + + if (retrievedVersion.getState().getSynchronizationState() != SynchronizationState.Merging && + // looks for sdc applicative conflicts + conflictsManager.isConflicted(itemId, retrievedVersion)) { + retrievedVersion.getState().setSynchronizationState(SynchronizationState.Merging); + } + return retrievedVersion; + } + + 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 filterRevisions(List<Revision> revisions) { + 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 filterRevisions(List<Revision> revisions) { /* When creating a new item an initial version is created with invalid data. This revision is not an applicable revision. The logic of identifying this revision is: 1- only the first version of item has this issue 2- only in the first item version there are 2 revisions created 3- the second revision is in format "Initial <vlm/vsp>: <name of the vlm/vsp>" 4- only if a revision in this format exists we remove the first revision. */ - int numOfRevisions = revisions.size(); - if (numOfRevisions > 1 && + int numOfRevisions = revisions.size(); + if (numOfRevisions > 1 && - revisions.get(numOfRevisions - 2).getMessage().matches("Initial .*:.*")) { - revisions.remove(numOfRevisions - 1); - } - } - - private void notifyUsers(String itemId, Version version, String message, - String userName, NotificationEventTypes eventType) { - Map<String, Object> eventProperties = new HashMap<>(); - eventProperties.put(ITEM_NAME, asdcItemManager.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); + revisions.get(numOfRevisions - 2).getMessage().matches("Initial .*:.*")) { + revisions.remove(numOfRevisions - 1); + } } - } - private class SyncEvent implements Event { - private String eventType; - private String originatorId; - private Map<String, Object> attributes; + private void notifyUsers(String itemId, Version version, String message, String userName, + NotificationEventTypes eventType) { + Map<String, Object> eventProperties = new HashMap<>(); + eventProperties.put(ITEM_NAME, asdcItemManager.get(itemId).getName()); + eventProperties.put(ITEM_ID, itemId); - private String entityId; + Version ver = versioningManager.get(itemId, version); + eventProperties.put(VERSION_NAME, ver.getName()); + eventProperties.put(VERSION_ID, ver.getId()); - public SyncEvent(String eventType, String originatorId, - Map<String, Object> attributes, String entityId) { - this.eventType = eventType; - this.originatorId = originatorId; - this.attributes = attributes; - this.entityId = entityId; - } + eventProperties.put(SUBMIT_DESCRIPTION, message); + eventProperties.put(PERMISSION_USER, userName); - @Override - public String getEventType() { - return eventType; + 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); + } } - @Override - public String getOriginatorId() { - return originatorId; - } + private class SyncEvent implements Event { - @Override - public Map<String, Object> getAttributes() { - return attributes; - } + private String eventType; + private String originatorId; + private Map<String, Object> attributes; - @Override - public String getEntityId() { - return entityId; - } + 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; + } + + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java index 815f06a18f..df6363c883 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java @@ -19,6 +19,10 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; +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.ErrorCode; import org.openecomp.sdc.common.errors.Messages; @@ -89,6 +93,7 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { private AsdcItemManager asdcItemManager = AsdcItemManagerFactory.getInstance().createInterface(); private VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); private UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @@ -133,6 +138,9 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); + activityLogManager + .logActivity(new ActivityLogEntity(vlm.getId(), version, ActivityType.Create, user, true, "", "")); + return Response.ok(itemCreationDto).build(); } @@ -218,6 +226,8 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { vendorLicenseManager.validate(vlmId, version); versioningManager.submit(vlmId, version, message); + activityLogManager + .logActivity(new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message)); } private void submitHealedVersion(String vlmId, Version healedVersion, String baseVersionId, String user) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java index aaf8a85ae2..5a5f61eed3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java @@ -1,26 +1,26 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.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.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager; @@ -51,6 +51,8 @@ public class ComponentProcessesImpl implements ComponentProcesses { private ProcessManager processManager = ProcessManagerFactory.getInstance().createInterface(); private ComponentManager componentManager = ComponentManagerFactory.getInstance().createInterface(); + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); @Override public Response list(String vspId, String versionId, String componentId, String user) { @@ -171,6 +173,8 @@ public class ComponentProcessesImpl implements ComponentProcesses { processManager.uploadProcessArtifact(attachment.getObject(InputStream.class), attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, processId); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, + ActivityType.Upload_Artifact, user, true, "", "")); return Response.ok().build(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java index b9827870cb..bdc422d580 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java @@ -20,6 +20,10 @@ import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.tuple.Pair; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +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.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -66,6 +70,8 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); private VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory .getInstance().createInterface(); + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); @Override public Response upload(String vspId, String versionId, Attachment fileToUpload, String user) { @@ -118,6 +124,9 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate Version version = new Version(versionId); OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, + ActivityType.Upload_Network_Package, user, true, "", "")); + OrchestrationTemplateActionResponseDto responseDto = new OrchestrationTemplateActionResponseDto(); BeanUtils.copyProperties(responseDto, response); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 14252cb893..f0fcd15939 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -19,6 +19,10 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; +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.ErrorCode; import org.openecomp.sdc.common.errors.Messages; @@ -100,6 +104,8 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { VersioningManagerFactory.getInstance().createInterface(); private final VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); + private final ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); private final NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); private final UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory @@ -161,7 +167,8 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { ItemCreationDto itemCreationDto = new ItemCreationDto(); itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); - + activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version, + ActivityType.Create, user, true, "", "")); return itemCreationDto; } @@ -493,12 +500,15 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { Map<String, List<ErrorMessage>> compilationErrors = vendorSoftwareProductManager.compile(vspId, version); if (!validationResponse.isValid() || MapUtils.isNotEmpty(compilationErrors)) { - + activityLogManager.logActivity( + new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, + "Failed on validation before submit", "")); return Optional.of(validationResponse); } versioningManager.submit(vspId, version, message); - + activityLogManager.logActivity( + new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); return Optional.empty(); } |