2 * ================================================================================
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
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 * ================================================================================
20 package org.openecomp.portalapp.portal.service;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.util.jar.Attributes;
25 import java.util.jar.Manifest;
27 import javax.servlet.ServletContext;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.context.annotation.EnableAspectJAutoProxy;
31 import org.springframework.stereotype.Service;
33 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
34 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
36 @Service("manifestService")
37 @EnableAspectJAutoProxy
39 public class ManifestServiceImpl implements ManifestService {
41 ServletContext context;
45 * @see org.openecomp.portalapp.portal.service.ManifestService#getWebappManifest()
47 public Attributes getWebappManifest() throws IOException {
48 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestServiceImpl.class);
49 // Path to resource on classpath
50 final String MANIFEST_RESOURCE_PATH = "/META-INF/MANIFEST.MF";
51 // Manifest is formatted as Java-style properties
53 InputStream inputStream = context.getResourceAsStream(MANIFEST_RESOURCE_PATH);
54 Manifest manifest = new Manifest(inputStream);
56 return manifest.getMainAttributes();
57 } catch (IOException e) {
58 logger.error(EELFLoggerDelegate.errorLogger, "getWebappManifest: failed to read/find manifest");