nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / portal / service / ManifestServiceImpl.java
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.service;
21
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.util.jar.Attributes;
25 import java.util.jar.Manifest;
26
27 import javax.servlet.ServletContext;
28
29 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
30 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.EnableAspectJAutoProxy;
33 import org.springframework.stereotype.Service;
34
35
36
37 @Service("manifestService")
38 @EnableAspectJAutoProxy
39 @EPMetricsLog
40 public class ManifestServiceImpl implements ManifestService {
41
42
43         @Autowired
44         ServletContext context;
45
46         
47         // * (non-Javadoc)      
48         // * 
49          
50         public Attributes getWebappManifest() throws IOException {
51                 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestServiceImpl.class);
52                 // Path to resource on classpath
53                 final String MANIFEST_RESOURCE_PATH = "/META-INF/MANIFEST.MF";
54                 // Manifest is formatted as Java-style properties
55                 try {
56                         InputStream inputStream = context.getResourceAsStream(MANIFEST_RESOURCE_PATH);
57                         Manifest manifest = new Manifest(inputStream);
58                         inputStream.close();
59                         return manifest.getMainAttributes();
60                 } catch (IOException e) {
61                         logger.error(EELFLoggerDelegate.errorLogger, "getWebappManifest: failed to read/find manifest");
62                         throw e;
63                 }
64         }
65 }