Update license; improve coverage; add docs dir
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / ueb / EPUebHelper.java
index 55137cb..a56cfb6 100644 (file)
@@ -1,21 +1,39 @@
 /*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
  * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
+ *             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.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.openecomp.portalapp.portal.ueb;
 
@@ -28,37 +46,34 @@ import javax.annotation.PostConstruct;
 
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
-import org.openecomp.portalsdk.core.onboarding.ueb.Helper;
-import org.openecomp.portalsdk.core.onboarding.ueb.Publisher;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
 import org.openecomp.portalapp.portal.domain.EPApp;
 import org.openecomp.portalapp.portal.domain.EcompApp;
 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
 import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum;
 import org.openecomp.portalapp.portal.logging.logic.EPLogUtil;
 import org.openecomp.portalapp.portal.service.EPAppService;
-import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.onboarding.ueb.Helper;
+import org.openecomp.portalsdk.core.onboarding.ueb.Publisher;
+import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
+import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
+import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
+import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 
 @Component
 @Transactional
 @org.springframework.context.annotation.Configuration
 @EnableAspectJAutoProxy
 public class EPUebHelper {
-       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUebHelper.class);
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUebHelper.class);
        
        @Autowired
-       EPAppService appsService;
-       
+       private EPAppService appsService;
        
        @Autowired
        private SessionFactory sessionFactory;
@@ -124,9 +139,8 @@ public class EPUebHelper {
                                                            PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), 
                                                            PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME));
                } catch (Exception e) {
+                       logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e);
                        EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebConnectionError, e);
-                       String stackTrace = EcompPortalUtils.getStackTrace(e);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while initializing the publisher. Details: " + stackTrace);
                }
                
                Thread thread = new Thread("EPUebManager: postConstructMethod - refreshPublisherList") {
@@ -144,13 +158,11 @@ public class EPUebHelper {
                try {
                        UebManager.getInstance().addPublisher(app.getUebTopicName());
                } catch (UebException e) {
-                       String stackTrace = EcompPortalUtils.getStackTrace(e);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception while adding a publisher. Details: " + stackTrace);
+                       logger.error(EELFLoggerDelegate.errorLogger, "addPublisher failed", e);
                }
        }
        
        public boolean checkAvailability() {
-               
                //
                //  Test existence of topic at UEB url
                //
@@ -180,8 +192,7 @@ public class EPUebHelper {
                        }
                        catch (Exception e) {
                            available = false;
-                           String stackTrace = EcompPortalUtils.getStackTrace(e);
-                                       logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing the UEB Healthcheck. Details: " + stackTrace);
+                                       logger.error(EELFLoggerDelegate.errorLogger, "checkAvailability failed", e);
                        }
                    }
                }