diff options
Diffstat (limited to 'openecomp-be')
11 files changed, 381 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(); } diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java new file mode 100644 index 0000000000..a1ccaa6fd1 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.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.sdc.activitylog; + +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public interface ActivityLogManager { + + void logActivity(ActivityLogEntity activityLogEntity); + + Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version versionId); +}
\ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java new file mode 100644 index 0000000000..78645f983e --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java @@ -0,0 +1,26 @@ +/* + * 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.sdc.activitylog; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + + +public abstract class ActivityLogManagerFactory extends AbstractComponentFactory<ActivityLogManager> { + public static ActivityLogManagerFactory getInstance() { + return AbstractFactory.getInstance(ActivityLogManagerFactory.class); + } +}
\ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java new file mode 100644 index 0000000000..ac5d95b94b --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.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.sdc.activitylog.impl; + +import org.openecomp.sdc.activitylog.ActivityLogManager; +import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; +import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory; + +public class ActivityLogManagerFactoryImpl extends ActivityLogManagerFactory { + private static final ActivityLogManager INSTANCE = + new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface()); + + @Override + public ActivityLogManager createInterface() { + return INSTANCE; + } +}
\ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java new file mode 100644 index 0000000000..7acaa7cf70 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.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.sdc.activitylog.impl; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.activitylog.ActivityLogManager; +import org.openecomp.sdc.activitylog.dao.ActivityLogDao; +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public class ActivityLogManagerImpl implements ActivityLogManager { + private ActivityLogDao activityLogDao; + + public ActivityLogManagerImpl(ActivityLogDao activityLogDao) { + this.activityLogDao = activityLogDao; + } + + @Override + public void logActivity(ActivityLogEntity activityLogEntity) { + activityLogEntity.setId(CommonMethods.nextUuId()); + activityLogDao.create(activityLogEntity); + } + + @Override + public Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version version) { + return activityLogDao.list(new ActivityLogEntity(itemId, version)); + } +}
\ No newline at end of file diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/pom.xml b/openecomp-be/dist/sdc-onboard-backend-docker/pom.xml index e9cbabae74..0872f6a150 100644 --- a/openecomp-be/dist/sdc-onboard-backend-docker/pom.xml +++ b/openecomp-be/dist/sdc-onboard-backend-docker/pom.xml @@ -22,6 +22,33 @@ <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <executions> + <execution> + <id>clean files</id> + <phase>clean</phase> + <goals> + <goal>clean</goal> + </goals> + <configuration> + <filesets> + <fileset> + <directory>${project.basedir}/artifacts/</directory> + <followSymlinks>false</followSymlinks> + <includes> + <include>*.war</include> + <include>onboarding_configuration.yaml</include> + <include>logback.xml</include> + </includes> + </fileset> + </filesets> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> <executions> |