1 package org.onap.portal.service;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.jar.Attributes;
6 import java.util.jar.Manifest;
7 import javax.servlet.ServletContext;
8 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.context.annotation.EnableAspectJAutoProxy;
11 import org.springframework.stereotype.Service;
14 @EnableAspectJAutoProxy
15 public class ManifestService {
18 ServletContext context;
20 public Attributes getWebappManifest() throws IOException {
21 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestService.class);
22 // Path to resource on classpath
23 final String MANIFEST_RESOURCE_PATH = "/META-INF/MANIFEST.MF";
24 // Manifest is formatted as Java-style properties
26 InputStream inputStream = context.getResourceAsStream(MANIFEST_RESOURCE_PATH);
27 Manifest manifest = new Manifest(inputStream);
29 return manifest.getMainAttributes();
30 } catch (IOException e) {
31 logger.error(EELFLoggerDelegate.errorLogger, "getWebappManifest: failed to read/find manifest");