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.controller;
22 import java.util.HashMap;
24 import java.util.jar.Attributes;
26 import javax.servlet.http.HttpServletRequest;
28 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
29 import org.openecomp.portalapp.portal.service.ManifestService;
30 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.context.annotation.Configuration;
34 import org.springframework.context.annotation.EnableAspectJAutoProxy;
35 import org.springframework.stereotype.Controller;
36 import org.springframework.web.bind.annotation.RequestMapping;
37 import org.springframework.web.bind.annotation.RequestMethod;
38 import org.springframework.web.bind.annotation.ResponseBody;
39 import org.springframework.web.bind.annotation.RestController;
44 * This controller responds to a request for the web application manifest,
45 * returning a JSON with the information that was created at build time.
47 * Manifest entries have names with hyphens, which means Javascript code can't
48 * simply use the shorthand object.key; instead use object['key'].
52 @EnableAspectJAutoProxy
56 public class ManifestController extends RestrictedBaseController {
58 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestController.class);
61 ManifestService manifestService;
64 * Gets the webapp manifest contents as a JSON object.
67 * @return A map of key-value pairs. On success:
70 * { "manifest" : { "key1": "value1", "key2": "value2" } }
76 * { "error": "message" }
79 @RequestMapping(value = { "/portalApi/manifest" }, method = RequestMethod.GET, produces = "application/json")
81 public Map<String, Object> getManifest(HttpServletRequest request) {
82 Map<String, Object> response = new HashMap<String, Object>();
84 Attributes attributes = manifestService.getWebappManifest();
85 response.put("manifest", attributes);
86 } catch (Exception ex) {
87 logger.error(EELFLoggerDelegate.errorLogger, "getManifest: failed to read manifest", ex);
88 response.put("error", "failed to get manifest: " + ex.toString());