2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdcrests.activitylog.rest.services;
23 import org.openecomp.sdc.activityLog.ActivityLogManager;
24 import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
25 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
26 import org.openecomp.sdc.logging.context.MdcUtil;
27 import org.openecomp.sdc.logging.types.LoggerServiceName;
28 import org.openecomp.sdc.versioning.dao.types.Version;
29 import org.openecomp.sdcrests.activitylog.rest.ActivityLog;
30 import org.openecomp.sdcrests.activitylog.rest.mapping.MapActivityLogEntityToActivityLogDto;
31 import org.openecomp.sdcrests.activitylog.types.ActivityLogDto;
32 import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
33 import org.springframework.context.annotation.Scope;
34 import org.springframework.stereotype.Service;
36 import javax.inject.Named;
37 import javax.ws.rs.core.Response;
38 import java.util.Collection;
41 @Service("activityLog")
42 @Scope(value = "prototype")
43 public class ActivityLogImpl implements ActivityLog {
45 private ActivityLogManager activityLogManager =
46 ActivityLogManagerFactory.getInstance().createInterface();
50 public Response getActivityLog(String vspId, String versionId, String user) {
51 MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString());
53 Collection<ActivityLogEntity> activityLogs =
54 activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user);
56 MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto();
57 GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>();
58 for (ActivityLogEntity activityLog : activityLogs) {
59 results.add(mapper.applyMapping(activityLog, ActivityLogDto.class));
62 return Response.ok(results).build();