fix incorrect dependency
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / activity-log-rest / activity-log-rest-services / src / main / java / org / openecomp / sdcrests / activitylog / rest / services / ActivityLogImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.sdcrests.activitylog.rest.services;
22
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;
35
36 import javax.inject.Named;
37 import javax.ws.rs.core.Response;
38 import java.util.Collection;
39
40 @Named
41 @Service("activityLog")
42 @Scope(value = "prototype")
43 public class ActivityLogImpl implements ActivityLog {
44
45     private ActivityLogManager activityLogManager =
46             ActivityLogManagerFactory.getInstance().createInterface();
47
48
49     @Override
50     public Response getActivityLog(String vspId, String versionId, String user) {
51         MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString());
52
53         Collection<ActivityLogEntity> activityLogs =
54                 activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user);
55
56         MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto();
57         GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>();
58         for (ActivityLogEntity activityLog : activityLogs) {
59             results.add(mapper.applyMapping(activityLog, ActivityLogDto.class));
60         }
61
62         return Response.ok(results).build();
63     }
64 }
65