2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
20 package org.openecomp.portalapp.portal.service;
23 import java.util.Date;
24 import java.util.HashMap;
25 import java.util.List;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.context.annotation.EnableAspectJAutoProxy;
30 import org.springframework.stereotype.Service;
31 import org.springframework.transaction.annotation.Transactional;
33 import org.openecomp.portalsdk.core.service.DataAccessService;
34 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
36 @Service("epAuditService")
38 @org.springframework.context.annotation.Configuration
39 @EnableAspectJAutoProxy
41 public class EPAuditServiceImpl implements EPAuditService {
44 private DataAccessService dataAccessService;
47 /* get the guest last login time with attuid as param.
48 * If record not found in table, return null.
51 public Date getGuestLastLogin(String attuid) {
52 Map<String, String> params = new HashMap<>();
53 params.put("attuid", attuid);
54 List<Date> list = getDataAccessService().executeNamedQuery("getGuestLastLogin", params, null);
57 if(list.size()==1) /* if list only contains one item, meaning this is the first time user logs in or record not found in db*/
58 date = list.get(0); /*the guest's current log in time*/
59 else if(list.size()==2)
60 date = list.get(1); /*most recent login date from db*/
65 public DataAccessService getDataAccessService() {
66 return dataAccessService;
69 public void setDataAccessService(DataAccessService dataAccessService) {
70 this.dataAccessService = dataAccessService;