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.policy.utils;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.util.Date;
26 import java.util.Properties;
28 import org.apache.log4j.Logger;
30 import com.att.cadi.Access;
33 * PolicyAccess used by AAF for logging purposes.
36 public class PolicyAccess implements Access {
37 private static final Logger logger = Logger.getLogger(PolicyAccess.class.getName());
39 private Properties properties = new Properties();
40 private Access.Level logLevel = Access.Level.INFO;
42 public PolicyAccess(Properties properties, Level level) {
43 this.properties = properties;
50 public ClassLoader classLoader() {
51 return getClass().getClassLoader();
55 public String decrypt(String enc, boolean arg1) throws IOException {
60 public String getProperty(String prop, String def) {
61 return properties.getProperty(prop, def);
65 public void load(InputStream in) throws IOException {
70 public void log(Level level, Object... args) {
71 if (logLevel.compareTo(level) > 0) {
74 StringBuffer sb = new StringBuffer();
75 sb.append(new Date()).append(' ').append(level);
80 public void log(Exception e, Object... args) {
81 StringBuffer sb = new StringBuffer();
82 sb.append(new Date()).append(" EXCEPTION ").append(e.getMessage());
84 logger.error(e.getMessage() + e);
88 public void setLogLevel(Level level) {
92 private void logtail(StringBuffer sb, Object[] args) {
93 for (Object o: args) {
94 String s = o.toString();
96 sb.append(' ').append(s);
99 logger.info(sb.toString());
103 public boolean willLog(Level arg0) {
104 // TODO Auto-generated method stub