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