From e69a9895051c7115d0a201991c707fbef42e77e4 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Tue, 15 May 2018 11:09:21 +0530 Subject: Handle logger.debug(, exception) from code Removed logger.debug(, exception) from AbstractServiceModelDao, ActionAuthenticationFilter,ApplicationConfigManagerImpl Change-Id: I58665a7dfd7e3e29d630d136af1bbf65228a9a7d Issue-ID: SDC-836 Signed-off-by: mojahidi --- .../server/filters/ActionAuthenticationFilter.java | 32 +++++++-------- .../impl/ApplicationConfigManagerImpl.java | 26 ++++-------- .../sdc/model/impl/AbstractServiceModelDao.java | 47 +++++++++------------- 3 files changed, 41 insertions(+), 64 deletions(-) diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java index e10f6a57ab..7b001c84b2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java @@ -1,28 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2018 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= - */ +*/ package org.openecomp.server.filters; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; - +import java.io.IOException; +import java.security.Principal; +import java.util.Base64; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -32,9 +28,9 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.security.Principal; -import java.util.Base64; + +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; public class ActionAuthenticationFilter implements Filter { @@ -62,7 +58,7 @@ public class ActionAuthenticationFilter implements Filter { String decodedCredentials = new String(Base64.getDecoder().decode(base64Credentials)); username = decodedCredentials.substring(0, decodedCredentials.indexOf(":")); } catch (Exception exception) { - log.debug("",exception); + log.error("Failed to decode credentials", exception); setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); return; } @@ -87,7 +83,7 @@ public class ActionAuthenticationFilter implements Filter { .valueOf(username.substring(username.indexOf("-") + 1).toUpperCase()); return userPrivilege.ordinal() >= requiredPrivilege.ordinal(); } catch (Exception exception) { - log.debug("",exception); + log.error("Failed to validate UserInRole", exception); return false; } } diff --git a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java index 50b0100522..877103f49a 100644 --- a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java @@ -1,25 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2018 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= - */ +*/ package org.openecomp.sdc.applicationconfig.impl; +import java.util.Collection; import org.openecomp.core.utilities.applicationconfig.ApplicationConfig; import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; import org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigImpl; @@ -28,18 +25,12 @@ import org.openecomp.sdc.applicationconfig.ApplicationConfigManager; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; - -import java.util.Collection; /** * Created by Talio on 8/8/2016. */ public class ApplicationConfigManagerImpl implements ApplicationConfigManager { - private final Logger log = LoggerFactory.getLogger(this.getClass().getName()); - private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = "SCHEMA_GENERATOR_INITIALIZATION_ERROR"; private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = @@ -51,10 +42,9 @@ public class ApplicationConfigManagerImpl implements ApplicationConfigManager { try { applicationConfig.insertValue(namespace, key, value); } catch (Exception exception) { - log.debug("",exception); throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory .APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).withMessage( - SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build()); + SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception); } } diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java index 3d1c4553b3..938b33b173 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java @@ -1,25 +1,32 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2018 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= - */ +*/ package org.openecomp.sdc.model.impl; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.onap.sdc.tosca.datatypes.model.Import; + +import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.core.model.dao.ServiceArtifactDaoInter; import org.openecomp.core.model.dao.ServiceTemplateDaoInter; import org.openecomp.core.model.types.ServiceArtifact; @@ -30,26 +37,16 @@ import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import org.onap.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.Old1610ServiceTemplate; -import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.sdc.versioning.dao.VersionableDao; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - public class AbstractServiceModelDao implements VersionableDao { protected ServiceTemplateDaoInter templateDao; protected ServiceArtifactDaoInter artifactDao; - private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); @Override public void registerVersioning(String versionableEntityType) { @@ -144,11 +141,6 @@ public class AbstractServiceModelDao implements VersionableDao { return null; } - public List getServiceModelContentNames() { - - return null; - } - private String getServiceBase(String vspId, Version version) { return templateDao.getBase(vspId, version); } @@ -173,8 +165,7 @@ public class AbstractServiceModelDao implements VersionableDao { return new ToscaExtensionYamlUtil().yamlToObject(serviceTemplateContent, org.onap.sdc.tosca.datatypes.model.ServiceTemplate.class); }catch (Exception e){ - log.debug("",e); - System.out.println("Found vsp with old-versioned tosca service template"); + log.warn("Found vsp with old-versioned tosca service template", e); Old1610ServiceTemplate old1610ServiceTemplate = new ToscaExtensionYamlUtil().yamlToObject(serviceTemplateContent, Old1610ServiceTemplate.class); -- cgit 1.2.3-korg