01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.romaframework.module.users;
18:
19: import java.util.HashMap;
20: import java.util.List;
21:
22: import org.romaframework.aspect.persistence.PersistenceAspect;
23: import org.romaframework.core.flow.ObjectContext;
24: import org.romaframework.module.admin.InfoHelper;
25: import org.romaframework.module.admin.domain.Info;
26: import org.romaframework.module.users.domain.ActivityLog;
27:
28: /**
29: * Log user and system activities.
30: *
31: * @author Luca Garulli (luca.garulli@assetdata.it)
32: */
33: public class ActivityLogHelper {
34:
35: protected ActivityLogHelper() {
36: // FILL CATEGORIES FROM DATABaSE
37: categories = new HashMap<String, Info>();
38:
39: List<Info> result = InfoHelper.getInstance().getInfoList(
40: ActivityLog.LOG_CATEGORY_NAME);
41: for (Info current : result)
42: categories.put(current.getText(), current);
43: }
44:
45: public void log(int iLevel, String iCategoryName, String iNotes) {
46: Info category = iCategoryName != null ? categories
47: .get(iCategoryName) : null;
48:
49: ObjectContext.getInstance().getContextComponent(
50: PersistenceAspect.class).createObject(
51: new ActivityLog(iLevel, category, iNotes));
52: }
53:
54: public static ActivityLogHelper getInstance() {
55: return instance;
56: }
57:
58: private HashMap<String, Info> categories;
59: private static ActivityLogHelper instance = new ActivityLogHelper();
60: }
|